@openglobus/og 0.22.1 → 0.23.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 (168) hide show
  1. package/css/og.css +137 -1
  2. package/lib/@openglobus/js/Object3d.d.ts +20 -10
  3. package/lib/@openglobus/js/camera/Camera.d.ts +9 -0
  4. package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
  5. package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
  6. package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
  7. package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  8. package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  9. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  10. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  11. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  12. package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  13. package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  14. package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  15. package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
  16. package/lib/@openglobus/js/control/index.d.ts +2 -0
  17. package/lib/@openglobus/js/entity/Entity.d.ts +278 -19
  18. package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
  19. package/lib/@openglobus/js/entity/GeoObject.d.ts +141 -36
  20. package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
  21. package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
  22. package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
  23. package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
  24. package/lib/@openglobus/js/index.d.ts +2 -1
  25. package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
  26. package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
  27. package/lib/@openglobus/js/math/Quat.d.ts +46 -33
  28. package/lib/@openglobus/js/math/Ray.d.ts +10 -4
  29. package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
  30. package/lib/@openglobus/js/math.d.ts +2 -2
  31. package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
  32. package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
  33. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  34. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  35. package/lib/@openglobus/js/renderer/Renderer.d.ts +64 -44
  36. package/lib/@openglobus/js/renderer/RendererEvents.d.ts +1 -0
  37. package/lib/@openglobus/js/scene/Planet.d.ts +11 -7
  38. package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
  39. package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
  40. package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
  41. package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
  42. package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
  43. package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
  44. package/lib/@openglobus/js/ui/Input.d.ts +32 -0
  45. package/lib/@openglobus/js/ui/View.d.ts +3 -1
  46. package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
  47. package/lib/@openglobus/js/utils/shared.d.ts +22 -0
  48. package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
  49. package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
  50. package/lib/@openglobus/js/webgl/Handler.d.ts +3 -0
  51. package/lib/@openglobus/og.css +1 -1
  52. package/lib/@openglobus/og.esm.js +1 -1
  53. package/lib/@openglobus/og.esm.js.map +1 -1
  54. package/lib/@openglobus/og.umd.js +1 -1
  55. package/lib/@openglobus/og.umd.js.map +1 -1
  56. package/lib/js/Globe.js +2 -1
  57. package/lib/js/Object3d.d.ts +20 -10
  58. package/lib/js/Object3d.js +124 -48
  59. package/lib/js/camera/Camera.d.ts +9 -0
  60. package/lib/js/camera/Camera.js +27 -1
  61. package/lib/js/camera/Frustum.d.ts +3 -0
  62. package/lib/js/camera/Frustum.js +7 -0
  63. package/lib/js/control/Atmosphere.js +10 -6
  64. package/lib/js/control/CameraLock.d.ts +38 -0
  65. package/lib/js/control/CameraLock.js +216 -0
  66. package/lib/js/control/Control.js +1 -1
  67. package/lib/js/control/DebugInfo.js +13 -3
  68. package/lib/js/control/KeyboardNavigation.js +1 -1
  69. package/lib/js/control/ScaleControl.js +9 -3
  70. package/lib/js/control/SimpleNavigation.d.ts +27 -10
  71. package/lib/js/control/SimpleNavigation.js +148 -49
  72. package/lib/js/control/Sun.js +1 -1
  73. package/lib/js/control/elevationProfile/ElevationProfileScene.js +4 -4
  74. package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  75. package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
  76. package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  77. package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
  78. package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  79. package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
  80. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  81. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +502 -0
  82. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  83. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
  84. package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  85. package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +106 -0
  86. package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  87. package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +34 -0
  88. package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  89. package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
  90. package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
  91. package/lib/js/control/geoObjectEditor/colors.js +8 -0
  92. package/lib/js/control/index.d.ts +2 -0
  93. package/lib/js/control/index.js +2 -0
  94. package/lib/js/control/timeline/TimelineControl.js +2 -0
  95. package/lib/js/entity/Entity.d.ts +278 -19
  96. package/lib/js/entity/Entity.js +483 -63
  97. package/lib/js/entity/EntityCollection.d.ts +8 -9
  98. package/lib/js/entity/EntityCollection.js +48 -45
  99. package/lib/js/entity/GeoObject.d.ts +141 -36
  100. package/lib/js/entity/GeoObject.js +153 -90
  101. package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
  102. package/lib/js/entity/GeoObjectHandler.js +198 -295
  103. package/lib/js/entity/InstanceData.d.ts +76 -0
  104. package/lib/js/entity/InstanceData.js +344 -0
  105. package/lib/js/entity/Polyline.d.ts +19 -6
  106. package/lib/js/entity/Polyline.js +76 -36
  107. package/lib/js/entity/PolylineHandler.d.ts +7 -0
  108. package/lib/js/entity/PolylineHandler.js +26 -1
  109. package/lib/js/index.d.ts +2 -1
  110. package/lib/js/index.js +2 -1
  111. package/lib/js/layer/Bing.js +2 -2
  112. package/lib/js/layer/Vector.d.ts +4 -0
  113. package/lib/js/layer/Vector.js +16 -0
  114. package/lib/js/light/LightSource.d.ts +1 -139
  115. package/lib/js/light/LightSource.js +21 -227
  116. package/lib/js/math/Quat.d.ts +46 -33
  117. package/lib/js/math/Quat.js +91 -90
  118. package/lib/js/math/Ray.d.ts +10 -4
  119. package/lib/js/math/Ray.js +20 -4
  120. package/lib/js/math/Vec3.d.ts +15 -0
  121. package/lib/js/math/Vec3.js +30 -1
  122. package/lib/js/math.d.ts +2 -2
  123. package/lib/js/math.js +3 -3
  124. package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
  125. package/lib/js/quadTree/EntityCollectionNode.js +8 -8
  126. package/lib/js/quadTree/Node.d.ts +1 -1
  127. package/lib/js/quadTree/Node.js +2 -2
  128. package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
  129. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  130. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
  131. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  132. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
  133. package/lib/js/renderer/Renderer.d.ts +64 -44
  134. package/lib/js/renderer/Renderer.js +264 -263
  135. package/lib/js/renderer/RendererEvents.d.ts +1 -0
  136. package/lib/js/renderer/RendererEvents.js +2 -1
  137. package/lib/js/scene/Planet.d.ts +11 -7
  138. package/lib/js/scene/Planet.js +109 -87
  139. package/lib/js/scene/RenderNode.d.ts +10 -25
  140. package/lib/js/scene/RenderNode.js +70 -58
  141. package/lib/js/shaders/depth.js +2 -5
  142. package/lib/js/shaders/drawnode.d.ts +1 -0
  143. package/lib/js/shaders/drawnode.js +51 -52
  144. package/lib/js/shaders/geoObject.d.ts +1 -0
  145. package/lib/js/shaders/geoObject.js +154 -91
  146. package/lib/js/shaders/polyline.js +68 -51
  147. package/lib/js/shaders/utils.d.ts +1 -1
  148. package/lib/js/shaders/utils.js +11 -0
  149. package/lib/js/ui/Checkbox.d.ts +31 -0
  150. package/lib/js/ui/Checkbox.js +110 -0
  151. package/lib/js/ui/Color.js +2 -1
  152. package/lib/js/ui/Dialog.d.ts +3 -0
  153. package/lib/js/ui/Dialog.js +20 -0
  154. package/lib/js/ui/Input.d.ts +32 -0
  155. package/lib/js/ui/Input.js +107 -0
  156. package/lib/js/ui/View.d.ts +3 -1
  157. package/lib/js/ui/View.js +6 -0
  158. package/lib/js/utils/objParser.d.ts +44 -12
  159. package/lib/js/utils/objParser.js +241 -149
  160. package/lib/js/utils/shared.d.ts +22 -0
  161. package/lib/js/utils/shared.js +34 -0
  162. package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
  163. package/lib/js/webgl/Framebuffer.d.ts +35 -8
  164. package/lib/js/webgl/Framebuffer.js +136 -29
  165. package/lib/js/webgl/Handler.d.ts +3 -0
  166. package/lib/js/webgl/Handler.js +11 -1
  167. package/lib/js/webgl/Program.js +0 -8
  168. package/package.json +4 -2
