@pirireis/webglobeplugins 0.9.12 → 0.9.13

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 (177) hide show
  1. package/Math/angle-calculation.js +1 -3
  2. package/Math/arc.js +29 -32
  3. package/Math/bounds/line-bbox.js +1 -3
  4. package/Math/constants.js +1 -6
  5. package/Math/frustum/types.js +1 -2
  6. package/Math/juction/arc-plane.js +32 -35
  7. package/Math/juction/line-sphere.js +9 -12
  8. package/Math/juction/plane-plane.js +15 -18
  9. package/Math/line.js +30 -33
  10. package/Math/methods.js +6 -24
  11. package/Math/plane.js +22 -25
  12. package/Math/quaternion.js +6 -9
  13. package/Math/types.js +1 -2
  14. package/Math/utils.js +2 -4
  15. package/Math/vec3.js +5 -8
  16. package/algorithms/search-binary.js +1 -4
  17. package/altitude-locator/draw-subset-obj.js +1 -3
  18. package/altitude-locator/plugin.js +34 -37
  19. package/altitude-locator/types.js +1 -3
  20. package/arrowfield/adaptor.js +1 -4
  21. package/arrowfield/index.js +3 -10
  22. package/arrowfield/plugin.js +3 -6
  23. package/bearing-line/index.js +2 -8
  24. package/bearing-line/plugin.js +62 -66
  25. package/circle-line-chain/chain-list-map.js +1 -5
  26. package/circle-line-chain/plugin.js +46 -50
  27. package/circle-line-chain/util.js +1 -5
  28. package/compass-rose/compass-rose-padding-flat.js +12 -16
  29. package/compass-rose/compass-text-writer.js +3 -7
  30. package/compass-rose/index.js +3 -7
  31. package/compassrose/compassrose.js +6 -9
  32. package/compassrose/index.js +2 -8
  33. package/heatwave/index.js +3 -10
  34. package/heatwave/isobar/objectarraylabels.js +7 -9
  35. package/heatwave/isobar/plugin.js +14 -54
  36. package/heatwave/isobar/quadtreecontours.js +2 -4
  37. package/heatwave/plugins/heatwaveglobeshell.js +9 -12
  38. package/index.js +12 -58
  39. package/package.json +1 -1
  40. package/partialrings/buffer-manager.js +2 -8
  41. package/partialrings/index.js +2 -41
  42. package/partialrings/plugin.js +13 -20
  43. package/partialrings/program.js +23 -30
  44. package/pin/pin-object-array.js +8 -13
  45. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +3 -6
  46. package/point-heat-map/plugin-webworker.js +11 -14
  47. package/point-heat-map/point-to-heat-map-flow.js +9 -12
  48. package/point-tracks/key-methods.js +1 -4
  49. package/point-tracks/plugin.js +15 -19
  50. package/programs/arrowfield/index.js +2 -7
  51. package/programs/arrowfield/logic.js +7 -10
  52. package/programs/arrowfield/object.js +7 -13
  53. package/programs/data2legend/density-to-legend.js +6 -9
  54. package/programs/data2legend/point-to-density-texture.js +13 -16
  55. package/programs/float2legendwithratio/index.js +2 -8
  56. package/programs/float2legendwithratio/logic.js +3 -6
  57. package/programs/float2legendwithratio/object.js +5 -11
  58. package/programs/globe-util/is-globe-moved.js +3 -5
  59. package/programs/globeshell/index.js +2 -8
  60. package/programs/globeshell/wiggle/index.js +2 -8
  61. package/programs/globeshell/wiggle/logic.js +3 -6
  62. package/programs/globeshell/wiggle/object.js +5 -11
  63. package/programs/helpers/blender/program.js +3 -6
  64. package/programs/helpers/fadeaway/index.js +2 -7
  65. package/programs/helpers/fadeaway/logic.js +3 -6
  66. package/programs/helpers/fadeaway/object.js +5 -11
  67. package/programs/helpers/index.js +2 -8
  68. package/programs/index.js +9 -58
  69. package/programs/line-on-globe/angled-line.js +19 -22
  70. package/programs/line-on-globe/circle-accurate-3d.js +21 -24
  71. package/programs/line-on-globe/circle-accurate-flat.js +18 -24
  72. package/programs/line-on-globe/circle-accurate.js +27 -30
  73. package/programs/line-on-globe/circle.js +26 -29
  74. package/programs/line-on-globe/degree-padding-around-circle-3d.js +23 -26
  75. package/programs/line-on-globe/lines-color-instanced-flat.js +20 -24
  76. package/programs/line-on-globe/linestrip.js +28 -31
  77. package/programs/line-on-globe/naive-accurate-flexible.js +29 -32
  78. package/programs/line-on-globe/to-the-surface.js +15 -17
  79. package/programs/line-on-globe/util.js +1 -4
  80. package/programs/picking/pickable-renderer.js +25 -28
  81. package/programs/point-on-globe/element-globe-surface-glow.js +22 -25
  82. package/programs/point-on-globe/element-point-glow.js +26 -29
  83. package/programs/point-on-globe/square-pixel-point.js +13 -16
  84. package/programs/programcache.js +1 -6
  85. package/programs/rings/distancering/circleflatprogram.js +20 -56
  86. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +21 -58
  87. package/programs/rings/distancering/circlepaddysharedbuffer.js +1 -4
  88. package/programs/rings/distancering/index.js +5 -14
  89. package/programs/rings/distancering/paddyflatprogram.js +21 -57
  90. package/programs/rings/distancering/paddyflatprogram2d.js +21 -57
  91. package/programs/rings/distancering/paddyflatprogram3d.js +21 -57
  92. package/programs/rings/index.js +1 -17
  93. package/programs/rings/partial-ring/piece-of-pie.js +23 -25
  94. package/programs/totems/camerauniformblock.js +7 -11
  95. package/programs/totems/canvas-webglobe-info.js +6 -10
  96. package/programs/totems/gpu-selection-uniform-block.js +7 -11
  97. package/programs/totems/index.js +2 -40
  98. package/programs/two-d/pixel-padding-for-compass.js +10 -13
  99. package/programs/util.js +1 -3
  100. package/programs/vectorfields/index.js +3 -23
  101. package/programs/vectorfields/logics/drawrectangleparticles.js +9 -12
  102. package/programs/vectorfields/logics/index.js +4 -12
  103. package/programs/vectorfields/logics/pixelbased.js +10 -13
  104. package/programs/vectorfields/logics/ubo.js +1 -7
  105. package/programs/vectorfields/pingpongbuffermanager.js +1 -4
  106. package/rangerings/enum.js +2 -5
  107. package/rangerings/index.js +5 -15
  108. package/rangerings/plugin.js +61 -68
  109. package/rangerings/rangeringangletext.js +26 -29
  110. package/rangerings/ring-account.js +1 -6
  111. package/shaders/fragment-toy/firework.js +1 -4
  112. package/shaders/fragment-toy/singularity.js +1 -4
  113. package/timetracks/adaptors-line-strip.js +3 -9
  114. package/timetracks/adaptors.js +3 -8
  115. package/timetracks/index.js +5 -19
  116. package/timetracks/plugin-line-strip.js +6 -12
  117. package/timetracks/plugin.js +6 -12
  118. package/timetracks/program-line-strip.js +9 -12
  119. package/timetracks/program.js +10 -13
  120. package/timetracks/programpoint-line-strip.js +6 -9
  121. package/timetracks/programpoint.js +6 -9
  122. package/util/account/bufferoffsetmanager.js +1 -4
  123. package/util/account/index.js +3 -23
  124. package/util/account/single-attribute-buffer-management/buffer-manager.js +1 -5
  125. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +1 -5
  126. package/util/account/single-attribute-buffer-management/index.js +4 -9
  127. package/util/account/single-attribute-buffer-management/object-store.js +1 -5
  128. package/util/account/single-attribute-buffer-management/types.js +1 -2
  129. package/util/account/util.js +1 -5
  130. package/util/algorithms/search-binary.js +1 -4
  131. package/util/check/get.js +1 -5
  132. package/util/check/typecheck.js +7 -16
  133. package/util/geometry/index.js +1 -7
  134. package/util/gl-util/buffer/attribute-loader.js +2 -6
  135. package/util/gl-util/buffer/index.js +2 -5
  136. package/util/gl-util/draw-options/methods.js +2 -6
  137. package/util/gl-util/uniform-block/manager.js +2 -5
  138. package/util/heatwavedatamanager/datamanager.js +1 -4
  139. package/util/heatwavedatamanager/index.js +3 -10
  140. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +3 -9
  141. package/util/heatwavedatamanager/pointcoordsmeta.js +1 -4
  142. package/util/index.js +13 -57
  143. package/util/interpolation/timetrack/index.js +1 -4
  144. package/util/interpolation/timetrack/timetrack-interpolator.js +6 -10
  145. package/util/interpolation/timetrack/web-worker-str.js +1 -4
  146. package/util/interpolation/timetrack/web-worker.js +2 -4
  147. package/util/jshelpers/data-filler.js +1 -4
  148. package/util/jshelpers/equality.js +1 -3
  149. package/util/jshelpers/index.js +2 -37
  150. package/util/jshelpers/timefilters.js +1 -3
  151. package/util/picking/fence.js +1 -4
  152. package/util/picking/picker-displayer.js +6 -9
  153. package/util/programs/draw-texture-on-canvas.js +6 -9
  154. package/util/programs/index.js +1 -17
  155. package/util/programs/shapesonglobe.js +9 -13
  156. package/util/programs/supersampletotextures.js +3 -7
  157. package/util/programs/texturetoglobe.js +8 -11
  158. package/util/shaderfunctions/geometrytransformations.js +24 -31
  159. package/util/shaderfunctions/index.js +2 -18
  160. package/util/shaderfunctions/nodata.js +1 -4
  161. package/util/shaderfunctions/noisefunctions.js +1 -3
  162. package/util/webglobe/gldefaultstates.js +1 -4
  163. package/util/webglobe/index.js +2 -18
  164. package/util/webglobe/rasteroverlay.js +1 -4
  165. package/util/webglobjectbuilders.js +16 -34
  166. package/util/webglobjectbuilders1.js +16 -34
  167. package/waveparticles/adaptor.js +1 -3
  168. package/waveparticles/index.js +3 -10
  169. package/waveparticles/plugin.js +9 -12
  170. package/wind/imagetovectorfieldandmagnitude.js +1 -4
  171. package/wind/index.js +5 -14
  172. package/wind/plugin.js +6 -45
  173. package/wind/vectorfieldimage.js +1 -3
  174. package/write-text/attached-text-writer.js +6 -10
  175. package/write-text/context-text.js +4 -8
  176. package/write-text/context-text3.js +7 -11
  177. package/write-text/index.js +1 -5
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bearingRealAngle = bearingRealAngle;
4
1
  function bearingRealAngle(long, lat, endLong, endLat) {
5
2
  const rLong = Radians * long;
6
3
  const rLat = Radians * lat;
@@ -13,3 +10,4 @@ function bearingRealAngle(long, lat, endLong, endLat) {
13
10
  initialBearing = (initialBearing + 360) % 360;
14
11
  return initialBearing;
15
12
  }
13
+ export { bearingRealAngle };
package/Math/arc.js CHANGED
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.arc = void 0;
4
- const vec3_1 = require("./vec3");
5
- const constants_1 = require("./constants");
6
- const _0vector = /*@__PURE__*/ vec3_1.vec3.create(0, 0, 0);
7
- const _1vector = /*@__PURE__*/ vec3_1.vec3.create(1, 1, 1);
8
- exports.arc = Object.freeze({
1
+ import { vec3 } from "./vec3";
2
+ import { EPSILON } from "./constants";
3
+ const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
4
+ const _1vector = /*@__PURE__*/ vec3.create(1, 1, 1);
5
+ export const arc = Object.freeze({
9
6
  create(p0, p1) {
10
- const normal = vec3_1.vec3.create(0, 0, 0);
11
- vec3_1.vec3.cross(normal, p0, p1);
7
+ const normal = vec3.create(0, 0, 0);
8
+ vec3.cross(normal, p0, p1);
12
9
  const coverPlaneNormal = [p0[0] + p1[0], p0[1] + p1[1], p0[2] + p1[2]];
13
- vec3_1.vec3.normalize(coverPlaneNormal, coverPlaneNormal);
14
- const dot = vec3_1.vec3.dot(coverPlaneNormal, p0);
10
+ vec3.normalize(coverPlaneNormal, coverPlaneNormal);
11
+ const dot = vec3.dot(coverPlaneNormal, p0);
15
12
  return {
16
- p0: vec3_1.vec3.clone(p0),
17
- p1: vec3_1.vec3.clone(p1),
18
- normal: vec3_1.vec3.clone(normal),
13
+ p0: vec3.clone(p0),
14
+ p1: vec3.clone(p1),
15
+ normal: vec3.clone(normal),
19
16
  coverPlane: {
20
17
  normal: coverPlaneNormal,
21
18
  distance: dot
@@ -23,40 +20,40 @@ exports.arc = Object.freeze({
23
20
  };
24
21
  },
25
22
  set(out, p0, p1) {
26
- vec3_1.vec3.copy(out.p0, p0);
27
- vec3_1.vec3.copy(out.p1, p1);
28
- vec3_1.vec3.cross(out.normal, p0, p1);
23
+ vec3.copy(out.p0, p0);
24
+ vec3.copy(out.p1, p1);
25
+ vec3.cross(out.normal, p0, p1);
29
26
  const coverPlaneNormal = [p0[0] + p1[0], p0[1] + p1[1], p0[2] + p1[2]];
30
- vec3_1.vec3.normalize(coverPlaneNormal, coverPlaneNormal);
27
+ vec3.normalize(coverPlaneNormal, coverPlaneNormal);
31
28
  out.coverPlane.normal = coverPlaneNormal;
32
- out.coverPlane.distance = vec3_1.vec3.dot(coverPlaneNormal, p0);
29
+ out.coverPlane.distance = vec3.dot(coverPlaneNormal, p0);
33
30
  },
34
31
  copy(out, a) {
35
- vec3_1.vec3.copy(out.p0, a.p0);
36
- vec3_1.vec3.copy(out.p1, a.p1);
37
- vec3_1.vec3.copy(out.normal, a.normal);
38
- out.coverPlane.normal = vec3_1.vec3.clone(a.coverPlane.normal);
32
+ vec3.copy(out.p0, a.p0);
33
+ vec3.copy(out.p1, a.p1);
34
+ vec3.copy(out.normal, a.normal);
35
+ out.coverPlane.normal = vec3.clone(a.coverPlane.normal);
39
36
  out.coverPlane.distance = a.coverPlane.distance;
40
37
  },
41
38
  clone(a) {
42
39
  return {
43
- p0: vec3_1.vec3.clone(a.p0),
44
- p1: vec3_1.vec3.clone(a.p1),
45
- normal: vec3_1.vec3.clone(a.normal),
40
+ p0: vec3.clone(a.p0),
41
+ p1: vec3.clone(a.p1),
42
+ normal: vec3.clone(a.normal),
46
43
  coverPlane: {
47
- normal: vec3_1.vec3.clone(a.coverPlane.normal),
44
+ normal: vec3.clone(a.coverPlane.normal),
48
45
  distance: a.coverPlane.distance
49
46
  }
50
47
  };
51
48
  },
52
49
  isPointOn(arc, point) {
53
- const alignment = Math.abs(vec3_1.vec3.dot(point, arc.normal)) < constants_1.EPSILON;
54
- const distance = Math.abs(vec3_1.vec3.lengthSquared(point) - 1) < constants_1.EPSILON;
55
- const cover = vec3_1.vec3.dot(arc.coverPlane.normal, point) >= arc.coverPlane.distance;
50
+ const alignment = Math.abs(vec3.dot(point, arc.normal)) < EPSILON;
51
+ const distance = Math.abs(vec3.lengthSquared(point) - 1) < EPSILON;
52
+ const cover = vec3.dot(arc.coverPlane.normal, point) >= arc.coverPlane.distance;
56
53
  return alignment || distance || cover;
57
54
  },
58
55
  equals(a, b) {
59
- return vec3_1.vec3.equals(a.p0, b.p0) && vec3_1.vec3.equals(a.p1, b.p1);
56
+ return vec3.equals(a.p0, b.p0) && vec3.equals(a.p1, b.p1);
60
57
  },
61
58
  populatePoints(out, arc, count) {
62
59
  // rotate p0 around normal vector with a quaternion
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGreatCircleArcBBox = getGreatCircleArcBBox;
4
1
  function isClose(a, b, rtol = 1e-5, atol = 1e-8) {
5
2
  // JavaScript equivalent of NumPy's isclose
6
3
  return Math.abs(a - b) <= (atol + rtol * Math.abs(b));
@@ -110,6 +107,7 @@ function degreesToRadians(deg) {
110
107
  function radiansToDegrees(rad) {
111
108
  return rad * 180 / Math.PI;
112
109
  }
110
+ export { getGreatCircleArcBBox };
113
111
  // Test Case 1: London to Tokyo
114
112
  const lat1Deg = 51.5, lon1Deg = -0.1;
115
113
  const lat2Deg = 35.7, lon2Deg = 139.7;
package/Math/constants.js CHANGED
@@ -1,9 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EPSILON = exports.WORLD_RADIUS_MERCATOR = exports.WORLD_RADIUS_3D = void 0;
4
1
  const WORLD_RADIUS_3D = 6378.137;
5
- exports.WORLD_RADIUS_3D = WORLD_RADIUS_3D;
6
2
  const WORLD_RADIUS_MERCATOR = 6378136.99911;
7
- exports.WORLD_RADIUS_MERCATOR = WORLD_RADIUS_MERCATOR;
8
3
  const EPSILON = 1e-10; // Used for floating point comparisons
9
- exports.EPSILON = EPSILON;
4
+ export { WORLD_RADIUS_3D, WORLD_RADIUS_MERCATOR, EPSILON };
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.arcSlice = arcSlice;
4
- const constants_1 = require("../constants");
5
- const vec3_1 = require("../vec3");
6
- const line_1 = require("../line");
7
- const plane_1 = require("../plane");
8
- const arc_1 = require("../arc");
9
- const plane_plane_1 = require("./plane-plane");
10
- const line_sphere_1 = require("./line-sphere");
11
- const _intersectionLine = /*@__PURE__*/ line_1.line.create();
12
- const _originPlane = /*@__PURE__*/ plane_1.plane.create();
1
+ import { EPSILON } from "../constants";
2
+ import { vec3 } from "../vec3";
3
+ import { line } from "../line";
4
+ import { plane } from "../plane";
5
+ import { arc } from "../arc";
6
+ import { planePlaneJuction } from "./plane-plane";
7
+ import { lineSphereIntersection } from "./line-sphere";
8
+ const _intersectionLine = /*@__PURE__*/ line.create();
9
+ const _originPlane = /*@__PURE__*/ plane.create();
13
10
  _originPlane.distance = 0;
14
- const _originSphere = /*@__PURE__*/ { center: vec3_1.vec3.create(0, 0, 0), radius: 1 };
15
- const _intersectionPoints = /*@__PURE__*/ [vec3_1.vec3.create(), vec3_1.vec3.create()];
11
+ const _originSphere = /*@__PURE__*/ { center: vec3.create(0, 0, 0), radius: 1 };
12
+ const _intersectionPoints = /*@__PURE__*/ [vec3.create(), vec3.create()];
16
13
  // TODO: out must be [Arc, Arc] there is a case where split into three arcs, visible by points or arcs but middle is not visible
17
14
  /**
18
15
  *
@@ -21,24 +18,24 @@ const _intersectionPoints = /*@__PURE__*/ [vec3_1.vec3.create(), vec3_1.vec3.cre
21
18
  * @param juctionPlane
22
19
  * @returns number of arcs segments in the junction divided by the junction plane.
23
20
  */
24
- function arcSlice(out, inArc, juctionPlane) {
21
+ export function arcSlice(out, inArc, juctionPlane) {
25
22
  // arc coverPlane and junctionPlane intersection exist in the range of unit sphere
26
- const coverRadiusAngle = plane_1.plane.getUnitSphereRadiusAngle(inArc.coverPlane);
27
- const visibleRadiusAngle = plane_1.plane.getUnitSphereRadiusAngle(juctionPlane);
23
+ const coverRadiusAngle = plane.getUnitSphereRadiusAngle(inArc.coverPlane);
24
+ const visibleRadiusAngle = plane.getUnitSphereRadiusAngle(juctionPlane);
28
25
  // TODO: RESEARCH efficient approach --
29
- const angleBetween_Cover_Visible = Math.acos(vec3_1.vec3.dot(inArc.coverPlane.normal, juctionPlane.normal));
30
- if (coverRadiusAngle + visibleRadiusAngle < angleBetween_Cover_Visible - constants_1.EPSILON) { // case A: out of range
26
+ const angleBetween_Cover_Visible = Math.acos(vec3.dot(inArc.coverPlane.normal, juctionPlane.normal));
27
+ if (coverRadiusAngle + visibleRadiusAngle < angleBetween_Cover_Visible - EPSILON) { // case A: out of range
31
28
  return 0; // No intersection
32
29
  }
33
30
  // ------------------------------------
34
31
  // the case when the arc is completely covered by the juction plane
35
- if (visibleRadiusAngle + constants_1.EPSILON >= angleBetween_Cover_Visible + coverRadiusAngle) { // case B: fully visible
36
- arc_1.arc.copy(out[0], inArc);
32
+ if (visibleRadiusAngle + EPSILON >= angleBetween_Cover_Visible + coverRadiusAngle) { // case B: fully visible
33
+ arc.copy(out[0], inArc);
37
34
  return 1;
38
35
  }
39
36
  // plane-plane intersection line should be calculated for the rest of the calculations
40
- vec3_1.vec3.copy(_originPlane.normal, inArc.normal);
41
- const isPlaneJunctions = (0, plane_plane_1.planePlaneJuction)(_intersectionLine, _originPlane, juctionPlane);
37
+ vec3.copy(_originPlane.normal, inArc.normal);
38
+ const isPlaneJunctions = planePlaneJuction(_intersectionLine, _originPlane, juctionPlane);
42
39
  if (!isPlaneJunctions) { // case C: planes are parallel.
43
40
  // case A covers opposite directions
44
41
  // case B Covers they face each other
@@ -46,38 +43,38 @@ function arcSlice(out, inArc, juctionPlane) {
46
43
  }
47
44
  // --- read until here ---
48
45
  // calculate the intersection points
49
- const isSphereIntersection = (0, line_sphere_1.lineSphereIntersection)(_intersectionPoints, _intersectionLine, _originSphere);
46
+ const isSphereIntersection = lineSphereIntersection(_intersectionPoints, _intersectionLine, _originSphere);
50
47
  if (!isSphereIntersection) {
51
48
  // other edge caes should be covered by now
52
49
  return 0; // No intersection
53
50
  }
54
- const i0IsCovered = plane_1.plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[0]) > -constants_1.EPSILON;
55
- const i1IsCovered = plane_1.plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[1]) > -constants_1.EPSILON;
56
- const p0IsVisible = plane_1.plane.distanceToPoint(juctionPlane, inArc.p0) > -constants_1.EPSILON;
57
- const p1IsVisible = plane_1.plane.distanceToPoint(juctionPlane, inArc.p1) > -constants_1.EPSILON;
51
+ const i0IsCovered = plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[0]) > -EPSILON;
52
+ const i1IsCovered = plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[1]) > -EPSILON;
53
+ const p0IsVisible = plane.distanceToPoint(juctionPlane, inArc.p0) > -EPSILON;
54
+ const p1IsVisible = plane.distanceToPoint(juctionPlane, inArc.p1) > -EPSILON;
58
55
  if (!p0IsVisible && !p1IsVisible && !i0IsCovered && !i1IsCovered) {
59
56
  return 0; // No intersection
60
57
  }
61
58
  if (i0IsCovered && i1IsCovered && p0IsVisible && p1IsVisible) {
62
59
  // calculate which points are closer
63
- const p0i0DistanceSquared = vec3_1.vec3.distanceSquared(inArc.p0, _intersectionPoints[0]);
64
- const p0i1DistanceSquared = vec3_1.vec3.distanceSquared(inArc.p0, _intersectionPoints[1]);
60
+ const p0i0DistanceSquared = vec3.distanceSquared(inArc.p0, _intersectionPoints[0]);
61
+ const p0i1DistanceSquared = vec3.distanceSquared(inArc.p0, _intersectionPoints[1]);
65
62
  const case0 = p0i0DistanceSquared < p0i1DistanceSquared;
66
- arc_1.arc.set(out[0], inArc.p0, case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
67
- arc_1.arc.set(out[1], inArc.p1, !case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
63
+ arc.set(out[0], inArc.p0, case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
64
+ arc.set(out[1], inArc.p1, !case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
68
65
  return 2;
69
66
  }
70
67
  if (i0IsCovered && i1IsCovered) {
71
- arc_1.arc.set(out[0], _intersectionPoints[0], _intersectionPoints[1]);
68
+ arc.set(out[0], _intersectionPoints[0], _intersectionPoints[1]);
72
69
  return 1;
73
70
  }
74
71
  if (p0IsVisible && p1IsVisible) {
75
- arc_1.arc.copy(out[0], inArc);
72
+ arc.copy(out[0], inArc);
76
73
  return 1;
77
74
  }
78
75
  if ((p0IsVisible || p1IsVisible) !== (i0IsCovered || i1IsCovered)) {
79
76
  throw new Error("Unexpected case: one covered and one visible point must be present");
80
77
  }
81
- arc_1.arc.set(out[0], p0IsVisible ? inArc.p0 : inArc.p1, i0IsCovered ? _intersectionPoints[0] : _intersectionPoints[1]);
78
+ arc.set(out[0], p0IsVisible ? inArc.p0 : inArc.p1, i0IsCovered ? _intersectionPoints[0] : _intersectionPoints[1]);
82
79
  return 1;
83
80
  }
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lineSphereIntersection = lineSphereIntersection;
4
- const vec3_1 = require("../vec3");
5
- const line_1 = require("../line");
6
- const _0vector = /*@__PURE__*/ vec3_1.vec3.create(0, 0, 0);
7
- function lineSphereIntersection(out, inLine, inSphere) {
8
- vec3_1.vec3.subtract(_0vector, inLine.origin, inSphere.center);
9
- const distanceSquared = vec3_1.vec3.lengthSquared(_0vector);
1
+ import { vec3 } from "../vec3";
2
+ import { line } from "../line";
3
+ const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
4
+ export function lineSphereIntersection(out, inLine, inSphere) {
5
+ vec3.subtract(_0vector, inLine.origin, inSphere.center);
6
+ const distanceSquared = vec3.lengthSquared(_0vector);
10
7
  const radiusSquared = inSphere.radius * inSphere.radius;
11
- const dot = vec3_1.vec3.dot(_0vector, inLine.direction);
8
+ const dot = vec3.dot(_0vector, inLine.direction);
12
9
  const dotSquared = dot * dot;
13
10
  const _a = dotSquared + radiusSquared - distanceSquared;
14
11
  if (_a < 0) {
@@ -18,8 +15,8 @@ function lineSphereIntersection(out, inLine, inSphere) {
18
15
  const a = Math.sqrt(_a);
19
16
  const t1 = dot - a;
20
17
  const t2 = dot + a;
21
- line_1.line.at(out[0], inLine, t1);
22
- line_1.line.at(out[1], inLine, t2);
18
+ line.at(out[0], inLine, t1);
19
+ line.at(out[1], inLine, t2);
23
20
  return true;
24
21
  }
25
22
  }
@@ -1,23 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.planePlaneJuction = planePlaneJuction;
4
- const constants_1 = require("../constants");
5
- const vec3_1 = require("../vec3");
6
- const _normal1 = vec3_1.vec3.create();
7
- const _normal2 = vec3_1.vec3.create();
8
- function planePlaneJuction(out, plane1, plane2) {
9
- vec3_1.vec3.copy(_normal1, plane1.normal);
10
- vec3_1.vec3.copy(_normal2, plane2.normal);
1
+ import { EPSILON } from "../constants";
2
+ import { vec3 } from "../vec3";
3
+ const _normal1 = vec3.create();
4
+ const _normal2 = vec3.create();
5
+ export function planePlaneJuction(out, plane1, plane2) {
6
+ vec3.copy(_normal1, plane1.normal);
7
+ vec3.copy(_normal2, plane2.normal);
11
8
  const distance1 = plane1.distance;
12
9
  const distance2 = plane2.distance;
13
10
  const { origin, direction } = out;
14
- const dot = vec3_1.vec3.dot(_normal1, _normal2);
15
- if (Math.abs(dot) > 1 - constants_1.EPSILON) {
11
+ const dot = vec3.dot(_normal1, _normal2);
12
+ if (Math.abs(dot) > 1 - EPSILON) {
16
13
  return false; // Planes are parallel, no intersection
17
14
  }
18
- vec3_1.vec3.cross(direction, _normal1, _normal2);
19
- const magnitudeSquired = vec3_1.vec3.lengthSquared(out.direction);
20
- if (magnitudeSquired < constants_1.EPSILON) {
15
+ vec3.cross(direction, _normal1, _normal2);
16
+ const magnitudeSquired = vec3.lengthSquared(out.direction);
17
+ if (magnitudeSquired < EPSILON) {
21
18
  return false; // No valid intersection line
22
19
  }
23
20
  const magnitude = Math.sqrt(magnitudeSquired);
@@ -28,7 +25,7 @@ function planePlaneJuction(out, plane1, plane2) {
28
25
  // Calculate the intersection point
29
26
  // set z = 0
30
27
  determinant = _normal1[0] * _normal2[1] - _normal1[1] * _normal2[0];
31
- if (Math.abs(determinant) > constants_1.EPSILON) {
28
+ if (Math.abs(determinant) > EPSILON) {
32
29
  origin[0] = (distance1 * _normal2[1] - distance2 * _normal1[1]) / determinant;
33
30
  origin[1] = (distance2 * _normal1[0] - distance1 * _normal2[0]) / determinant;
34
31
  origin[2] = 0;
@@ -36,7 +33,7 @@ function planePlaneJuction(out, plane1, plane2) {
36
33
  else {
37
34
  // set y = 0
38
35
  determinant = _normal1[0] * _normal2[2] - _normal1[2] * _normal2[0];
39
- if (Math.abs(determinant) > constants_1.EPSILON) {
36
+ if (Math.abs(determinant) > EPSILON) {
40
37
  origin[0] = (distance1 * _normal2[2] - distance2 * _normal1[2]) / determinant;
41
38
  origin[1] = 0;
42
39
  origin[2] = (distance2 * _normal1[0] - distance1 * _normal2[0]) / determinant;
@@ -44,7 +41,7 @@ function planePlaneJuction(out, plane1, plane2) {
44
41
  else {
45
42
  // set x = 0
46
43
  determinant = _normal1[1] * _normal2[2] - _normal1[2] * _normal2[1];
47
- if (Math.abs(determinant) > constants_1.EPSILON) {
44
+ if (Math.abs(determinant) > EPSILON) {
48
45
  origin[0] = 0;
49
46
  origin[1] = (distance1 * _normal2[2] - distance2 * _normal1[2]) / determinant;
50
47
  origin[2] = (distance2 * _normal1[1] - distance1 * _normal2[1]) / determinant;
package/Math/line.js CHANGED
@@ -1,56 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.line = void 0;
4
- const constants_1 = require("./constants");
5
- const vec3_1 = require("./vec3");
6
- const _0vector = /*@__PURE__*/ vec3_1.vec3.create(0, 0, 0);
7
- exports.line = Object.freeze({
8
- create(origin = vec3_1.vec3.create(), direction = vec3_1.vec3.create()) {
9
- const direction_ = vec3_1.vec3.clone(direction);
10
- vec3_1.vec3.normalize(direction_, direction_);
1
+ import { EPSILON } from './constants';
2
+ import { vec3 } from './vec3';
3
+ const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
4
+ export const line = Object.freeze({
5
+ create(origin = vec3.create(), direction = vec3.create()) {
6
+ const direction_ = vec3.clone(direction);
7
+ vec3.normalize(direction_, direction_);
11
8
  return {
12
- origin: vec3_1.vec3.clone(origin),
9
+ origin: vec3.clone(origin),
13
10
  direction: direction_
14
11
  };
15
12
  },
16
13
  set(out, origin, direction) {
17
- vec3_1.vec3.copy(out.origin, origin);
18
- vec3_1.vec3.copy(out.direction, direction);
14
+ vec3.copy(out.origin, origin);
15
+ vec3.copy(out.direction, direction);
19
16
  },
20
17
  copy(out, a) {
21
- out.origin = vec3_1.vec3.copy(out.origin, a.origin);
22
- out.direction = vec3_1.vec3.copy(out.direction, a.direction);
18
+ out.origin = vec3.copy(out.origin, a.origin);
19
+ out.direction = vec3.copy(out.direction, a.direction);
23
20
  },
24
21
  clone(a) {
25
22
  return {
26
- origin: vec3_1.vec3.clone(a.origin),
27
- direction: vec3_1.vec3.clone(a.direction)
23
+ origin: vec3.clone(a.origin),
24
+ direction: vec3.clone(a.direction)
28
25
  };
29
26
  },
30
27
  fromTwoPoints(out, a, b) {
31
- vec3_1.vec3.subtract(out.direction, b, a);
32
- vec3_1.vec3.normalize(out.direction, out.direction);
33
- vec3_1.vec3.copy(out.origin, a);
28
+ vec3.subtract(out.direction, b, a);
29
+ vec3.normalize(out.direction, out.direction);
30
+ vec3.copy(out.origin, a);
34
31
  },
35
32
  at(out, line, distance) {
36
- vec3_1.vec3.multiplyScalar(_0vector, line.direction, distance);
37
- vec3_1.vec3.add(out, _0vector, line.origin);
33
+ vec3.multiplyScalar(_0vector, line.direction, distance);
34
+ vec3.add(out, _0vector, line.origin);
38
35
  },
39
36
  closestPoint(out, line, point) {
40
- vec3_1.vec3.subtract(_0vector, point, line.origin);
41
- const dot = vec3_1.vec3.dot(_0vector, line.direction);
42
- vec3_1.vec3.copy(out, line.direction);
43
- vec3_1.vec3.multiplyScalar(out, out, dot);
44
- vec3_1.vec3.add(out, out, line.origin);
37
+ vec3.subtract(_0vector, point, line.origin);
38
+ const dot = vec3.dot(_0vector, line.direction);
39
+ vec3.copy(out, line.direction);
40
+ vec3.multiplyScalar(out, out, dot);
41
+ vec3.add(out, out, line.origin);
45
42
  },
46
43
  contains(line, point) {
47
- vec3_1.vec3.subtract(_0vector, point, line.origin);
48
- vec3_1.vec3.cross(_0vector, _0vector, line.direction);
49
- return vec3_1.vec3.lengthSquared(_0vector) < constants_1.EPSILON;
44
+ vec3.subtract(_0vector, point, line.origin);
45
+ vec3.cross(_0vector, _0vector, line.direction);
46
+ return vec3.lengthSquared(_0vector) < EPSILON;
50
47
  },
51
48
  applyQuaternion(out, line, quaternion) {
52
- vec3_1.vec3.applyQuaternion(out.origin, line.origin, quaternion);
53
- vec3_1.vec3.applyQuaternion(out.direction, line.direction, quaternion);
54
- vec3_1.vec3.normalize(out.direction, out.direction);
49
+ vec3.applyQuaternion(out.origin, line.origin, quaternion);
50
+ vec3.applyQuaternion(out.direction, line.direction, quaternion);
51
+ vec3.normalize(out.direction, out.direction);
55
52
  }
56
53
  });
package/Math/methods.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.globe2Dcoordinates = exports.globe3Dcoordinates = exports.pixelXYLenghtToUnitVectorWithHeight = exports.wgs84ToMercator = exports.wgs84ToCartesian3d = exports.wgs84ToUnitVector = exports.sphericalLinearInterpolation_Cartesian3d = exports.sphericalLinearInterpolation_Mercator = exports.sphericalLinearInterpolation_UnitVector = exports.radianToCartesian3d = exports.radianToMercator = exports.cartesian3dToRadian = exports.length3 = exports.dot3 = exports.normalize3 = exports.RADIANS = void 0;
4
- const constants_1 = require("./constants");
1
+ import { WORLD_RADIUS_3D, WORLD_RADIUS_MERCATOR } from './constants';
5
2
  /**
6
3
  * @typedef {Array<number>} vec3 [x, y, z]
7
4
  * @typedef {Array<number>} vec2 [x, y]
@@ -13,7 +10,6 @@ const constants_1 = require("./constants");
13
10
  // **************** VECTOR OPERATIONS **********************
14
11
  // *********************************************************
15
12
  const RADIANS = Math.PI / 180;
16
- exports.RADIANS = RADIANS;
17
13
  /**
18
14
  * @param {vec3} a
19
15
  * @returns {vec3}
@@ -22,7 +18,6 @@ const normalize3 = (a) => {
22
18
  const len = length3(a);
23
19
  return [a[0] / len, a[1] / len, a[2] / len];
24
20
  };
25
- exports.normalize3 = normalize3;
26
21
  /**
27
22
  * @param {vec3} a
28
23
  * @param {vec3} b
@@ -31,7 +26,6 @@ exports.normalize3 = normalize3;
31
26
  const dot3 = (a, b) => {
32
27
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
33
28
  };
34
- exports.dot3 = dot3;
35
29
  /**
36
30
  * @param {vec3} a
37
31
  * @returns {number}
@@ -39,7 +33,6 @@ exports.dot3 = dot3;
39
33
  const length3 = (a) => {
40
34
  return Math.sqrt(dot3(a, a));
41
35
  };
42
- exports.length3 = length3;
43
36
  // *********************************************************
44
37
  // **************** TRANSFORMATIONS ************************
45
38
  // *********************************************************
@@ -56,15 +49,13 @@ const cartesian3dToRadian = (cartesian) => {
56
49
  const lat = Math.asin(z); // length);
57
50
  return [long, lat];
58
51
  };
59
- exports.cartesian3dToRadian = cartesian3dToRadian;
60
52
  /**
61
53
  * @param {vec2} xy long lat in radians
62
54
  * @returns {vec2} long lat in mercator meters
63
55
  */
64
56
  const radianToMercator = (xy) => {
65
- return [constants_1.WORLD_RADIUS_MERCATOR * xy[0], constants_1.WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + xy[1] / 2))];
57
+ return [WORLD_RADIUS_MERCATOR * xy[0], WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + xy[1] / 2))];
66
58
  };
67
- exports.radianToMercator = radianToMercator;
68
59
  /**
69
60
  * @param {vec2} xy long lat radians
70
61
  * @returns {vec3} cartesian
@@ -75,7 +66,6 @@ const radianToCartesian3d = (xy) => {
75
66
  const z = -Math.sin(xy[1]);
76
67
  return [x, y, z];
77
68
  };
78
- exports.radianToCartesian3d = radianToCartesian3d;
79
69
  // *********************************************************
80
70
  // ***************** INTERPOLATIONS ************************
81
71
  // *********************************************************
@@ -97,7 +87,6 @@ const sphericalLinearInterpolation_UnitVector = (normalizedA, normalizedB, ratio
97
87
  ];
98
88
  return result;
99
89
  };
100
- exports.sphericalLinearInterpolation_UnitVector = sphericalLinearInterpolation_UnitVector;
101
90
  /**
102
91
  * @param {vec3} normalizedA
103
92
  * @param {vec3} normalizedB
@@ -109,7 +98,6 @@ const sphericalLinearInterpolation_Mercator = (normalizedA, normalizedB, ratio)
109
98
  const angles = cartesian3dToRadian(unitVector);
110
99
  return radianToMercator(angles);
111
100
  };
112
- exports.sphericalLinearInterpolation_Mercator = sphericalLinearInterpolation_Mercator;
113
101
  /**
114
102
  * @param {vec4} a vec3 unit vector and length
115
103
  * @param {vec4} b vec3 unit vector and length
@@ -120,7 +108,6 @@ const sphericalLinearInterpolation_Cartesian3d = (a, b, ratio) => {
120
108
  const height = a[3] + (b[3] - a[3]) * ratio;
121
109
  return [unitVector[0] * height, unitVector[1] * height, unitVector[2] * height];
122
110
  };
123
- exports.sphericalLinearInterpolation_Cartesian3d = sphericalLinearInterpolation_Cartesian3d;
124
111
  /**
125
112
  *
126
113
  * @param {wgs84} coordinates
@@ -134,7 +121,6 @@ const wgs84ToUnitVector = (coordinates) => {
134
121
  const z = Math.sin(lat);
135
122
  return [x, y, z];
136
123
  };
137
- exports.wgs84ToUnitVector = wgs84ToUnitVector;
138
124
  /**
139
125
  * @param {number} long wgs84
140
126
  * @param {number} lat wgs84
@@ -147,19 +133,17 @@ const wgs84ToCartesian3d = (long, lat, height) => {
147
133
  const x = Math.cos(latRad) * Math.cos(longRad);
148
134
  const y = Math.cos(latRad) * Math.sin(longRad);
149
135
  const z = Math.sin(latRad);
150
- const radius = constants_1.WORLD_RADIUS_3D + height;
136
+ const radius = WORLD_RADIUS_3D + height;
151
137
  return [x * radius, y * radius, z * radius];
152
138
  };
153
- exports.wgs84ToCartesian3d = wgs84ToCartesian3d;
154
139
  /**
155
140
  * @param {number} long
156
141
  * @param {number} lat
157
142
  * @returns {vec2} mercator
158
143
  */
159
144
  const wgs84ToMercator = (long, lat) => {
160
- return [constants_1.WORLD_RADIUS_MERCATOR * long * RADIANS, constants_1.WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + lat * RADIANS / 2))];
145
+ return [WORLD_RADIUS_MERCATOR * long * RADIANS, WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + lat * RADIANS / 2))];
161
146
  };
162
- exports.wgs84ToMercator = wgs84ToMercator;
163
147
  /**
164
148
  * @param {vec2} pixelXY
165
149
  * @returns {vec2} long lat in radians
@@ -171,10 +155,9 @@ const pixelXYToRadians = (pixelXY) => {
171
155
  };
172
156
  const pixelXYLenghtToUnitVectorWithHeight = (pixelXYHeight) => {
173
157
  const [long, lat] = pixelXYToRadians(pixelXYHeight);
174
- const radius = constants_1.WORLD_RADIUS_3D + pixelXYHeight[2];
158
+ const radius = WORLD_RADIUS_3D + pixelXYHeight[2];
175
159
  return radianToCartesian3d([long, lat]).concat(radius);
176
160
  };
177
- exports.pixelXYLenghtToUnitVectorWithHeight = pixelXYLenghtToUnitVectorWithHeight;
178
161
  const globe3Dcoordinates = (globe, height = 0) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
179
162
  const len = longlats.length / 2;
180
163
  const result = new Float32Array(len * 3 + paddingCount * 3).fill(paddingValue);
@@ -186,7 +169,6 @@ const globe3Dcoordinates = (globe, height = 0) => (longlats, { paddingCount = 0,
186
169
  }
187
170
  return result;
188
171
  };
189
- exports.globe3Dcoordinates = globe3Dcoordinates;
190
172
  const globe2Dcoordinates = (globe) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
191
173
  const len = longlats.length / 2;
192
174
  const result = new Float32Array(len * 2 + paddingCount * 2).fill(paddingValue);
@@ -198,4 +180,4 @@ const globe2Dcoordinates = (globe) => (longlats, { paddingCount = 0, paddingValu
198
180
  }
199
181
  return result;
200
182
  };
201
- exports.globe2Dcoordinates = globe2Dcoordinates;
183
+ export { RADIANS, normalize3, dot3, length3, cartesian3dToRadian, radianToMercator, radianToCartesian3d, sphericalLinearInterpolation_UnitVector, sphericalLinearInterpolation_Mercator, sphericalLinearInterpolation_Cartesian3d, wgs84ToUnitVector, wgs84ToCartesian3d, wgs84ToMercator, pixelXYLenghtToUnitVectorWithHeight, globe3Dcoordinates, globe2Dcoordinates, };