@openglobus/og 0.14.10 → 0.15.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 (140) hide show
  1. package/css/og.css +378 -275
  2. package/dist/@openglobus/og.css +1 -1
  3. package/dist/@openglobus/og.esm.js +2 -2
  4. package/dist/@openglobus/og.esm.js.map +1 -1
  5. package/dist/@openglobus/og.umd.js +2 -2
  6. package/dist/@openglobus/og.umd.js.map +1 -1
  7. package/package.json +18 -17
  8. package/src/og/Clock.js +218 -194
  9. package/src/og/Globe.js +5 -5
  10. package/src/og/Object3d.js +104 -145
  11. package/src/og/camera/Camera.js +31 -27
  12. package/src/og/camera/PlanetCamera.js +22 -14
  13. package/src/og/cons.js +107 -107
  14. package/src/og/control/Atmosphere.js +396 -0
  15. package/src/og/control/CompassButton.js +11 -18
  16. package/src/og/control/Control.js +187 -188
  17. package/src/og/control/GeoImageDragControl.js +84 -66
  18. package/src/og/control/LayerSwitcher.js +56 -138
  19. package/src/og/control/Lighting.js +314 -186
  20. package/src/og/control/MouseNavigation.js +2 -2
  21. package/src/og/control/RulerSwitcher.js +24 -19
  22. package/src/og/control/ScaleControl.js +30 -10
  23. package/src/og/control/SimpleSkyBackground.js +210 -0
  24. package/src/og/control/Sun.js +2 -0
  25. package/src/og/control/ZoomControl.js +30 -42
  26. package/src/og/control/index.js +6 -0
  27. package/src/og/control/ruler/RulerScene.js +5 -23
  28. package/src/og/control/selection/Selection.js +99 -0
  29. package/src/og/control/selection/SelectionScene.js +350 -0
  30. package/src/og/control/timeline/TimelineControl.js +99 -0
  31. package/src/og/control/timeline/TimelineModel.js +133 -0
  32. package/src/og/control/timeline/TimelineView.js +449 -0
  33. package/src/og/control/timeline/timelineUtils.js +132 -0
  34. package/src/og/ellipsoid/Ellipsoid.js +120 -93
  35. package/src/og/ellipsoid/wgs84.js +13 -13
  36. package/src/og/entity/Entity.js +36 -9
  37. package/src/og/entity/EntityCollection.js +0 -2
  38. package/src/og/entity/GeoObject.js +72 -56
  39. package/src/og/entity/GeoObjectHandler.js +487 -656
  40. package/src/og/entity/GeometryHandler.js +1341 -1337
  41. package/src/og/entity/Polyline.js +0 -16
  42. package/src/og/entity/Ray.js +0 -10
  43. package/src/og/entity/RayHandler.js +3 -44
  44. package/src/og/entity/Strip.js +1 -6
  45. package/src/og/index.js +10 -6
  46. package/src/og/input/input.js +3 -1
  47. package/src/og/layer/CanvasTiles.js +39 -34
  48. package/src/og/layer/Layer.js +69 -9
  49. package/src/og/layer/Material.js +1 -8
  50. package/src/og/layer/WMS.js +16 -5
  51. package/src/og/light/LightSource.js +2 -0
  52. package/src/og/math/Line3.js +140 -139
  53. package/src/og/math/Plane.js +118 -117
  54. package/src/og/math/Ray.js +242 -239
  55. package/src/og/math/Vec3.js +56 -37
  56. package/src/og/math/Vec4.js +3 -4
  57. package/src/og/math.js +21 -21
  58. package/src/og/quadTree/Node.js +5 -4
  59. package/src/og/quadTree/index.js +12 -0
  60. package/src/og/renderer/Renderer.js +64 -37
  61. package/src/og/renderer/RendererEvents.js +1071 -1065
  62. package/src/og/scene/Planet.js +352 -172
  63. package/src/og/scene/RenderNode.js +27 -12
  64. package/src/og/segment/Segment.js +0 -5
  65. package/src/og/shaders/atmos.js +332 -0
  66. package/src/og/shaders/drawnode.js +475 -109
  67. package/src/og/shaders/geoObject.js +96 -51
  68. package/src/og/shaders/polyline.js +212 -17
  69. package/src/og/shaders/ray.js +13 -6
  70. package/src/og/shaders/toneMapping.js +5 -5
  71. package/src/og/shaders/utils.js +88 -0
  72. package/src/og/terrain/GlobusTerrain.js +5 -4
  73. package/src/og/terrain/MapboxTerrain.js +231 -52
  74. package/src/og/ui/Button.js +106 -0
  75. package/src/og/ui/ButtonGroup.js +57 -0
  76. package/src/og/ui/Dialog.js +242 -0
  77. package/src/og/ui/Slider.js +144 -0
  78. package/src/og/ui/ToggleButton.js +51 -0
  79. package/src/og/{control → ui}/UIhelpers.js +11 -2
  80. package/src/og/ui/View.js +190 -0
  81. package/src/og/utils/shared.js +960 -942
  82. package/src/og/webgl/Framebuffer.js +308 -387
  83. package/src/og/webgl/Handler.js +90 -30
  84. package/src/og/webgl/Multisample.js +8 -0
  85. package/types/Clock.d.ts +7 -2
  86. package/types/Object3d.d.ts +14 -3
  87. package/types/camera/Camera.d.ts +18 -17
  88. package/types/camera/PlanetCamera.d.ts +3 -1
  89. package/types/control/Atmosphere.d.ts +15 -0
  90. package/types/control/CompassButton.d.ts +1 -2
  91. package/types/control/GeoImageDragControl.d.ts +7 -1
  92. package/types/control/LayerSwitcher.d.ts +5 -6
  93. package/types/control/Lighting.d.ts +32 -7
  94. package/types/control/ScaleControl.d.ts +2 -1
  95. package/types/control/SimpleSkyBackground.d.ts +15 -0
  96. package/types/control/ZoomControl.d.ts +0 -1
  97. package/types/control/index.d.ts +4 -1
  98. package/types/control/ruler/RulerScene.d.ts +0 -1
  99. package/types/control/selection/Selection.d.ts +49 -0
  100. package/types/control/selection/SelectionScene.d.ts +34 -0
  101. package/types/ellipsoid/Ellipsoid.d.ts +3 -2
  102. package/types/entity/Entity.d.ts +8 -0
  103. package/types/entity/GeoObject.d.ts +28 -22
  104. package/types/entity/GeoObjectHandler.d.ts +16 -56
  105. package/types/entity/Ray.d.ts +0 -3
  106. package/types/entity/RayHandler.d.ts +0 -4
  107. package/types/index.d.ts +7 -5
  108. package/types/input/input.d.ts +2 -0
  109. package/types/layer/CanvasTiles.d.ts +1 -0
  110. package/types/layer/Layer.d.ts +9 -0
  111. package/types/layer/WMS.d.ts +7 -3
  112. package/types/math/Plane.d.ts +1 -1
  113. package/types/math/Vec3.d.ts +19 -16
  114. package/types/math/Vec4.d.ts +2 -3
  115. package/types/math.d.ts +20 -20
  116. package/types/quadTree/index.d.ts +10 -0
  117. package/types/renderer/Renderer.d.ts +11 -37
  118. package/types/scene/Planet.d.ts +27 -1
  119. package/types/scene/RenderNode.d.ts +2 -1
  120. package/types/segment/Segment.d.ts +1 -1
  121. package/types/shaders/atmos.d.ts +4 -0
  122. package/types/shaders/drawnode.d.ts +3 -2
  123. package/types/shaders/utils.d.ts +1 -0
  124. package/types/terrain/GlobusTerrain.d.ts +1 -1
  125. package/types/terrain/MapboxTerrain.d.ts +2 -1
  126. package/types/ui/Button.d.ts +21 -0
  127. package/types/ui/Dialog.d.ts +41 -0
  128. package/types/ui/Slider.d.ts +30 -0
  129. package/types/ui/ToggleButton.d.ts +10 -0
  130. package/types/{control → ui}/UIhelpers.d.ts +1 -1
  131. package/types/ui/View.d.ts +32 -0
  132. package/types/utils/shared.d.ts +16 -14
  133. package/types/webgl/Framebuffer.d.ts +2 -5
  134. package/types/webgl/Handler.d.ts +15 -10
  135. package/types/webgl/Multisample.d.ts +2 -0
  136. package/src/og/ajax.js +0 -204
  137. package/src/og/entity/Object3d.js +0 -504
  138. package/src/og/utils/quadTreeType.js +0 -11
  139. package/types/ajax.d.ts +0 -24
  140. package/types/utils/quadTreeType.d.ts +0 -8