@@ -2,6 +2,7 @@ import * as math from "../math";
2
2
  import { Vec3 } from "./Vec3";
3
3
  import { Mat4 } from "./Mat4";
4
4
  import { Mat3 } from "./Mat3";
5
+ import { PI_TWO } from "../math";
5
6
  /**
6
7
  * A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.
7
8
  * @constructor
@@ -166,10 +167,10 @@ export class Quat {
166
167
  let rotAxis = source.cross(dest).normalize();
167
168
  return Quat.axisAngleToQuat(rotAxis, rotAngle);
168
169
  }
169
- static setFromEulerAngles(pitch, yaw, roll) {
170
- let res = new Quat();
171
- return res.setFromEulerAngles(pitch, yaw, roll);
172
- }
170
+ // static setFromEulerAngles(pitch: number, yaw: number, roll: number): Quat {
171
+ // let res = new Quat();
172
+ // return res.setFromEulerAngles(pitch, yaw, roll);
173
+ // }
173
174
  /**
174
175
  * Returns true if the components are zero.
175
176
  * @public
@@ -178,6 +179,14 @@ export class Quat {
178
179
  isZero() {
179
180
  return this.x === 0.0 && this.y === 0.0 && this.z === 0.0 && this.w === 0.0;
180
181
  }
182
+ /**
183
+ * Returns true if a component is NaN.
184
+ * @public
185
+ * @returns {boolean} -
186
+ */
187
+ isNaN() {
188
+ return isNaN(this.x) || isNaN(this.y) || isNaN(this.z) || isNaN(this.w);
189
+ }
181
190
  /**
182
191
  * Clear Quat. Sets zeroes.
183
192
  * @public
@@ -245,6 +254,15 @@ export class Quat {
245
254
  add(q) {
246
255
  return new Quat(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w);
247
256
  }
257
+ /**
258
+ * Computes the componentwise sum of two Quats.
259
+ * @public
260
+ * @param {Quat} q - Quat to add.
261
+ * @returns {Quat} -
262
+ */
263
+ addRes(q, res) {
264
+ return res.set(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w);
265
+ }
248
266
  /**
249
267
  * Computes the componentwise difference of two Quats.
250
268
  * @public
@@ -284,26 +302,8 @@ export class Quat {
284
302
  toVec() {
285
303
  return [this.x, this.y, this.z, this.w];
286
304
  }
287
- /**
288
- * Sets current quaternion by spherical coordinates.
289
- * @public
290
- * @param {number} lat - Latitude.
291
- * @param {number} lon - Longitude.
292
- * @param {number} angle - Angle in radians.
293
- * @returns {Quat} -
294
- */
295
- setFromSphericalCoords(lat, lon, angle) {
296
- let sin_a = Math.sin(angle / 2);
297
- let cos_a = Math.cos(angle / 2);
298
- let sin_lat = Math.sin(lat);
299
- let cos_lat = Math.cos(lat);
300
- let sin_long = Math.sin(lon);
301
- let cos_long = Math.cos(lon);
302
- this.x = sin_a * cos_lat * sin_long;
303
- this.y = sin_a * sin_lat;
304
- this.z = sin_a * sin_lat * cos_long;
305
- this.w = cos_a;
306
- return this;
305
+ get xyz() {
306
+ return new Vec3(this.x, this.y, this.z);
307
307
  }
308
308
  /**
309
309
  * Sets rotation with the given heading and up vectors.
@@ -347,12 +347,33 @@ export class Quat {
347
347
  }
348
348
  return this;
349
349
  }
350
+ /**
351
+ * Sets current quaternion by spherical coordinates.
352
+ * @public
353
+ * @param {number} lat - Latitude.
354
+ * @param {number} lon - Longitude.
355
+ * @param {number} angle - Angle in radians.
356
+ * @returns {Quat} -
357
+ */
358
+ setFromSphericalCoords(lat, lon, angle) {
359
+ let sin_a = Math.sin(angle / 2);
360
+ let cos_a = Math.cos(angle / 2);
361
+ let sin_lat = Math.sin(lat);
362
+ let cos_lat = Math.cos(lat);
363
+ let sin_long = Math.sin(lon);
364
+ let cos_long = Math.cos(lon);
365
+ this.x = sin_a * cos_lat * sin_long;
366
+ this.y = sin_a * sin_lat;
367
+ this.z = sin_a * sin_lat * cos_long;
368
+ this.w = cos_a;
369
+ return this;
370
+ }
350
371
  /**
351
372
  * Gets spherical coordinates.
352
373
  * @public
353
374
  * @returns {Object} Returns object with latitude, longitude and alpha.
354
375
  */
355
- toSphericalCoords() {
376
+ getSphericalCoords() {
356
377
  let cos_a = this.w;
357
378
  let sin_a = Math.sqrt(1.0 - cos_a * cos_a);
358
379
  // var angle = Math.acos(cos_a) * 2;
@@ -395,7 +416,7 @@ export class Quat {
395
416
  /**
396
417
  * Returns axis and angle of the current Quat.
397
418
  * @public
398
- * @returns {Object} -
419
+ * @returns { axis: Vec3, angle: number } -
399
420
  */
400
421
  getAxisAngle() {
401
422
  let x = this.x, y = this.y, z = this.z, w = this.w;
@@ -420,6 +441,24 @@ export class Quat {
420
441
  angle: angle
421
442
  };
422
443
  }
444
+ getPitch() {
445
+ let sinPitch = -2 * (this.y * this.z - this.w * this.x);
446
+ return Math.abs(sinPitch) >= 1
447
+ ? Math.sign(sinPitch) * PI_TWO
448
+ : Math.asin(sinPitch);
449
+ }
450
+ getYaw() {
451
+ return -Math.atan2(2 * (this.x * this.z + this.w * this.y), 1 - 2 * (this.y * this.y + this.x * this.x));
452
+ }
453
+ getRoll() {
454
+ return Math.atan2(2 * (this.x * this.y + this.w * this.z), 1 - 2 * (this.z * this.z + this.x * this.x));
455
+ }
456
+ setPitchYawRoll(pitchRad, yawRad, rollRad, frame = Quat.IDENTITY) {
457
+ let qp = Quat.xRotation(-pitchRad);
458
+ let qy = Quat.yRotation(yawRad);
459
+ let qr = Quat.zRotation(-rollRad);
460
+ return this.copy(qr.mul(qp).mul(qy).mul(frame).conjugate());
461
+ }
423
462
  /**
424
463
  * Sets current Quat by Euler's angles.
425
464
  * @public
@@ -574,6 +613,21 @@ export class Quat {
574
613
  d = -b * d - f * e - h * g;
575
614
  return new Vec3(i * a + d * -b + j * -h - k * -f, j * a + d * -f + k * -b - i * -h, k * a + d * -h + i * -f - j * -b);
576
615
  }
616
+ /**
617
+ * Returns quaternion and vector production.
618
+ * @public
619
+ * @param {Vec3} v - 3d Vector.
620
+ * @returns {Vec3} -
621
+ */
622
+ mulVec3Res(v, res) {
623
+ // t = 2 * cross(q.xyz, v)
624
+ // v' = v + q.w * t + cross(q.xyz, t)
625
+ let d = v.x, e = v.y, g = v.z;
626
+ let b = this.x, f = this.y, h = this.z, a = this.w;
627
+ let i = a * d + f * g - h * e, j = a * e + h * d - b * g, k = a * g + b * e - f * d;
628
+ d = -b * d - f * e - h * g;
629
+ return res.set(i * a + d * -b + j * -h - k * -f, j * a + d * -f + k * -b - i * -h, k * a + d * -h + i * -f - j * -b);
630
+ }
577
631
  /**
578
632
  * Computes the product of two Quats.
579
633
  * @public
@@ -585,6 +639,17 @@ export class Quat {
585
639
  let f = q.x, h = q.y, i = q.z, b = q.w;
586
640
  return new Quat(d * b + a * f + e * i - g * h, e * b + a * h + g * f - d * i, g * b + a * i + d * h - e * f, a * b - d * f - e * h - g * i);
587
641
  }
642
+ /**
643
+ * Computes the product of two Quats.
644
+ * @public
645
+ * @param {Quat} q - Quat to multiply.
646
+ * @returns {Quat} -
647
+ */
648
+ mulRes(q, res) {
649
+ let d = this.x, e = this.y, g = this.z, a = this.w;
650
+ let f = q.x, h = q.y, i = q.z, b = q.w;
651
+ return res.set(d * b + a * f + e * i - g * h, e * b + a * h + g * f - d * i, g * b + a * i + d * h - e * f, a * b - d * f - e * h - g * i);
652
+ }
588
653
  /**
589
654
  * Computes the product of two Quats.
590
655
  * @public
@@ -708,70 +773,6 @@ export class Quat {
708
773
  }
709
774
  return new Quat(scale0 * ax + scale1 * bx, scale0 * ay + scale1 * by, scale0 * az + scale1 * bz, scale0 * aw + scale1 * bw);
710
775
  }
711
- /**
712
- * Returns a roll angle in radians.
713
- * @public
714
- * @param {Boolean} [reprojectAxis] -
715
- * @returns {Number} -
716
- */
717
- getRoll(reprojectAxis = false) {
718
- let x = this.x, y = this.y, z = this.z, w = this.w;
719
- if (reprojectAxis) {
720
- let fTy = 2.0 * y;
721
- let fTz = 2.0 * z;
722
- let fTwz = fTz * w;
723
- let fTxy = fTy * x;
724
- let fTyy = fTy * y;
725
- let fTzz = fTz * z;
726
- return Math.atan2(fTxy + fTwz, 1.0 - (fTyy + fTzz));
727
- }
728
- else {
729
- return Math.atan2(2 * (x * y + w * z), w * w + x * x - y * y - z * z);
730
- }
731
- }
732
- /**
733
- * Returns a pitch angle in radians.
734
- * @public
735
- * @param {Boolean} [reprojectAxis] -
736
- * @returns {number} -
737
- */
738
- getPitch(reprojectAxis = false) {
739
- let x = this.x, y = this.y, z = this.z, w = this.w;
740
- if (reprojectAxis) {
741
- let fTx = 2.0 * x;
742
- let fTz = 2.0 * z;
743
- let fTwx = fTx * w;
744
- let fTxx = fTx * x;
745
- let fTyz = fTz * y;
746
- let fTzz = fTz * z;
747
- return Math.atan2(fTyz + fTwx, 1.0 - (fTxx + fTzz));
748
- }
749
- else {
750
- return Math.atan2(2 * (y * z + w * x), w * w - x * x - y * y + z * z);
751
- }
752
- }
753
- /**
754
- * Returns a yaw angle in radians.
755
- * @public
756
- * @param {Boolean} [reprojectAxis] -
757
- * @returns {number} -
758
- */
759
- getYaw(reprojectAxis = false) {
760
- let x = this.x, y = this.y, z = this.z, w = this.w;
761
- if (reprojectAxis) {
762
- let fTx = 2.0 * x;
763
- let fTy = 2.0 * y;
764
- let fTz = 2.0 * z;
765
- let fTwy = fTy * w;
766
- let fTxx = fTx * x;
767
- let fTxz = fTz * x;
768
- let fTyy = fTy * y;
769
- return Math.atan2(fTxz + fTwy, 1.0 - (fTxx + fTyy));
770
- }
771
- else {
772
- return Math.asin(-2 * (x * z - w * y));
773
- }
774
- }
775
776
  }
776
777
  /**
777
778
  * Creates Quat instance.
@@ -1,6 +1,7 @@
1
1
  import { Box } from "../bv/Box";
2
2
  import { Sphere } from "../bv/Sphere";
3
3
  import { Vec3 } from "./Vec3";
4
+ import { Plane } from "./Plane";
4
5
  /**
5
6
  * Represents a ray that extends infinitely from the provided origin in the provided direction.
6
7
  * @class
@@ -38,10 +39,9 @@ export declare class Ray {
38
39
  */
39
40
  set(origin: Vec3, direction: Vec3): Ray;
40
41
  /**
41
- * Computes the point along the ray on the distance.
42
- * @public
43
- * @param {number} distance - Point distance.
44
- * @returns {Vec3}
42
+ * Get a point on the ray at a given distance `t`.
43
+ * @param {number} distance - Distance from the origin along the ray.
44
+ * @returns {Vec3} The point at distance `t`.
45
45
  */
46
46
  getPoint(distance: number): Vec3;
47
47
  /**
@@ -73,4 +73,10 @@ export declare class Ray {
73
73
  */
74
74
  hitSphere(sphere: Sphere): Vec3 | null;
75
75
  hitBox(box: Box): void;
76
+ /**
77
+ * Finds the intersection of the ray with a plane.
78
+ * @param {Plane} plane - The plane to intersect with.
79
+ * @returns {Vec3 | null} The intersection point or null if no intersection.
80
+ */
81
+ hitPlane2(plane: Plane, res: Vec3): number;
76
82
  }
@@ -40,10 +40,9 @@ export class Ray {
40
40
  return this;
41
41
  }
42
42
  /**
43
- * Computes the point along the ray on the distance.
44
- * @public
45
- * @param {number} distance - Point distance.
46
- * @returns {Vec3}
43
+ * Get a point on the ray at a given distance `t`.
44
+ * @param {number} distance - Distance from the origin along the ray.
45
+ * @returns {Vec3} The point at distance `t`.
47
46
  */
48
47
  getPoint(distance) {
49
48
  return Vec3.add(this.origin, this.direction.scaleTo(distance));
@@ -185,4 +184,21 @@ export class Ray {
185
184
  // TODO
186
185
  //
187
186
  }
187
+ /**
188
+ * Finds the intersection of the ray with a plane.
189
+ * @param {Plane} plane - The plane to intersect with.
190
+ * @returns {Vec3 | null} The intersection point or null if no intersection.
191
+ */
192
+ hitPlane2(plane, res) {
193
+ const d = this.direction.dot(plane.n);
194
+ if (Math.abs(d) < EPS10) {
195
+ return Ray.OUTSIDE;
196
+ }
197
+ const t = plane.p.sub(this.origin).dot(plane.n) / d;
198
+ if (t < 0) {
199
+ return Ray.AWAY;
200
+ }
201
+ res.copy(this.getPoint(t));
202
+ return Ray.INSIDE;
203
+ }
188
204
  }
@@ -241,6 +241,13 @@ export declare class Vec3 {
241
241
  * @returns {Vec3} Returns a sum vector.
242
242
  */
243
243
  add(p: Vec3): Vec3;
244
+ /**
245
+ * Gets two vectors summarization.
246
+ * @public
247
+ * @param {Vec3} p - Vector to add.
248
+ * @returns {Vec3} Returns a sum vector.
249
+ */
250
+ addRes(p: Vec3, res: Vec3): Vec3;
244
251
  /**
245
252
  * Subtract vector from the current.
246
253
  * @public
@@ -283,6 +290,13 @@ export declare class Vec3 {
283
290
  * @returns {Vec3} -
284
291
  */
285
292
  mul(vec: Vec3): Vec3;
293
+ /**
294
+ * Multiply current vector object to another and returns new vector instance.
295
+ * @public
296
+ * @param {Vec3} vec - Multiply vector.
297
+ * @returns {Vec3} -
298
+ */
299
+ mulRes(vec: Vec3, res: Vec3): Vec3;
286
300
  /**
287
301
  * Divide current vector's components to another. Results stores in the current vector object.
288
302
  * @public
@@ -452,6 +466,7 @@ export declare class Vec3 {
452
466
  * @returns {Vec3} -
453
467
  */
454
468
  slerp(v2: Vec3, t: number): Vec3;
469
+ mulVecA(a: Vec3): Vec3;
455
470
  /**
456
471
  * Gets the shortest arc quaternion to rotate this vector to the destination vector.
457
472
  * @param {Vec3} dest -
@@ -155,7 +155,12 @@ export class Vec3 {
155
155
  * @returns {number} -
156
156
  */
157
157
  static angle(a, b) {
158
- return Math.acos(a.dot(b) / Math.sqrt(a.length2() * b.length2()));
158
+ // the same
159
+ // let d = a.dot(b) / Math.sqrt(a.length2() * b.length2());
160
+ // return Math.acos(Math.max(-1, Math.min(1, d)));
161
+ let dotProduct = a.dot(b);
162
+ let crossProduct = a.cross(b).length();
163
+ return Math.atan2(crossProduct, dotProduct);
159
164
  }
160
165
  /**
161
166
  * Returns two vectors linear interpolation.
@@ -389,6 +394,15 @@ export class Vec3 {
389
394
  add(p) {
390
395
  return new Vec3(this.x + p.x, this.y + p.y, this.z + p.z);
391
396
  }
397
+ /**
398
+ * Gets two vectors summarization.
399
+ * @public
400
+ * @param {Vec3} p - Vector to add.
401
+ * @returns {Vec3} Returns a sum vector.
402
+ */
403
+ addRes(p, res) {
404
+ return res.set(this.x + p.x, this.y + p.y, this.z + p.z);
405
+ }
392
406
  /**
393
407
  * Subtract vector from the current.
394
408
  * @public
@@ -452,6 +466,15 @@ export class Vec3 {
452
466
  mul(vec) {
453
467
  return new Vec3(this.x * vec.x, this.y * vec.y, this.z * vec.z);
454
468
  }
469
+ /**
470
+ * Multiply current vector object to another and returns new vector instance.
471
+ * @public
472
+ * @param {Vec3} vec - Multiply vector.
473
+ * @returns {Vec3} -
474
+ */
475
+ mulRes(vec, res) {
476
+ return res.set(this.x * vec.x, this.y * vec.y, this.z * vec.z);
477
+ }
455
478
  /**
456
479
  * Divide current vector's components to another. Results stores in the current vector object.
457
480
  * @public
@@ -741,6 +764,12 @@ export class Vec3 {
741
764
  }
742
765
  return Vec3.add(this.scaleTo(scale0), v2.scale(scale1));
743
766
  }
767
+ mulVecA(a) {
768
+ this.x *= a.x;
769
+ this.y *= a.y;
770
+ this.z *= a.z;
771
+ return this;
772
+ }
744
773
  /**
745
774
  * Gets the shortest arc quaternion to rotate this vector to the destination vector.
746
775
  * @param {Vec3} dest -
package/lib/js/math.d.ts CHANGED
@@ -70,7 +70,7 @@ export declare function log(n: number, base: number): number;
70
70
  /**
71
71
  * Clamp the number.
72
72
  * @function
73
- * @param {number} number - Input number.
73
+ * @param {number} value - Input number.
74
74
  * @param {number} min - Minimal edge.
75
75
  * @param {number} max - Maximal edge.
76
76
  * @returns {number} -
@@ -78,7 +78,7 @@ export declare function log(n: number, base: number): number;
78
78
  * clamp(12, 1, 5)
79
79
  * //returns 5
80
80
  */
81
- export declare function clamp(number: number, min: number, max: number): number;
81
+ export declare function clamp(value: number, min: number, max: number): number;
82
82
  /**
83
83
  * Converts degrees value to radians.
84
84
  * @function
package/lib/js/math.js CHANGED
@@ -71,7 +71,7 @@ export function log(n, base) {
71
71
  /**
72
72
  * Clamp the number.
73
73
  * @function
74
- * @param {number} number - Input number.
74
+ * @param {number} value - Input number.
75
75
  * @param {number} min - Minimal edge.
76
76
  * @param {number} max - Maximal edge.
77
77
  * @returns {number} -
@@ -79,8 +79,8 @@ export function log(n, base) {
79
79
  * clamp(12, 1, 5)
80
80
  * //returns 5
81
81
  */
82
- export function clamp(number, min, max) {
83
- return Math.max(min, Math.min(number, max));
82
+ export function clamp(value, min, max) {
83
+ return Math.max(min, Math.min(value, max));
84
84
  }
85
85
  /**
86
86
  * Converts degrees value to radians.
@@ -16,7 +16,7 @@ declare class EntityCollectionNode {
16
16
  layer: Vector;
17
17
  strategy: EntityCollectionsTreeStrategy;
18
18
  parentNode: EntityCollectionNode | null;
19
- childrenNodes: EntityCollectionNode[];
19
+ childNodes: EntityCollectionNode[];
20
20
  partId: number;
21
21
  nodeId: number;
22
22
  state: number | null;
@@ -34,7 +34,7 @@ declare class EntityCollectionNode {
34
34
  __setLonLat__(entity: Entity): LonLat;
35
35
  buildTree(entities: Entity[], rightNow?: boolean): void;
36
36
  isInside(entity: Entity): boolean;
37
- createChildrenNodes(): void;
37
+ createChildNodes(): void;
38
38
  collectRenderCollectionsPASS1(visibleNodes: NodesDict, outArr: EntityCollection[]): void;
39
39
  collectRenderCollectionsPASS2(visibleNodes: NodesDict, outArr: EntityCollection[], renderingNodeId: number): void;
40
40
  applyCollection(): void;
@@ -13,7 +13,7 @@ class EntityCollectionNode {
13
13
  this.strategy = strategy;
14
14
  this.layer = strategy._layer;
15
15
  this.parentNode = parent;
16
- this.childrenNodes = [];
16
+ this.childNodes = [];
17
17
  this.partId = partId;
18
18
  //this.nodeId = partId + id;
19
19
  this.nodeId = partId + (parent ? parent.nodeId * 4 + 1 : 0);
@@ -78,9 +78,9 @@ class EntityCollectionNode {
78
78
  buildTree(entities, rightNow = false) {
79
79
  this.count += entities.length;
80
80
  if (entities.length > this.layer._nodeCapacity) {
81
- const cn = this.childrenNodes;
81
+ const cn = this.childNodes;
82
82
  if (!cn.length) {
83
- this.createChildrenNodes();
83
+ this.createChildNodes();
84
84
  }
85
85
  let en_nw = [], en_ne = [], en_sw = [], en_se = [];
86
86
  let i = entities.length;
@@ -120,7 +120,7 @@ class EntityCollectionNode {
120
120
  return false;
121
121
  }
122
122
  }
123
- createChildrenNodes() {
123
+ createChildNodes() {
124
124
  const s = this.strategy;
125
125
  const ext = this.extent;
126
126
  const size_x = ext.getWidth() * 0.5;
@@ -128,7 +128,7 @@ class EntityCollectionNode {
128
128
  const ne = ext.northEast;
129
129
  const sw = ext.southWest;
130
130
  const c = new LonLat(sw.lon + size_x, sw.lat + size_y);
131
- const nd = this.childrenNodes;
131
+ const nd = this.childNodes;
132
132
  const p = this.layer._planet;
133
133
  const z = this.zoom + 1;
134
134
  nd[NW] = new EntityCollectionNode(s, NW, this, new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
@@ -139,7 +139,7 @@ class EntityCollectionNode {
139
139
  collectRenderCollectionsPASS1(visibleNodes, outArr) {
140
140
  const n = visibleNodes[this.nodeId];
141
141
  if (n) {
142
- const cn = this.childrenNodes;
142
+ const cn = this.childNodes;
143
143
  if (this.entityCollection) {
144
144
  this.renderCollection(outArr, visibleNodes);
145
145
  }
@@ -162,7 +162,7 @@ class EntityCollectionNode {
162
162
  const altVis = (cam.eye.distance(this.bsphere.center) - this.bsphere.radius <
163
163
  VISIBLE_DISTANCE * Math.sqrt(cam._lonLat.height)) || cam._lonLat.height > 10000;
164
164
  if (this.count > 0 && altVis && cam.containsSphere(this.bsphere)) {
165
- const cn = this.childrenNodes;
165
+ const cn = this.childNodes;
166
166
  if (this.entityCollection) {
167
167
  this.renderCollection(outArr, visibleNodes, renderingNodeId);
168
168
  }
@@ -181,7 +181,7 @@ class EntityCollectionNode {
181
181
  this._inTheQueue = false;
182
182
  }
183
183
  traverseTree(callback) {
184
- const cn = this.childrenNodes;
184
+ const cn = this.childNodes;
185
185
  if (this.entityCollection) {
186
186
  callback(this);
187
187
  }
@@ -33,7 +33,7 @@ declare class Node {
33
33
  inFrustum: number;
34
34
  _fadingNodes: Node[];
35
35
  constructor(SegmentPrototype: typeof Segment, planet: Planet, partId: number, parent: Node | null, tileZoom: number, extent: Extent);
36
- createChildrenNodes(): void;
36
+ createChildNodes(): void;
37
37
  createBounds(): void;
38
38
  getState(): number | null;
39
39
  /**
@@ -53,7 +53,7 @@ class Node {
53
53
  this._fadingNodes = [];
54
54
  this.createBounds();
55
55
  }
56
- createChildrenNodes() {
56
+ createChildNodes() {
57
57
  this.ready = true;
58
58
  const p = this.planet;
59
59
  const ps = this.segment;
@@ -137,7 +137,7 @@ class Node {
137
137
  // }
138
138
  traverseNodes(cam, maxZoom, terrainReadySegment, stopLoading, zoomPassNode) {
139
139
  if (!this.ready) {
140
- this.createChildrenNodes();
140
+ this.createChildNodes();
141
141
  }
142
142
  let n = this.nodes;
143
143
  n[0].renderTree(cam, maxZoom, terrainReadySegment, stopLoading, zoomPassNode);
@@ -40,7 +40,7 @@ export class QuadTreeStrategy {
40
40
  preRender() {
41
41
  for (let i = 0; i < this._quadTreeList.length; i++) {
42
42
  let quadTree = this._quadTreeList[i];
43
- quadTree.createChildrenNodes();
43
+ quadTree.createChildNodes();
44
44
  quadTree.segment.createPlainSegment();
45
45
  for (let j = 0; j < quadTree.nodes.length; j++) {
46
46
  quadTree.nodes[j].segment.createPlainSegment();
@@ -9,7 +9,7 @@ export declare class EarthEntityCollectionNodeLonLat extends EntityCollectionNod
9
9
  isNorth: boolean;
10
10
  strategy: EarthEntityCollectionsTreeStrategy;
11
11
  constructor(strategy: EarthEntityCollectionsTreeStrategy, partId: number, parent: EarthEntityCollectionNodeLonLat | null, extent: Extent, planet: Planet, zoom: number);
12
- createChildrenNodes(): void;
12
+ createChildNodes(): void;
13
13
  protected _setExtentBounds(): void;
14
14
  __setLonLat__(entity: Entity): LonLat;
15
15
  isVisible(): boolean;
@@ -8,7 +8,7 @@ export class EarthEntityCollectionNodeLonLat extends EntityCollectionNode {
8
8
  this.strategy = strategy;
9
9
  this.isNorth = false;
10
10
  }
11
- createChildrenNodes() {
11
+ createChildNodes() {
12
12
  const s = this.strategy;
13
13
  const ext = this.extent;
14
14
  const size_x = ext.getWidth() * 0.5;
@@ -16,7 +16,7 @@ export class EarthEntityCollectionNodeLonLat extends EntityCollectionNode {
16
16
  const ne = ext.northEast;
17
17
  const sw = ext.southWest;
18
18
  const c = new LonLat(sw.lon + size_x, sw.lat + size_y);
19
- const nd = this.childrenNodes;
19
+ const nd = this.childNodes;
20
20
  const p = this.layer._planet;
21
21
  const z = this.zoom + 1;
22
22
  nd[NW] = new EarthEntityCollectionNodeLonLat(s, NW, this, new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);
@@ -8,7 +8,7 @@ import { EquiEntityCollectionsTreeStrategy } from "./EquiEntityCollectionsTreeSt
8
8
  export declare class EquiEntityCollectionNodeLonLat extends EntityCollectionNode {
9
9
  strategy: EquiEntityCollectionsTreeStrategy;
10
10
  constructor(strategy: EquiEntityCollectionsTreeStrategy, partId: number, parent: EquiEntityCollectionNodeLonLat | null, extent: Extent, planet: Planet, zoom: number);
11
- createChildrenNodes(): void;
11
+ createChildNodes(): void;
12
12
  protected _setExtentBounds(): void;
13
13
  __setLonLat__(entity: Entity): LonLat;
14
14
  isVisible(): boolean;
@@ -7,7 +7,7 @@ export class EquiEntityCollectionNodeLonLat extends EntityCollectionNode {
7
7
  super(strategy, partId, parent, extent, planet, zoom);
8
8
  this.strategy = strategy;
9
9
  }
10
- createChildrenNodes() {
10
+ createChildNodes() {
11
11
  const s = this.strategy;
12
12
  const ext = this.extent;
13
13
  const size_x = ext.getWidth() * 0.5;
@@ -15,7 +15,7 @@ export class EquiEntityCollectionNodeLonLat extends EntityCollectionNode {
15
15
  const ne = ext.northEast;
16
16
  const sw = ext.southWest;
17
17
  const c = new LonLat(sw.lon + size_x, sw.lat + size_y);
18
- const nd = this.childrenNodes;
18
+ const nd = this.childNodes;
19
19
  const p = this.layer._planet;
20
20
  const z = this.zoom + 1;
21
21
  nd[NW] = new EquiEntityCollectionNodeLonLat(s, NW, this, new Extent(new LonLat(sw.lon, sw.lat + size_y), new LonLat(sw.lon + size_x, ne.lat)), p, z);