@openglobus/og 0.11.5 → 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 (145) hide show
  1. package/package.json +5 -7
  2. package/src/og/Clock.js +6 -10
  3. package/src/og/Events.js +5 -7
  4. package/src/og/Extent.js +73 -32
  5. package/src/og/ImageCanvas.js +18 -15
  6. package/src/og/LonLat.js +13 -10
  7. package/src/og/Popup.js +18 -17
  8. package/src/og/QueueArray.js +3 -4
  9. package/src/og/Rectangle.js +4 -6
  10. package/src/og/Stack.js +2 -4
  11. package/src/og/ajax.js +20 -14
  12. package/src/og/astro/earth.js +21 -15
  13. package/src/og/bv/Box.js +2 -3
  14. package/src/og/bv/Sphere.js +10 -7
  15. package/src/og/camera/Frustum.js +19 -12
  16. package/src/og/camera/PlanetCamera.js +0 -1
  17. package/src/og/control/CompassButton.js +1 -2
  18. package/src/og/control/Control.js +7 -9
  19. package/src/og/control/DebugInfo.js +0 -1
  20. package/src/og/control/KeyboardNavigation.js +9 -9
  21. package/src/og/control/LayerSwitcher.js +21 -20
  22. package/src/og/control/SegmentBoundVisualization.js +5 -6
  23. package/src/og/control/ShowFps.js +12 -7
  24. package/src/og/control/SimpleNavigation.js +5 -7
  25. package/src/og/control/Sun.js +22 -12
  26. package/src/og/control/ToggleWireframe.js +3 -3
  27. package/src/og/control/TouchNavigation.js +43 -32
  28. package/src/og/control/ZoomControl.js +40 -24
  29. package/src/og/ellipsoid/Ellipsoid.js +148 -56
  30. package/src/og/ellipsoid/wgs84.js +3 -3
  31. package/src/og/entity/BaseBillboard.js +65 -14
  32. package/src/og/entity/Billboard.js +9 -5
  33. package/src/og/entity/BillboardHandler.js +310 -64
  34. package/src/og/entity/Entity.js +39 -1
  35. package/src/og/entity/EntityCollection.js +47 -24
  36. package/src/og/entity/GeoObject.js +228 -0
  37. package/src/og/entity/GeoObjectHandler.js +910 -0
  38. package/src/og/entity/GeometryHandler.js +595 -123
  39. package/src/og/entity/Label.js +53 -18
  40. package/src/og/entity/LabelHandler.js +42 -244
  41. package/src/og/entity/LabelWorker.js +213 -0
  42. package/src/og/entity/Object3d.js +504 -0
  43. package/src/og/entity/PointCloud.js +76 -28
  44. package/src/og/entity/PointCloudHandler.js +5 -5
  45. package/src/og/entity/Ray.js +49 -16
  46. package/src/og/entity/Strip.js +72 -43
  47. package/src/og/entity/StripHandler.js +23 -23
  48. package/src/og/layer/BaseGeoImage.js +50 -19
  49. package/src/og/layer/CanvasTiles.js +16 -16
  50. package/src/og/layer/GeoImage.js +6 -6
  51. package/src/og/layer/KML.js +55 -33
  52. package/src/og/layer/Layer.js +3 -3
  53. package/src/og/layer/Vector.js +94 -48
  54. package/src/og/layer/WMS.js +33 -16
  55. package/src/og/light/LightSource.js +19 -12
  56. package/src/og/math/Mat3.js +24 -12
  57. package/src/og/math/Mat4.js +603 -603
  58. package/src/og/math/Plane.js +19 -18
  59. package/src/og/math/Ray.js +17 -12
  60. package/src/og/math/Vec2.js +24 -14
  61. package/src/og/math/Vec3.js +60 -30
  62. package/src/og/math/coder.js +7 -7
  63. package/src/og/proj/EPSG3857.js +3 -3
  64. package/src/og/proj/EPSG4326.js +3 -3
  65. package/src/og/proj/Proj.js +2 -4
  66. package/src/og/quadTree/Node.js +31 -17
  67. package/src/og/renderer/Renderer.js +23 -6
  68. package/src/og/renderer/RendererEvents.js +1 -1
  69. package/src/og/scene/BaseNode.js +2 -3
  70. package/src/og/scene/Planet.js +2 -2
  71. package/src/og/scene/RenderNode.js +15 -8
  72. package/src/og/shaders/geoObject.js +211 -0
  73. package/src/og/shaders/pointCloud.js +41 -41
  74. package/src/og/shaders/shape.js +12 -18
  75. package/src/og/shaders/skybox.js +36 -36
  76. package/src/og/shapes/BaseShape.js +107 -35
  77. package/src/og/shapes/Icosphere.js +25 -10
  78. package/src/og/shapes/Sphere.js +8 -11
  79. package/src/og/utils/TextureAtlas.js +16 -18
  80. package/src/og/utils/shared.js +1 -1
  81. package/src/og/webgl/Handler.js +68 -49
  82. package/src/og/webgl/Multisample.js +44 -16
  83. package/src/og/webgl/Program.js +78 -33
  84. package/src/og/webgl/callbacks.js +3 -3
  85. package/types/Deferred.d.ts +1 -1
  86. package/types/Events.d.ts +2 -2
  87. package/types/Extent.d.ts +1 -1
  88. package/types/Rectangle.d.ts +1 -1
  89. package/types/ajax.d.ts +1 -1
  90. package/types/bv/Box.d.ts +1 -1
  91. package/types/bv/Sphere.d.ts +1 -1
  92. package/types/camera/Camera.d.ts +5 -5
  93. package/types/camera/Frustum.d.ts +6 -6
  94. package/types/camera/PlanetCamera.d.ts +8 -8
  95. package/types/control/Control.d.ts +1 -1
  96. package/types/control/EarthCoordinates.d.ts +1 -1
  97. package/types/control/Sun.d.ts +1 -1
  98. package/types/entity/BaseBillboard.d.ts +15 -8
  99. package/types/entity/Entity.d.ts +24 -9
  100. package/types/entity/EntityCollection.d.ts +15 -9
  101. package/types/entity/GeoObject.d.ts +111 -0
  102. package/types/entity/GeoObjectHandler.d.ts +77 -0
  103. package/types/entity/Geometry.d.ts +1 -1
  104. package/types/entity/GeometryHandler.d.ts +1 -1
  105. package/types/entity/Label.d.ts +3 -3
  106. package/types/entity/LabelHandler.d.ts +2 -0
  107. package/types/entity/LabelWorker.d.ts +9 -0
  108. package/types/entity/PointCloud.d.ts +1 -1
  109. package/types/entity/Polyline.d.ts +5 -5
  110. package/types/entity/Ray.d.ts +1 -1
  111. package/types/entity/Strip.d.ts +1 -1
  112. package/types/layer/BaseGeoImage.d.ts +3 -3
  113. package/types/layer/CanvasTiles.d.ts +5 -5
  114. package/types/layer/GeoImage.d.ts +1 -1
  115. package/types/layer/GeoVideo.d.ts +1 -1
  116. package/types/layer/Layer.d.ts +5 -5
  117. package/types/layer/Vector.d.ts +9 -9
  118. package/types/layer/XYZ.d.ts +3 -3
  119. package/types/light/LightSource.d.ts +7 -7
  120. package/types/math/Plane.d.ts +1 -1
  121. package/types/math/Ray.d.ts +1 -1
  122. package/types/math/Vec2.d.ts +34 -34
  123. package/types/math/Vec3.d.ts +1 -1
  124. package/types/math/Vec4.d.ts +1 -1
  125. package/types/math/coder.d.ts +1 -1
  126. package/types/math.d.ts +1 -1
  127. package/types/proj/Proj.d.ts +2 -2
  128. package/types/quadTree/Node.d.ts +1 -1
  129. package/types/renderer/Renderer.d.ts +12 -10
  130. package/types/renderer/RendererEvents.d.ts +1 -1
  131. package/types/scene/BaseNode.d.ts +4 -4
  132. package/types/scene/Planet.d.ts +40 -40
  133. package/types/scene/RenderNode.d.ts +9 -9
  134. package/types/segment/Segment.d.ts +9 -9
  135. package/types/shaders/geoObject.d.ts +3 -0
  136. package/types/shapes/BaseShape.d.ts +5 -5
  137. package/types/terrain/EmptyTerrain.d.ts +2 -2
  138. package/types/terrain/GlobusTerrain.d.ts +4 -4
  139. package/types/utils/TextureAtlas.d.ts +4 -4
  140. package/types/utils/shared.d.ts +9 -9
  141. package/types/webgl/Framebuffer.d.ts +1 -1
  142. package/types/webgl/Handler.d.ts +16 -7
  143. package/types/webgl/Multisample.d.ts +2 -2
  144. package/types/webgl/Program.d.ts +6 -0
  145. package/types/webgl/ProgramController.d.ts +1 -1