@@ -4,10 +4,9 @@
4
4
 
5
5
  "use strict";
6
6
 
7
- import * as math from "../math.js";
8
7
  import { Vec3 } from "../math/Vec3.js";
9
8
  import { LonLat } from "../LonLat.js";
10
- import { EPSILON10 } from "../math.js";
9
+ import { EPS1, EPS12, EPS15, RADIANS, DEGREES } from "../math.js";
11
10
 
12
11
  /**
13
12
  * Class represents a plant ellipsoid.
@@ -65,10 +64,10 @@ class Ellipsoid {
65
64
  * @returns {number} Distance in m between this point and destination point (same units as radius).
66
65
  */
67
66
  rhumbDistanceTo(startLonLat, endLonLat) {
68
- const f1 = startLonLat.lat * math.RADIANS;
69
- const f2 = endLonLat.lat * math.RADIANS;
67
+ const f1 = startLonLat.lat * RADIANS;
68
+ const f2 = endLonLat.lat * RADIANS;
70
69
  const df = f2 - f1;
71
- let d = Math.abs(endLonLat.lon - startLonLat.lon) * math.RADIANS;
70
+ let d = Math.abs(endLonLat.lon - startLonLat.lon) * RADIANS;
72
71
  if (Math.abs(d) > Math.PI) d = d > 0 ? -(2 * Math.PI - d) : (2 * Math.PI + d);
73
72
  const dd = Math.log(Math.tan(f2 / 2 + Math.PI / 4) / Math.tan(f1 / 2 + Math.PI / 4));
74
73
  const q = Math.abs(dd) > 10e-12 ? df / dd : Math.cos(f1);
@@ -83,10 +82,10 @@ class Ellipsoid {
83
82
  * @return {LonLat} Midpoint between points.
84
83
  */
85
84
  static getMiddlePointOnGreatCircle(lonLat1, lonLat2) {
86
- var f1 = lonLat1.lat * math.RADIANS,
87
- l1 = lonLat1.lon * math.RADIANS;
88
- var f2 = lonLat2.lat * math.RADIANS;
89
- var dl = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
85
+ var f1 = lonLat1.lat * RADIANS,
86
+ l1 = lonLat1.lon * RADIANS;
87
+ var f2 = lonLat2.lat * RADIANS;
88
+ var dl = (lonLat2.lon - lonLat1.lon) * RADIANS;
90
89
 
91
90
  var Bx = Math.cos(f2) * Math.cos(dl);
92
91
  var By = Math.cos(f2) * Math.sin(dl);
@@ -97,7 +96,7 @@ class Ellipsoid {
97
96
 
98
97
  var l3 = l1 + Math.atan2(By, Math.cos(f1) + Bx);
99
98
 
100
- return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
99
+ return new LonLat(((l3 * DEGREES + 540) % 360) - 180, f3 * DEGREES);
101
100
  }
102
101
 
103
102
  /**
@@ -108,10 +107,10 @@ class Ellipsoid {
108
107
  * @returns {LonLat} Intermediate point between points.
109
108
  */
110
109
  static getIntermediatePointOnGreatCircle(lonLat1, lonLat2, fraction) {
111
- var f1 = lonLat1.lat * math.RADIANS,
112
- l1 = lonLat1.lon * math.RADIANS;
113
- var f2 = lonLat2.lat * math.RADIANS,
114
- l2 = lonLat2.lon * math.RADIANS;
110
+ var f1 = lonLat1.lat * RADIANS,
111
+ l1 = lonLat1.lon * RADIANS;
112
+ var f2 = lonLat2.lat * RADIANS,
113
+ l2 = lonLat2.lon * RADIANS;
115
114
 
116
115
  var sinf1 = Math.sin(f1),
117
116
  cosf1 = Math.cos(f1),
@@ -139,14 +138,14 @@ class Ellipsoid {
139
138
  var f3 = Math.atan2(z, Math.sqrt(x * x + y * y));
140
139
  var l3 = Math.atan2(y, x);
141
140
 
142
- return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
141
+ return new LonLat(((l3 * DEGREES + 540) % 360) - 180, f3 * DEGREES);
143
142
  }
144
143
 
145
144
  static getRhumbBearing(lonLat1, lonLat2) {
146
- var dLon = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
145
+ var dLon = (lonLat2.lon - lonLat1.lon) * RADIANS;
147
146
  var dPhi = Math.log(
148
- Math.tan((lonLat2.lat * math.RADIANS) / 2 + Math.PI / 4) /
149
- Math.tan((lonLat1.lat * math.RADIANS) / 2 + Math.PI / 4)
147
+ Math.tan((lonLat2.lat * RADIANS) / 2 + Math.PI / 4) /
148
+ Math.tan((lonLat1.lat * RADIANS) / 2 + Math.PI / 4)
150
149
  );
151
150
  if (Math.abs(dLon) > Math.PI) {
152
151
  if (dLon > 0) {
@@ -155,17 +154,17 @@ class Ellipsoid {
155
154
  dLon = 2 * Math.PI + dLon;
156
155
  }
157
156
  }
158
- return (Math.atan2(dLon, dPhi) * math.DEGREES + 360) % 360;
157
+ return (Math.atan2(dLon, dPhi) * DEGREES + 360) % 360;
159
158
  }
160
159
 
161
160
  static getBearing(lonLat1, lonLat2) {
162
- var f1 = lonLat1.lat * math.RADIANS,
163
- l1 = lonLat1.lon * math.RADIANS;
164
- var f2 = lonLat2.lat * math.RADIANS,
165
- l2 = lonLat2.lon * math.RADIANS;
161
+ var f1 = lonLat1.lat * RADIANS,
162
+ l1 = lonLat1.lon * RADIANS;
163
+ var f2 = lonLat2.lat * RADIANS,
164
+ l2 = lonLat2.lon * RADIANS;
166
165
  var y = Math.sin(l2 - l1) * Math.cos(f2);
167
166
  var x = Math.cos(f1) * Math.sin(f2) - Math.sin(f1) * Math.cos(f2) * Math.cos(l2 - l1);
168
- return Math.atan2(y, x) * math.DEGREES;
167
+ return Math.atan2(y, x) * DEGREES;
169
168
  }
170
169
 
171
170
  /**
@@ -175,13 +174,13 @@ class Ellipsoid {
175
174
  * @return {number} Initial bearing in degrees from north.
176
175
  */
177
176
  static getInitialBearing(lonLat1, lonLat2) {
178
- var f1 = lonLat1.lat * math.RADIANS,
179
- f2 = lonLat2.lat * math.RADIANS;
180
- var dl = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
177
+ var f1 = lonLat1.lat * RADIANS,
178
+ f2 = lonLat2.lat * RADIANS;
179
+ var dl = (lonLat2.lon - lonLat1.lon) * RADIANS;
181
180
  var y = Math.sin(dl) * Math.cos(f2);
182
181
  var x = Math.cos(f1) * Math.sin(f2) - Math.sin(f1) * Math.cos(f2) * Math.cos(dl);
183
182
  var D = Math.atan2(y, x);
184
- return (D * math.DEGREES + 360) % 360;
183
+ return (D * DEGREES + 360) % 360;
185
184
  }
186
185
 
187
186
  /**
@@ -193,12 +192,12 @@ class Ellipsoid {
193
192
  * @return {LonLat|null} Destination point (null if no unique intersection defined).
194
193
  */
195
194
  static intersection(p1, brng1, p2, brng2) {
196
- var f1 = p1.lat * math.RADIANS,
197
- l1 = p1.lon * math.RADIANS;
198
- var f2 = p2.lat * math.RADIANS,
199
- l2 = p2.lon * math.RADIANS;
200
- var D13 = brng1 * math.RADIANS,
201
- D23 = brng2 * math.RADIANS;
195
+ var f1 = p1.lat * RADIANS,
196
+ l1 = p1.lon * RADIANS;
197
+ var f2 = p2.lat * RADIANS,
198
+ l2 = p2.lon * RADIANS;
199
+ var D13 = brng1 * RADIANS,
200
+ D23 = brng2 * RADIANS;
202
201
  var df = f2 - f1,
203
202
  dl = l2 - l1;
204
203
 
@@ -250,7 +249,7 @@ class Ellipsoid {
250
249
  );
251
250
  var l3 = l1 + dl13;
252
251
 
253
- return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
252
+ return new LonLat(((l3 * DEGREES + 540) % 360) - 180, f3 * DEGREES);
254
253
  }
255
254
 
256
255
  /**
@@ -290,8 +289,8 @@ class Ellipsoid {
290
289
  * @returns {Vec3} -
291
290
  */
292
291
  lonLatToCartesian(lonlat) {
293
- var latrad = math.RADIANS * lonlat.lat,
294
- lonrad = math.RADIANS * lonlat.lon;
292
+ var latrad = RADIANS * lonlat.lat,
293
+ lonrad = RADIANS * lonlat.lon;
295
294
 
296
295
  var slt = Math.sin(latrad);
297
296
 
@@ -313,8 +312,8 @@ class Ellipsoid {
313
312
  * @returns {Vec3} -
314
313
  */
315
314
  lonLatToCartesianRes(lonlat, res) {
316
- var latrad = math.RADIANS * lonlat.lat,
317
- lonrad = math.RADIANS * lonlat.lon;
315
+ var latrad = RADIANS * lonlat.lat,
316
+ lonrad = RADIANS * lonlat.lon;
318
317
 
319
318
  var slt = Math.sin(latrad);
320
319
 
@@ -337,8 +336,8 @@ class Ellipsoid {
337
336
  * @returns {Vec3} -
338
337
  */
339
338
  geodeticToCartesian(lon, lat, height = 0) {
340
- var latrad = math.RADIANS * lat,
341
- lonrad = math.RADIANS * lon;
339
+ var latrad = RADIANS * lat,
340
+ lonrad = RADIANS * lon;
342
341
 
343
342
  var slt = Math.sin(latrad);
344
343
 
@@ -355,44 +354,72 @@ class Ellipsoid {
355
354
  /**
356
355
  * Gets Wgs84 geodetic coordiantes from cartesian ECEF.
357
356
  * @public
358
- * @param {Vec3} cartesian - Cartesian coordinates.
357
+ * @param {Vec3} p - Cartesian coordinates.
359
358
  * @returns {LonLat} -
360
359
  */
361
- cartesianToLonLat(cartesian) {
362
- var x = cartesian.z,
363
- y = cartesian.x,
364
- z = cartesian.y;
365
- var ecc2 = this._e2;
366
- var ecc22 = this._e22;
367
- var r2 = x * x + y * y;
368
- var r = Math.sqrt(r2);
369
- var z2 = z * z;
370
- var f = 54.0 * this._b2 * z2;
371
- var g = r2 + (1.0 - ecc2) * z2 + ecc2 * (this._a2 - this._b2);
372
- var g2 = g * g;
373
- var c = (ecc22 * f * r2) / (g2 * g);
374
- var s = Math.pow(1.0 + c + Math.sqrt(c * (c + 2.0)), 0.33333333333333333);
375
- var p = f / (3.0 * Math.pow(1.0 + s + 1.0 / s, 2.0) * g2);
376
- var q = Math.sqrt(1.0 + 2.0 * ecc22 * p);
377
- var recc2r0 =
378
- r -
379
- ecc2 *
380
- (-(p * ecc2 * r) / 1 +
381
- q +
382
- Math.sqrt(
383
- 0.5 * this._a2 * (1.0 + 1.0 / q) -
384
- (p * (1.0 - ecc2) * z2) / (q * (1.0 + q)) -
385
- 0.5 * p * r2
386
- ));
387
- var recc2r02 = recc2r0 * recc2r0;
388
- var v = Math.sqrt(recc2r02 + (1.0 - ecc2) * z2);
389
- var z0 = (this._b2 * z) / (this._a * v);
390
- var lat = Math.atan((z + this._k2 * z0) / r) * math.DEGREES;
391
- var lon = Math.atan2(y, x) * math.DEGREES;
360
+ projToSurface(p) {
361
+
362
+ let pX = p.x || 0.0,
363
+ pY = p.y || 0.0,
364
+ pZ = p.z || 0.0;
365
+
366
+ let invRadii2X = this._invRadii2.x,
367
+ invRadii2Y = this._invRadii2.y,
368
+ invRadii2Z = this._invRadii2.z;
369
+
370
+ let x2 = pX * pX * invRadii2X,
371
+ y2 = pY * pY * invRadii2Y,
372
+ z2 = pZ * pZ * invRadii2Z;
373
+
374
+ let norm = x2 + y2 + z2;
375
+ let ratio = Math.sqrt(1.0 / norm);
376
+ let first = p.scaleTo(ratio);
377
+
378
+ if (norm < EPS1) {
379
+ return !Number.isFinite(ratio) ? new Vec3() : first
380
+ }
381
+
382
+ let lambda = ((1.0 - ratio) * p.length()) / first.mulA(this._invRadii2).length();
383
+
384
+ let m_X, m_Y, m_Z;
385
+
386
+ do {
387
+ m_X = 1.0 / (1.0 + lambda * invRadii2X);
388
+ m_Y = 1.0 / (1.0 + lambda * invRadii2Y);
389
+ m_Z = 1.0 / (1.0 + lambda * invRadii2Z);
390
+
391
+ let m_X2 = m_X * m_X,
392
+ m_Y2 = m_Y * m_Y,
393
+ m_Z2 = m_Z * m_Z;
394
+
395
+ let func = x2 * m_X2 + y2 * m_Y2 + z2 * m_Z2 - 1.0;
396
+
397
+ if (Math.abs(func) < EPS12) {
398
+ break;
399
+ }
400
+
401
+ let m_X3 = m_X2 * m_X,
402
+ m_Y3 = m_Y2 * m_Y,
403
+ m_Z3 = m_Z2 * m_Z;
404
+
405
+ lambda += 0.5 * func / (x2 * m_X3 * invRadii2X + y2 * m_Y3 * invRadii2Y + z2 * m_Z3 * invRadii2Z);
406
+
407
+ } while (true); // eslint-disable-line
408
+
409
+ return new Vec3(pX * m_X, pY * m_Y, pZ * m_Z);
410
+ }
411
+
412
+ cartesianToLonLat(cart) {
413
+
414
+ let p = this.projToSurface(cart);
415
+
416
+ let n = this.getSurfaceNormal3v(p),
417
+ h = cart.sub(p);
418
+
392
419
  return new LonLat(
393
- lon,
394
- lat,
395
- cartesian.length() - this.geodeticToCartesian(lon, lat).length()
420
+ Math.atan2(n.x, n.z) * DEGREES,
421
+ Math.asin(n.y) * DEGREES,
422
+ Math.sign(h.dot(cart)) * h.length()
396
423
  );
397
424
  }
398
425
 
@@ -403,11 +430,11 @@ class Ellipsoid {
403
430
  * @return {Vec3} -
404
431
  */
405
432
  getSurfaceNormal3v(coord) {
406
- var r2 = this._invRadii2;
407
- var nx = coord.x * r2.x,
433
+ let r2 = this._invRadii2;
434
+ let nx = coord.x * r2.x,
408
435
  ny = coord.y * r2.y,
409
436
  nz = coord.z * r2.z;
410
- var l = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
437
+ let l = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
411
438
  return new Vec3(nx * l, ny * l, nz * l);
412
439
  }
413
440
 
@@ -419,10 +446,10 @@ class Ellipsoid {
419
446
  * @return {LonLat} -
420
447
  */
421
448
  getBearingDestination(lonLat1, bearing = 0.0, distance = 0) {
422
- bearing = bearing * math.RADIANS;
449
+ bearing = bearing * RADIANS;
423
450
  var nlon = ((lonLat1.lon + 540) % 360) - 180;
424
- var f1 = lonLat1.lat * math.RADIANS,
425
- l1 = nlon * math.RADIANS;
451
+ var f1 = lonLat1.lat * RADIANS,
452
+ l1 = nlon * RADIANS;
426
453
  var dR = distance / this._a;
427
454
  var f2 = Math.asin(
428
455
  Math.sin(f1) * Math.cos(dR) + Math.cos(f1) * Math.sin(dR) * Math.cos(bearing)
@@ -433,8 +460,8 @@ class Ellipsoid {
433
460
  Math.sin(bearing) * Math.sin(dR) * Math.cos(f1),
434
461
  Math.cos(dR) - Math.sin(f1) * Math.sin(f2)
435
462
  )) *
436
- math.DEGREES,
437
- f2 * math.DEGREES
463
+ DEGREES,
464
+ f2 * DEGREES
438
465
  );
439
466
  }
440
467
 
@@ -445,14 +472,14 @@ class Ellipsoid {
445
472
  * @return {number} Distance between points.
446
473
  */
447
474
  getGreatCircleDistance(lonLat1, lonLat2) {
448
- var dLat = (lonLat2.lat - lonLat1.lat) * math.RADIANS;
449
- var dLon = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
475
+ var dLat = (lonLat2.lat - lonLat1.lat) * RADIANS;
476
+ var dLon = (lonLat2.lon - lonLat1.lon) * RADIANS;
450
477
  var a =
451
478
  Math.sin(dLat / 2.0) * Math.sin(dLat / 2.0) +
452
479
  Math.sin(dLon / 2.0) *
453
480
  Math.sin(dLon / 2) *
454
- Math.cos(lonLat1.lat * math.RADIANS) *
455
- Math.cos(lonLat2.lat * math.RADIANS);
481
+ Math.cos(lonLat1.lat * RADIANS) *
482
+ Math.cos(lonLat2.lat * RADIANS);
456
483
  return this._a * 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));
457
484
  }
458
485
 
@@ -469,10 +496,10 @@ class Ellipsoid {
469
496
  b = this._b,
470
497
  f = 1.0 / this._f,
471
498
  s = dist,
472
- alpha1 = brng * math.RADIANS,
499
+ alpha1 = brng * RADIANS,
473
500
  sinAlpha1 = Math.sin(alpha1),
474
501
  cosAlpha1 = Math.cos(alpha1),
475
- tanU1 = (1 - f) * Math.tan(lat1 * math.RADIANS),
502
+ tanU1 = (1 - f) * Math.tan(lat1 * RADIANS),
476
503
  cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1),
477
504
  sinU1 = tanU1 * cosU1,
478
505
  sigma1 = Math.atan2(tanU1, cosAlpha1),
@@ -520,7 +547,7 @@ class Ellipsoid {
520
547
  sinSigma *
521
548
  (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM))),
522
549
  revAz = Math.atan2(sinAlpha, -tmp); // final bearing
523
- return new LonLat(lon1 + L * math.DEGREES, lat2 * math.DEGREES);
550
+ return new LonLat(lon1 + L * DEGREES, lat2 * DEGREES);
524
551
  }
525
552
 
526
553
  /**
@@ -555,7 +582,7 @@ class Ellipsoid {
555
582
 
556
583
  let eps = Math.abs(qw2 - product);
557
584
 
558
- if (eps > math.EPSILON15 && qw2 < product) {
585
+ if (eps > EPS15 && qw2 < product) {
559
586
  // Imaginary roots (0 intersections).
560
587
  return null;
561
588
  } else if (qw2 > product) {
@@ -594,4 +621,4 @@ class Ellipsoid {
594
621
  }
595
622
  }
596
623
 
597
- export { Ellipsoid };
624
+ export { Ellipsoid };
@@ -1,13 +1,13 @@
1
- /**
2
- * @module og/ellipsoid/wgs84
3
- */
4
-
5
- "use strict";
6
-
7
- import { Ellipsoid } from "./Ellipsoid.js";
8
-
9
- /**
10
- * WGS84 ellipsoid object.
11
- * @type {Ellipsoid}
12
- */
13
- export const wgs84 = new Ellipsoid(6378137.0, 6356752.3142); // Equitorial Radius (m), Polar Radius (m)
1
+ /**
2
+ * @module og/ellipsoid/wgs84
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Ellipsoid } from "./Ellipsoid.js";
8
+
9
+ /**
10
+ * WGS84 ellipsoid object.
11
+ * @type {Ellipsoid}
12
+ */
13
+ export const wgs84 = new Ellipsoid(6378137.0, 6356752.3142451793); // Equitorial Radius (m), Polar Radius (m)
@@ -338,9 +338,9 @@ class Entity {
338
338
  setCartesian(x, y, z) {
339
339
  let p = this._cartesian;
340
340
 
341
- p.x = x;
342
- p.y = y;
343
- p.z = z;
341
+ p.x = x || 0.0;
342
+ p.y = y || 0.0;
343
+ p.z = z || 0.0;
344
344
 
345
345
  // billboards
346
346
  this.billboard && this.billboard.setPosition3v(p);
@@ -382,9 +382,9 @@ class Entity {
382
382
  _setCartesian3vSilent(cartesian, skipLonLat) {
383
383
  let p = this._cartesian;
384
384
 
385
- p.x = cartesian.x;
386
- p.y = cartesian.y;
387
- p.z = cartesian.z;
385
+ p.x = cartesian.x || 0.0;
386
+ p.y = cartesian.y || 0.0;
387
+ p.z = cartesian.z || 0.0;
388
388
 
389
389
  // billboards
390
390
  this.billboard && this.billboard.setPosition3v(p);
@@ -438,13 +438,40 @@ class Entity {
438
438
 
439
439
  let ec = this._entityCollection;
440
440
  if (ec && ec.renderNode && ec.renderNode.ellipsoid) {
441
- if (Math.abs(lonlat.lat) < mercator.MAX_LAT) {
442
- this._lonlatMerc = lonlat.forwardMercator();
441
+ if (Math.abs(l.lat) < mercator.MAX_LAT) {
442
+ this._lonlatMerc = l.forwardMercator();
443
443
  } else {
444
444
  this._lonlatMerc = null;
445
445
  }
446
446
 
447
- ec.renderNode.ellipsoid.lonLatToCartesianRes(lonlat, this._cartesian);
447
+ ec.renderNode.ellipsoid.lonLatToCartesianRes(l, this._cartesian);
448
+ this.setCartesian3v(this._cartesian);
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Sets geodetic coordinates of the entity point object.
454
+ * @public
455
+ * @param {number} lon - Longitude.
456
+ * @param {number} lat - Latitude
457
+ * @param {number} [height] - Height
458
+ */
459
+ setLonLat2(lon, lat, height) {
460
+ let l = this._lonlat;
461
+
462
+ l.lon = lon;
463
+ l.lat = lat;
464
+ l.height = height != undefined ? height : l.height;
465
+
466
+ let ec = this._entityCollection;
467
+ if (ec && ec.renderNode && ec.renderNode.ellipsoid) {
468
+ if (Math.abs(l.lat) < mercator.MAX_LAT) {
469
+ this._lonlatMerc = l.forwardMercator();
470
+ } else {
471
+ this._lonlatMerc = null;
472
+ }
473
+
474
+ ec.renderNode.ellipsoid.lonLatToCartesianRes(l, this._cartesian);
448
475
  this.setCartesian3v(this._cartesian);
449
476
  }
450
477
  }
@@ -505,9 +505,7 @@ class EntityCollection {
505
505
  this.billboardHandler.setRenderer(renderNode.renderer);
506
506
  this.labelHandler.setRenderer(renderNode.renderer);
507
507
  this.rayHandler.setRenderer(renderNode.renderer);
508
-
509
508
  this.geoObjectHandler.setRenderNode(renderNode);
510
-
511
509
  this.shapeHandler.setRenderNode(renderNode);
512
510
  this.polylineHandler.setRenderNode(renderNode);
513
511
  this.pointCloudHandler.setRenderNode(renderNode);