@@ -2,11 +2,11 @@
2
2
  * @module og/ellipsoid/Ellipsoid
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import * as math from '../math.js';
8
- import { Vec3 } from '../math/Vec3.js';
9
- import { LonLat } from '../LonLat.js';
7
+ import * as math from "../math.js";
8
+ import { Vec3 } from "../math/Vec3.js";
9
+ import { LonLat } from "../LonLat.js";
10
10
 
11
11
  /**
12
12
  * Class represents a plant ellipsoid.
@@ -44,8 +44,10 @@ class Ellipsoid {
44
44
  }
45
45
 
46
46
  static getRelativeBearing(a, b) {
47
- let a_y = Math.cos(a), a_x = Math.sin(a),
48
- b_y = Math.cos(b), b_x = Math.sin(b);
47
+ let a_y = Math.cos(a),
48
+ a_x = Math.sin(a),
49
+ b_y = Math.cos(b),
50
+ b_x = Math.sin(b);
49
51
  let c = a_y * b_x - b_y * a_x,
50
52
  d = a_x * b_x + a_y * b_y;
51
53
  if (c > 0.0) {
@@ -75,7 +77,7 @@ class Ellipsoid {
75
77
 
76
78
  var l3 = l1 + Math.atan2(By, Math.cos(f1) + Bx);
77
79
 
78
- return new LonLat((l3 * math.DEGREES + 540) % 360 - 180, f3 * math.DEGREES);
80
+ return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
79
81
  }
80
82
 
81
83
  /**
@@ -86,15 +88,25 @@ class Ellipsoid {
86
88
  * @returns {LonLat} Intermediate point between points.
87
89
  */
88
90
  static getIntermediatePointOnGreatCircle(lonLat1, lonLat2, fraction) {
89
- var f1 = lonLat1.lat * math.RADIANS, l1 = lonLat1.lon * math.RADIANS;
90
- var f2 = lonLat2.lat * math.RADIANS, l2 = lonLat2.lon * math.RADIANS;
91
-
92
- var sinf1 = Math.sin(f1), cosf1 = Math.cos(f1), sinl1 = Math.sin(l1), cosl1 = Math.cos(l1);
93
- var sinf2 = Math.sin(f2), cosf2 = Math.cos(f2), sinl2 = Math.sin(l2), cosl2 = Math.cos(l2);
91
+ var f1 = lonLat1.lat * math.RADIANS,
92
+ l1 = lonLat1.lon * math.RADIANS;
93
+ var f2 = lonLat2.lat * math.RADIANS,
94
+ l2 = lonLat2.lon * math.RADIANS;
95
+
96
+ var sinf1 = Math.sin(f1),
97
+ cosf1 = Math.cos(f1),
98
+ sinl1 = Math.sin(l1),
99
+ cosl1 = Math.cos(l1);
100
+ var sinf2 = Math.sin(f2),
101
+ cosf2 = Math.cos(f2),
102
+ sinl2 = Math.sin(l2),
103
+ cosl2 = Math.cos(l2);
94
104
 
95
105
  var df = f2 - f1,
96
106
  dl = l2 - l1;
97
- var a = Math.sin(df / 2) * Math.sin(df / 2) + Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2);
107
+ var a =
108
+ Math.sin(df / 2) * Math.sin(df / 2) +
109
+ Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2);
98
110
  var d = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
99
111
 
100
112
  var A = Math.sin((1 - fraction) * d) / Math.sin(d);
@@ -107,12 +119,15 @@ class Ellipsoid {
107
119
  var f3 = Math.atan2(z, Math.sqrt(x * x + y * y));
108
120
  var l3 = Math.atan2(y, x);
109
121
 
110
- return new LonLat((l3 * math.DEGREES + 540) % 360 - 180, f3 * math.DEGREES);
122
+ return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
111
123
  }
112
124
 
113
125
  static getRhumbBearing(lonLat1, lonLat2) {
114
126
  var dLon = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
115
- var dPhi = Math.log(Math.tan(lonLat2.lat * math.RADIANS / 2 + Math.PI / 4) / Math.tan(lonLat1.lat * math.RADIANS / 2 + Math.PI / 4));
127
+ var dPhi = Math.log(
128
+ Math.tan((lonLat2.lat * math.RADIANS) / 2 + Math.PI / 4) /
129
+ Math.tan((lonLat1.lat * math.RADIANS) / 2 + Math.PI / 4)
130
+ );
116
131
  if (Math.abs(dLon) > Math.PI) {
117
132
  if (dLon > 0) {
118
133
  dLon = (2 * Math.PI - dLon) * -1;
@@ -124,8 +139,10 @@ class Ellipsoid {
124
139
  }
125
140
 
126
141
  static getBearing(lonLat1, lonLat2) {
127
- var f1 = lonLat1.lat * math.RADIANS, l1 = lonLat1.lon * math.RADIANS;
128
- var f2 = lonLat2.lat * math.RADIANS, l2 = lonLat2.lon * math.RADIANS;
142
+ var f1 = lonLat1.lat * math.RADIANS,
143
+ l1 = lonLat1.lon * math.RADIANS;
144
+ var f2 = lonLat2.lat * math.RADIANS,
145
+ l2 = lonLat2.lon * math.RADIANS;
129
146
  var y = Math.sin(l2 - l1) * Math.cos(f2);
130
147
  var x = Math.cos(f1) * Math.sin(f2) - Math.sin(f1) * Math.cos(f2) * Math.cos(l2 - l1);
131
148
  return Math.atan2(y, x) * math.DEGREES;
@@ -142,8 +159,7 @@ class Ellipsoid {
142
159
  f2 = lonLat2.lat * math.RADIANS;
143
160
  var dl = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
144
161
  var y = Math.sin(dl) * Math.cos(f2);
145
- var x = Math.cos(f1) * Math.sin(f2) -
146
- Math.sin(f1) * Math.cos(f2) * Math.cos(dl);
162
+ var x = Math.cos(f1) * Math.sin(f2) - Math.sin(f1) * Math.cos(f2) * Math.cos(dl);
147
163
  var D = Math.atan2(y, x);
148
164
  return (D * math.DEGREES + 360) % 360;
149
165
  }
@@ -166,19 +182,30 @@ class Ellipsoid {
166
182
  var df = f2 - f1,
167
183
  dl = l2 - l1;
168
184
 
169
- var d12 = 2 * Math.asin(Math.sqrt(Math.sin(df / 2) * Math.sin(df / 2) + Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2)));
185
+ var d12 =
186
+ 2 *
187
+ Math.asin(
188
+ Math.sqrt(
189
+ Math.sin(df / 2) * Math.sin(df / 2) +
190
+ Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2)
191
+ )
192
+ );
170
193
  if (d12 == 0) return null;
171
194
 
172
195
  // initial/final bearings between points
173
- var Da = Math.acos((Math.sin(f2) - Math.sin(f1) * Math.cos(d12)) / (Math.sin(d12) * Math.cos(f1)));
196
+ var Da = Math.acos(
197
+ (Math.sin(f2) - Math.sin(f1) * Math.cos(d12)) / (Math.sin(d12) * Math.cos(f1))
198
+ );
174
199
  if (isNaN(Da)) Da = 0; // protect against rounding
175
- var Db = Math.acos((Math.sin(f1) - Math.sin(f2) * Math.cos(d12)) / (Math.sin(d12) * Math.cos(f2)));
200
+ var Db = Math.acos(
201
+ (Math.sin(f1) - Math.sin(f2) * Math.cos(d12)) / (Math.sin(d12) * Math.cos(f2))
202
+ );
176
203
 
177
204
  var D12 = Math.sin(l2 - l1) > 0 ? Da : 2 * Math.PI - Da;
178
205
  var D21 = Math.sin(l2 - l1) > 0 ? 2 * Math.PI - Db : Db;
179
206
 
180
- var a1 = (D13 - D12 + Math.PI) % (2 * Math.PI) - Math.PI;
181
- var a2 = (D21 - D23 + Math.PI) % (2 * Math.PI) - Math.PI;
207
+ var a1 = ((D13 - D12 + Math.PI) % (2 * Math.PI)) - Math.PI;
208
+ var a2 = ((D21 - D23 + Math.PI) % (2 * Math.PI)) - Math.PI;
182
209
 
183
210
  if (Math.sin(a1) == 0 && Math.sin(a2) == 0) return null; // infinite intersections
184
211
  if (Math.sin(a1) * Math.sin(a2) < 0) return null; // ambiguous intersection
@@ -187,13 +214,23 @@ class Ellipsoid {
187
214
  // a2 = Math.abs(a2);
188
215
  // ... Ed Williams takes abs of a1/a2, but seems to break calculation?
189
216
 
190
- var a3 = Math.acos(-Math.cos(a1) * Math.cos(a2) + Math.sin(a1) * Math.sin(a2) * Math.cos(d12));
191
- var d13 = Math.atan2(Math.sin(d12) * Math.sin(a1) * Math.sin(a2), Math.cos(a2) + Math.cos(a1) * Math.cos(a3));
192
- var f3 = Math.asin(Math.sin(f1) * Math.cos(d13) + Math.cos(f1) * Math.sin(d13) * Math.cos(D13));
193
- var dl13 = Math.atan2(Math.sin(D13) * Math.sin(d13) * Math.cos(f1), Math.cos(d13) - Math.sin(f1) * Math.sin(f3));
217
+ var a3 = Math.acos(
218
+ -Math.cos(a1) * Math.cos(a2) + Math.sin(a1) * Math.sin(a2) * Math.cos(d12)
219
+ );
220
+ var d13 = Math.atan2(
221
+ Math.sin(d12) * Math.sin(a1) * Math.sin(a2),
222
+ Math.cos(a2) + Math.cos(a1) * Math.cos(a3)
223
+ );
224
+ var f3 = Math.asin(
225
+ Math.sin(f1) * Math.cos(d13) + Math.cos(f1) * Math.sin(d13) * Math.cos(D13)
226
+ );
227
+ var dl13 = Math.atan2(
228
+ Math.sin(D13) * Math.sin(d13) * Math.cos(f1),
229
+ Math.cos(d13) - Math.sin(f1) * Math.sin(f3)
230
+ );
194
231
  var l3 = l1 + dl13;
195
232
 
196
- return new LonLat((l3 * math.DEGREES + 540) % 360 - 180, f3 * math.DEGREES);
233
+ return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
197
234
  }
198
235
 
199
236
  /**
@@ -244,7 +281,8 @@ class Ellipsoid {
244
281
  return new Vec3(
245
282
  nc * Math.sin(lonrad),
246
283
  (N * (1.0 - this._e2) + lonlat.height) * slt,
247
- nc * Math.cos(lonrad));
284
+ nc * Math.cos(lonrad)
285
+ );
248
286
  }
249
287
 
250
288
  /**
@@ -252,7 +290,7 @@ class Ellipsoid {
252
290
  * @public
253
291
  * @param {LonLat} lonlat - Degrees geodetic coordiantes.
254
292
  * @param {Vec3} res - Output result.
255
- * @returns {Vec3} -
293
+ * @returns {Vec3} -
256
294
  */
257
295
  lonLatToCartesianRes(lonlat, res) {
258
296
  var latrad = math.RADIANS * lonlat.lat,
@@ -290,7 +328,8 @@ class Ellipsoid {
290
328
  return new Vec3(
291
329
  nc * Math.sin(lonrad),
292
330
  (N * (1 - this._e2) + height) * slt,
293
- nc * Math.cos(lonrad));
331
+ nc * Math.cos(lonrad)
332
+ );
294
333
  }
295
334
 
296
335
  /**
@@ -300,7 +339,9 @@ class Ellipsoid {
300
339
  * @returns {LonLat} -
301
340
  */
302
341
  cartesianToLonLat(cartesian) {
303
- var x = cartesian.z, y = cartesian.x, z = cartesian.y;
342
+ var x = cartesian.z,
343
+ y = cartesian.x,
344
+ z = cartesian.y;
304
345
  var ecc2 = this._e2;
305
346
  var ecc22 = this._e22;
306
347
  var r2 = x * x + y * y;
@@ -309,17 +350,30 @@ class Ellipsoid {
309
350
  var f = 54.0 * this._b2 * z2;
310
351
  var g = r2 + (1.0 - ecc2) * z2 + ecc2 * (this._a2 - this._b2);
311
352
  var g2 = g * g;
312
- var c = ecc22 * f * r2 / (g2 * g);
313
- var s = Math.pow((1.0 + c + Math.sqrt(c * (c + 2.0))), 0.33333333333333333);
314
- var p = f / (3.0 * Math.pow((1.0 + s + 1.0 / s), 2.0) * g2);
353
+ var c = (ecc22 * f * r2) / (g2 * g);
354
+ var s = Math.pow(1.0 + c + Math.sqrt(c * (c + 2.0)), 0.33333333333333333);
355
+ var p = f / (3.0 * Math.pow(1.0 + s + 1.0 / s, 2.0) * g2);
315
356
  var q = Math.sqrt(1.0 + 2.0 * ecc22 * p);
316
- var recc2r0 = r - ecc2 * (-(p * ecc2 * r) / 1 + q + Math.sqrt(0.5 * this._a2 * (1.0 + 1.0 / q) - p * (1.0 - ecc2) * z2 / (q * (1.0 + q)) - 0.5 * p * r2));
357
+ var recc2r0 =
358
+ r -
359
+ ecc2 *
360
+ (-(p * ecc2 * r) / 1 +
361
+ q +
362
+ Math.sqrt(
363
+ 0.5 * this._a2 * (1.0 + 1.0 / q) -
364
+ (p * (1.0 - ecc2) * z2) / (q * (1.0 + q)) -
365
+ 0.5 * p * r2
366
+ ));
317
367
  var recc2r02 = recc2r0 * recc2r0;
318
368
  var v = Math.sqrt(recc2r02 + (1.0 - ecc2) * z2);
319
- var z0 = this._b2 * z / (this._a * v);
369
+ var z0 = (this._b2 * z) / (this._a * v);
320
370
  var lat = Math.atan((z + this._k2 * z0) / r) * math.DEGREES;
321
371
  var lon = Math.atan2(y, x) * math.DEGREES;
322
- return new LonLat(lon, lat, cartesian.length() - this.geodeticToCartesian(lon, lat).length());
372
+ return new LonLat(
373
+ lon,
374
+ lat,
375
+ cartesian.length() - this.geodeticToCartesian(lon, lat).length()
376
+ );
323
377
  }
324
378
 
325
379
  /**
@@ -339,11 +393,22 @@ class Ellipsoid {
339
393
 
340
394
  getBearingDestination(lonLat1, bearing, distance) {
341
395
  bearing = bearing * math.RADIANS;
342
- var nlon = (lonLat1.lon + 540) % 360 - 180;
343
- var f1 = lonLat1.lat * math.RADIANS, l1 = nlon * math.RADIANS;
396
+ var nlon = ((lonLat1.lon + 540) % 360) - 180;
397
+ var f1 = lonLat1.lat * math.RADIANS,
398
+ l1 = nlon * math.RADIANS;
344
399
  var dR = distance / this._a;
345
- var f2 = Math.asin(Math.sin(f1) * Math.cos(dR) + Math.cos(f1) * Math.sin(dR) * Math.cos(bearing));
346
- return new LonLat((l1 + Math.atan2(Math.sin(bearing) * Math.sin(dR) * Math.cos(f1), Math.cos(dR) - Math.sin(f1) * Math.sin(f2))) * math.DEGREES, f2 * math.DEGREES);
400
+ var f2 = Math.asin(
401
+ Math.sin(f1) * Math.cos(dR) + Math.cos(f1) * Math.sin(dR) * Math.cos(bearing)
402
+ );
403
+ return new LonLat(
404
+ (l1 +
405
+ Math.atan2(
406
+ Math.sin(bearing) * Math.sin(dR) * Math.cos(f1),
407
+ Math.cos(dR) - Math.sin(f1) * Math.sin(f2)
408
+ )) *
409
+ math.DEGREES,
410
+ f2 * math.DEGREES
411
+ );
347
412
  }
348
413
 
349
414
  /**
@@ -355,8 +420,12 @@ class Ellipsoid {
355
420
  getGreatCircleDistance(lonLat1, lonLat2) {
356
421
  var dLat = (lonLat2.lat - lonLat1.lat) * math.RADIANS;
357
422
  var dLon = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
358
- var a = Math.sin(dLat / 2.0) * Math.sin(dLat / 2.0) +
359
- Math.sin(dLon / 2.0) * Math.sin(dLon / 2) * Math.cos(lonLat1.lat * math.RADIANS) * Math.cos(lonLat2.lat * math.RADIANS);
423
+ var a =
424
+ Math.sin(dLat / 2.0) * Math.sin(dLat / 2.0) +
425
+ Math.sin(dLon / 2.0) *
426
+ Math.sin(dLon / 2) *
427
+ Math.cos(lonLat1.lat * math.RADIANS) *
428
+ Math.cos(lonLat2.lat * math.RADIANS);
360
429
  return this._a * 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));
361
430
  }
362
431
 
@@ -377,28 +446,52 @@ class Ellipsoid {
377
446
  sinAlpha1 = Math.sin(alpha1),
378
447
  cosAlpha1 = Math.cos(alpha1),
379
448
  tanU1 = (1 - f) * Math.tan(lat1 * math.RADIANS),
380
- cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1)), sinU1 = tanU1 * cosU1,
449
+ cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1),
450
+ sinU1 = tanU1 * cosU1,
381
451
  sigma1 = Math.atan2(tanU1, cosAlpha1),
382
452
  sinAlpha = cosU1 * sinAlpha1,
383
453
  cosSqAlpha = 1 - sinAlpha * sinAlpha,
384
- uSq = cosSqAlpha * (a * a - b * b) / (b * b),
385
- A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq))),
386
- B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))),
454
+ uSq = (cosSqAlpha * (a * a - b * b)) / (b * b),
455
+ A = 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq))),
456
+ B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))),
387
457
  sigma = s / (b * A),
388
458
  sigmaP = 2 * Math.PI;
389
459
  while (Math.abs(sigma - sigmaP) > 1e-12) {
390
460
  var cos2SigmaM = Math.cos(2 * sigma1 + sigma),
391
461
  sinSigma = Math.sin(sigma),
392
462
  cosSigma = Math.cos(sigma),
393
- deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
463
+ deltaSigma =
464
+ B *
465
+ sinSigma *
466
+ (cos2SigmaM +
467
+ (B / 4) *
468
+ (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) -
469
+ (B / 6) *
470
+ cos2SigmaM *
471
+ (-3 + 4 * sinSigma * sinSigma) *
472
+ (-3 + 4 * cos2SigmaM * cos2SigmaM)));
394
473
  sigmaP = sigma;
395
474
  sigma = s / (b * A) + deltaSigma;
396
475
  }
397
476
  var tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1,
398
- lat2 = Math.atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, (1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)),
399
- lambda = Math.atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1),
400
- C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha)),
401
- L = lambda - (1 - C) * f * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM))),
477
+ lat2 = Math.atan2(
478
+ sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
479
+ (1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)
480
+ ),
481
+ lambda = Math.atan2(
482
+ sinSigma * sinAlpha1,
483
+ cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1
484
+ ),
485
+ C = (f / 16) * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha)),
486
+ L =
487
+ lambda -
488
+ (1 - C) *
489
+ f *
490
+ sinAlpha *
491
+ (sigma +
492
+ C *
493
+ sinSigma *
494
+ (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM))),
402
495
  revAz = Math.atan2(sinAlpha, -tmp); // final bearing
403
496
  return new LonLat(lon1 + L * math.DEGREES, lat2 * math.DEGREES);
404
497
  }
@@ -412,7 +505,6 @@ class Ellipsoid {
412
505
  * @returns {Vec3} -
413
506
  */
414
507
  hitRay(origin, direction) {
415
-
416
508
  var q = this._invRadii.mul(origin);
417
509
  var w = this._invRadii.mul(direction);
418
510
 
@@ -473,4 +565,4 @@ class Ellipsoid {
473
565
  }
474
566
  }
475
567
 
476
- export { Ellipsoid };
568
+ export { Ellipsoid };
@@ -2,12 +2,12 @@
2
2
  * @module og/ellipsoid/wgs84
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { Ellipsoid } from './Ellipsoid.js';
7
+ import { Ellipsoid } from "./Ellipsoid.js";
8
8
 
9
9
  /**
10
10
  * WGS84 ellipsoid object.
11
11
  * @type {Ellipsoid}
12
12
  */
13
- export const wgs84 = new Ellipsoid(6378137.000, 6356752.3142);
13
+ export const wgs84 = new Ellipsoid(6378137.0, 6356752.3142);
@@ -97,7 +97,16 @@ class BaseBillboard {
97
97
  * @protected
98
98
  * @type {number}
99
99
  */
100
- this._handlerIndex = -1;
100
+ this._handlerIndex = -1;
101
+
102
+ /**
103
+ * An indication that the object is ready to draw
104
+ * @protected
105
+ * @type {number}
106
+ */
107
+ this._isReady = false;
108
+
109
+ this._lockId = -1;
101
110
  }
102
111
 
103
112
  static get _staticCounter() {
@@ -123,8 +132,11 @@ class BaseBillboard {
123
132
  this._position.y = y;
124
133
  this._position.z = z;
125
134
  Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
126
- this._handler &&
127
- this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
135
+ if (this._isReady) {
136
+ this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
137
+ } else if (this._lockId !== -1) {
138
+ this._lockId = -2;
139
+ }
128
140
  }
129
141
 
130
142
  /**
@@ -137,8 +149,11 @@ class BaseBillboard {
137
149
  this._position.y = position.y;
138
150
  this._position.z = position.z;
139
151
  Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
140
- this._handler &&
141
- this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
152
+ if (this._isReady) {
153
+ this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
154
+ } else if (this._lockId !== -1) {
155
+ this._lockId = -2;
156
+ }
142
157
  }
143
158
 
144
159
  /**
@@ -161,7 +176,11 @@ class BaseBillboard {
161
176
  this._offset.x = x;
162
177
  this._offset.y = y;
163
178
  z != undefined && (this._offset.z = z);
164
- this._handler && this._handler.setOffsetArr(this._handlerIndex, this._offset);
179
+ if (this._isReady) {
180
+ this._handler.setOffsetArr(this._handlerIndex, this._offset);
181
+ } else if (this._lockId !== -1) {
182
+ this._lockId = -2;
183
+ }
165
184
  }
166
185
 
167
186
  /**
@@ -173,7 +192,11 @@ class BaseBillboard {
173
192
  this._offset.x = offset.x;
174
193
  this._offset.y = offset.y;
175
194
  offset.z != undefined && (this._offset.z = offset.z);
176
- this._handler && this._handler.setOffsetArr(this._handlerIndex, offset);
195
+ if (this._isReady) {
196
+ this._handler.setOffsetArr(this._handlerIndex, offset);
197
+ } else if (this._lockId !== -1) {
198
+ this._lockId = -2;
199
+ }
177
200
  }
178
201
 
179
202
  /**
@@ -192,7 +215,11 @@ class BaseBillboard {
192
215
  */
193
216
  setRotation(rotation) {
194
217
  this._rotation = rotation;
195
- this._handler && this._handler.setRotationArr(this._handlerIndex, rotation);
218
+ if (this._isReady) {
219
+ this._handler.setRotationArr(this._handlerIndex, rotation);
220
+ } else if (this._lockId !== -1) {
221
+ this._lockId = -2;
222
+ }
196
223
  }
197
224
 
198
225
  /**
@@ -227,7 +254,11 @@ class BaseBillboard {
227
254
  this._color.y = g;
228
255
  this._color.z = b;
229
256
  a != undefined && (this._color.w = a);
230
- this._handler && this._handler.setRgbaArr(this._handlerIndex, this._color);
257
+ if (this._isReady) {
258
+ this._handler.setRgbaArr(this._handlerIndex, this._color);
259
+ } else if (this._lockId !== -1) {
260
+ this._lockId = -2;
261
+ }
231
262
  }
232
263
 
233
264
  /**
@@ -240,7 +271,11 @@ class BaseBillboard {
240
271
  this._color.y = color.y;
241
272
  this._color.z = color.z;
242
273
  color.w != undefined && (this._color.w = color.w);
243
- this._handler && this._handler.setRgbaArr(this._handlerIndex, color);
274
+ if (this._isReady) {
275
+ this._handler.setRgbaArr(this._handlerIndex, color);
276
+ } else if (this._lockId !== -1) {
277
+ this._lockId = -2;
278
+ }
244
279
  }
245
280
 
246
281
  /**
@@ -268,7 +303,11 @@ class BaseBillboard {
268
303
  */
269
304
  setVisibility(visibility) {
270
305
  this._visibility = visibility;
271
- this._handler && this._handler.setVisibility(this._handlerIndex, visibility);
306
+ if (this._isReady) {
307
+ this._handler.setVisibility(this._handlerIndex, visibility);
308
+ } else if (this._lockId !== -1) {
309
+ this._lockId = -2;
310
+ }
272
311
  }
273
312
 
274
313
  /**
@@ -291,7 +330,11 @@ class BaseBillboard {
291
330
  this._alignedAxis.x = x;
292
331
  this._alignedAxis.y = y;
293
332
  this._alignedAxis.z = z;
294
- this._handler && this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis);
333
+ if (this._isReady) {
334
+ this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis);
335
+ } else if (this._lockId !== -1) {
336
+ this._lockId = -2;
337
+ }
295
338
  }
296
339
 
297
340
  /**
@@ -303,7 +346,11 @@ class BaseBillboard {
303
346
  this._alignedAxis.x = alignedAxis.x;
304
347
  this._alignedAxis.y = alignedAxis.y;
305
348
  this._alignedAxis.z = alignedAxis.z;
306
- this._handler && this._handler.setAlignedAxisArr(this._handlerIndex, alignedAxis);
349
+ if (this._isReady) {
350
+ this._handler.setAlignedAxisArr(this._handlerIndex, alignedAxis);
351
+ } else if (this._lockId !== -1) {
352
+ this._lockId = -2;
353
+ }
307
354
  }
308
355
 
309
356
  /**
@@ -330,7 +377,11 @@ class BaseBillboard {
330
377
  * @param {Vec3} color - Picking color.
331
378
  */
332
379
  setPickingColor3v(color) {
333
- this._handler && this._handler.setPickingColorArr(this._handlerIndex, color);
380
+ if (this._isReady) {
381
+ this._handler.setPickingColorArr(this._handlerIndex, color);
382
+ } else if (this._lockId !== -1) {
383
+ this._lockId = -2;
384
+ }
334
385
  }
335
386
  }
336
387
 
@@ -2,9 +2,9 @@
2
2
  * @module og/entity/Billboard
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { BaseBillboard } from './BaseBillboard.js';
7
+ import { BaseBillboard } from "./BaseBillboard.js";
8
8
 
9
9
  /**
10
10
  * Represents basic quad billboard image.
@@ -76,7 +76,10 @@ class Billboard extends BaseBillboard {
76
76
  ta.loadImage(src, function (img) {
77
77
  if (ta.nodes[img.__nodeIndex]) {
78
78
  that._image = img;
79
- bh.setTexCoordArr(that._handlerIndex, ta.nodes[that._image.__nodeIndex].texCoords);
79
+ bh.setTexCoordArr(
80
+ that._handlerIndex,
81
+ ta.nodes[that._image.__nodeIndex].texCoords
82
+ );
80
83
  } else {
81
84
  ta.addImage(img);
82
85
  ta.createTexture();
@@ -106,7 +109,8 @@ class Billboard extends BaseBillboard {
106
109
  setSize(width, height) {
107
110
  this._width = width;
108
111
  this._height = height;
109
- this._handler && this._handler.setSizeArr(this._handlerIndex, width * this._scale, height * this._scale);
112
+ this._handler &&
113
+ this._handler.setSizeArr(this._handlerIndex, width * this._scale, height * this._scale);
110
114
  }
111
115
 
112
116
  /**
@@ -158,4 +162,4 @@ class Billboard extends BaseBillboard {
158
162
  }
159
163
  }
160
164
 
161
- export { Billboard };
165
+ export { Billboard };