@pirireis/webglobeplugins 0.9.11 → 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 (179) hide show
  1. package/Math/angle-calculation.js +9 -11
  2. package/Math/arc.js +38 -41
  3. package/Math/bounds/line-bbox.js +79 -83
  4. package/Math/constants.js +4 -9
  5. package/Math/frustum/types.js +1 -2
  6. package/Math/juction/arc-plane.js +33 -36
  7. package/Math/juction/line-sphere.js +15 -18
  8. package/Math/juction/plane-plane.js +20 -23
  9. package/Math/line.js +42 -47
  10. package/Math/methods.js +69 -92
  11. package/Math/plane.js +33 -38
  12. package/Math/quaternion.js +48 -55
  13. package/Math/types.js +1 -2
  14. package/Math/utils.js +2 -4
  15. package/Math/vec3.js +46 -52
  16. package/algorithms/search-binary.js +5 -8
  17. package/altitude-locator/draw-subset-obj.js +8 -11
  18. package/altitude-locator/plugin.js +114 -133
  19. package/altitude-locator/types.js +1 -3
  20. package/arrowfield/adaptor.js +3 -7
  21. package/arrowfield/index.js +3 -10
  22. package/arrowfield/plugin.js +63 -69
  23. package/bearing-line/index.js +2 -8
  24. package/bearing-line/plugin.js +218 -248
  25. package/circle-line-chain/chain-list-map.js +82 -92
  26. package/circle-line-chain/plugin.js +147 -182
  27. package/circle-line-chain/util.js +1 -5
  28. package/compass-rose/compass-rose-padding-flat.js +111 -140
  29. package/compass-rose/compass-text-writer.js +63 -75
  30. package/compass-rose/index.js +3 -7
  31. package/compassrose/compassrose.js +50 -57
  32. package/compassrose/index.js +2 -8
  33. package/heatwave/index.js +3 -10
  34. package/heatwave/isobar/objectarraylabels.js +50 -56
  35. package/heatwave/isobar/plugin.js +111 -170
  36. package/heatwave/isobar/quadtreecontours.js +78 -96
  37. package/heatwave/plugins/heatwaveglobeshell.js +73 -94
  38. package/index.js +12 -58
  39. package/package.json +1 -1
  40. package/partialrings/buffer-manager.js +32 -70
  41. package/partialrings/index.js +2 -41
  42. package/partialrings/plugin.js +55 -98
  43. package/partialrings/program.js +141 -59
  44. package/pin/pin-object-array.js +89 -97
  45. package/pin/pin-point-totem.js +21 -22
  46. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
  47. package/point-heat-map/plugin-webworker.js +45 -53
  48. package/point-heat-map/point-to-heat-map-flow.js +46 -51
  49. package/point-tracks/key-methods.js +2 -5
  50. package/point-tracks/plugin.js +141 -170
  51. package/programs/arrowfield/index.js +2 -7
  52. package/programs/arrowfield/logic.js +172 -67
  53. package/programs/arrowfield/object.js +35 -43
  54. package/programs/data2legend/density-to-legend.js +47 -26
  55. package/programs/data2legend/point-to-density-texture.js +56 -34
  56. package/programs/float2legendwithratio/index.js +2 -8
  57. package/programs/float2legendwithratio/logic.js +88 -45
  58. package/programs/float2legendwithratio/object.js +45 -54
  59. package/programs/globe-util/is-globe-moved.js +10 -13
  60. package/programs/globeshell/index.js +2 -8
  61. package/programs/globeshell/wiggle/index.js +2 -8
  62. package/programs/globeshell/wiggle/logic.js +191 -101
  63. package/programs/globeshell/wiggle/object.js +35 -43
  64. package/programs/helpers/blender/program.js +36 -22
  65. package/programs/helpers/fadeaway/index.js +2 -7
  66. package/programs/helpers/fadeaway/logic.js +36 -17
  67. package/programs/helpers/fadeaway/object.js +11 -18
  68. package/programs/helpers/index.js +2 -8
  69. package/programs/index.js +9 -58
  70. package/programs/line-on-globe/angled-line.js +95 -39
  71. package/programs/line-on-globe/circle-accurate-3d.js +86 -39
  72. package/programs/line-on-globe/circle-accurate-flat.js +116 -64
  73. package/programs/line-on-globe/circle-accurate.js +113 -46
  74. package/programs/line-on-globe/circle.js +106 -44
  75. package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
  76. package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
  77. package/programs/line-on-globe/linestrip.js +126 -63
  78. package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
  79. package/programs/line-on-globe/to-the-surface.js +62 -35
  80. package/programs/line-on-globe/util.js +2 -5
  81. package/programs/picking/pickable-renderer.js +127 -46
  82. package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
  83. package/programs/point-on-globe/element-point-glow.js +112 -47
  84. package/programs/point-on-globe/square-pixel-point.js +80 -34
  85. package/programs/programcache.js +14 -19
  86. package/programs/rings/distancering/circleflatprogram.js +76 -70
  87. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
  88. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
  89. package/programs/rings/distancering/index.js +5 -14
  90. package/programs/rings/distancering/paddyflatprogram.js +87 -70
  91. package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
  92. package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
  93. package/programs/rings/index.js +1 -17
  94. package/programs/rings/partial-ring/piece-of-pie.js +144 -44
  95. package/programs/totems/camerauniformblock.js +65 -56
  96. package/programs/totems/canvas-webglobe-info.js +49 -45
  97. package/programs/totems/gpu-selection-uniform-block.js +45 -45
  98. package/programs/totems/index.js +2 -40
  99. package/programs/two-d/pixel-padding-for-compass.js +94 -36
  100. package/programs/util.js +7 -10
  101. package/programs/vectorfields/index.js +3 -23
  102. package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
  103. package/programs/vectorfields/logics/index.js +4 -12
  104. package/programs/vectorfields/logics/pixelbased.js +94 -41
  105. package/programs/vectorfields/logics/ubo.js +32 -32
  106. package/programs/vectorfields/pingpongbuffermanager.js +30 -37
  107. package/rangerings/enum.js +2 -5
  108. package/rangerings/index.js +5 -15
  109. package/rangerings/plugin.js +223 -286
  110. package/rangerings/rangeringangletext.js +122 -137
  111. package/rangerings/ring-account.js +53 -75
  112. package/shaders/fragment-toy/firework.js +55 -4
  113. package/shaders/fragment-toy/singularity.js +56 -5
  114. package/timetracks/adaptors-line-strip.js +27 -44
  115. package/timetracks/adaptors.js +48 -67
  116. package/timetracks/index.js +5 -19
  117. package/timetracks/plugin-line-strip.js +65 -79
  118. package/timetracks/plugin.js +71 -85
  119. package/timetracks/program-line-strip.js +297 -107
  120. package/timetracks/program.js +421 -118
  121. package/timetracks/programpoint-line-strip.js +98 -48
  122. package/timetracks/programpoint.js +91 -48
  123. package/util/account/bufferoffsetmanager.js +72 -98
  124. package/util/account/index.js +3 -23
  125. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
  126. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
  127. package/util/account/single-attribute-buffer-management/index.js +4 -9
  128. package/util/account/single-attribute-buffer-management/object-store.js +29 -34
  129. package/util/account/single-attribute-buffer-management/types.js +1 -2
  130. package/util/account/util.js +2 -8
  131. package/util/algorithms/search-binary.js +5 -8
  132. package/util/check/get.js +5 -9
  133. package/util/check/typecheck.js +13 -24
  134. package/util/geometry/index.js +10 -18
  135. package/util/gl-util/buffer/attribute-loader.js +10 -26
  136. package/util/gl-util/buffer/index.js +2 -5
  137. package/util/gl-util/draw-options/methods.js +10 -15
  138. package/util/gl-util/uniform-block/manager.js +69 -72
  139. package/util/heatwavedatamanager/datamanager.js +56 -119
  140. package/util/heatwavedatamanager/index.js +3 -10
  141. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
  142. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
  143. package/util/index.js +13 -57
  144. package/util/interpolation/timetrack/index.js +2 -5
  145. package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
  146. package/util/interpolation/timetrack/web-worker-str.js +180 -5
  147. package/util/interpolation/timetrack/web-worker.js +4 -6
  148. package/util/jshelpers/data-filler.js +8 -11
  149. package/util/jshelpers/equality.js +1 -3
  150. package/util/jshelpers/index.js +2 -37
  151. package/util/jshelpers/timefilters.js +8 -10
  152. package/util/picking/fence.js +8 -11
  153. package/util/picking/picker-displayer.js +49 -58
  154. package/util/programs/draw-texture-on-canvas.js +41 -26
  155. package/util/programs/index.js +1 -17
  156. package/util/programs/shapesonglobe.js +104 -68
  157. package/util/programs/supersampletotextures.js +45 -43
  158. package/util/programs/texturetoglobe.js +99 -52
  159. package/util/shaderfunctions/geometrytransformations.js +323 -35
  160. package/util/shaderfunctions/index.js +2 -18
  161. package/util/shaderfunctions/nodata.js +8 -5
  162. package/util/shaderfunctions/noisefunctions.js +40 -12
  163. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  164. package/util/webglobe/gldefaultstates.js +1 -4
  165. package/util/webglobe/index.js +2 -18
  166. package/util/webglobe/rasteroverlay.js +36 -41
  167. package/util/webglobjectbuilders.js +70 -93
  168. package/util/webglobjectbuilders1.js +63 -82
  169. package/waveparticles/adaptor.js +7 -10
  170. package/waveparticles/index.js +3 -10
  171. package/waveparticles/plugin.js +82 -90
  172. package/wind/imagetovectorfieldandmagnitude.js +16 -19
  173. package/wind/index.js +5 -14
  174. package/wind/plugin.js +454 -291
  175. package/wind/vectorfieldimage.js +6 -8
  176. package/write-text/attached-text-writer.js +48 -54
  177. package/write-text/context-text.js +52 -63
  178. package/write-text/context-text3.js +71 -80
  179. package/write-text/index.js +1 -5
package/Math/line.js CHANGED
@@ -1,58 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.line = void 0;
4
- var constants_1 = require("./constants");
5
- var vec3_1 = require("./vec3");
6
- var _0vector = /*@__PURE__*/ vec3_1.vec3.create(0, 0, 0);
7
- exports.line = Object.freeze({
8
- create: function (origin, direction) {
9
- if (origin === void 0) { origin = vec3_1.vec3.create(); }
10
- if (direction === void 0) { direction = vec3_1.vec3.create(); }
11
- var direction_ = vec3_1.vec3.clone(direction);
12
- 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_);
13
8
  return {
14
- origin: vec3_1.vec3.clone(origin),
9
+ origin: vec3.clone(origin),
15
10
  direction: direction_
16
11
  };
17
12
  },
18
- set: function (out, origin, direction) {
19
- vec3_1.vec3.copy(out.origin, origin);
20
- vec3_1.vec3.copy(out.direction, direction);
13
+ set(out, origin, direction) {
14
+ vec3.copy(out.origin, origin);
15
+ vec3.copy(out.direction, direction);
21
16
  },
22
- copy: function (out, a) {
23
- out.origin = vec3_1.vec3.copy(out.origin, a.origin);
24
- out.direction = vec3_1.vec3.copy(out.direction, a.direction);
17
+ copy(out, a) {
18
+ out.origin = vec3.copy(out.origin, a.origin);
19
+ out.direction = vec3.copy(out.direction, a.direction);
25
20
  },
26
- clone: function (a) {
21
+ clone(a) {
27
22
  return {
28
- origin: vec3_1.vec3.clone(a.origin),
29
- direction: vec3_1.vec3.clone(a.direction)
23
+ origin: vec3.clone(a.origin),
24
+ direction: vec3.clone(a.direction)
30
25
  };
31
26
  },
32
- fromTwoPoints: function (out, a, b) {
33
- vec3_1.vec3.subtract(out.direction, b, a);
34
- vec3_1.vec3.normalize(out.direction, out.direction);
35
- vec3_1.vec3.copy(out.origin, a);
36
- },
37
- at: function (out, line, distance) {
38
- vec3_1.vec3.multiplyScalar(_0vector, line.direction, distance);
39
- vec3_1.vec3.add(out, _0vector, line.origin);
40
- },
41
- closestPoint: function (out, line, point) {
42
- vec3_1.vec3.subtract(_0vector, point, line.origin);
43
- var dot = vec3_1.vec3.dot(_0vector, line.direction);
44
- vec3_1.vec3.copy(out, line.direction);
45
- vec3_1.vec3.multiplyScalar(out, out, dot);
46
- vec3_1.vec3.add(out, out, line.origin);
47
- },
48
- contains: function (line, point) {
49
- vec3_1.vec3.subtract(_0vector, point, line.origin);
50
- vec3_1.vec3.cross(_0vector, _0vector, line.direction);
51
- return vec3_1.vec3.lengthSquared(_0vector) < constants_1.EPSILON;
52
- },
53
- applyQuaternion: function (out, line, quaternion) {
54
- vec3_1.vec3.applyQuaternion(out.origin, line.origin, quaternion);
55
- vec3_1.vec3.applyQuaternion(out.direction, line.direction, quaternion);
56
- vec3_1.vec3.normalize(out.direction, out.direction);
27
+ fromTwoPoints(out, a, b) {
28
+ vec3.subtract(out.direction, b, a);
29
+ vec3.normalize(out.direction, out.direction);
30
+ vec3.copy(out.origin, a);
31
+ },
32
+ at(out, line, distance) {
33
+ vec3.multiplyScalar(_0vector, line.direction, distance);
34
+ vec3.add(out, _0vector, line.origin);
35
+ },
36
+ closestPoint(out, line, point) {
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);
42
+ },
43
+ contains(line, point) {
44
+ vec3.subtract(_0vector, point, line.origin);
45
+ vec3.cross(_0vector, _0vector, line.direction);
46
+ return vec3.lengthSquared(_0vector) < EPSILON;
47
+ },
48
+ applyQuaternion(out, line, quaternion) {
49
+ vec3.applyQuaternion(out.origin, line.origin, quaternion);
50
+ vec3.applyQuaternion(out.direction, line.direction, quaternion);
51
+ vec3.normalize(out.direction, out.direction);
57
52
  }
58
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
- var 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]
@@ -12,34 +9,30 @@ var constants_1 = require("./constants");
12
9
  // *********************************************************
13
10
  // **************** VECTOR OPERATIONS **********************
14
11
  // *********************************************************
15
- var RADIANS = Math.PI / 180;
16
- exports.RADIANS = RADIANS;
12
+ const RADIANS = Math.PI / 180;
17
13
  /**
18
14
  * @param {vec3} a
19
15
  * @returns {vec3}
20
16
  */
21
- var normalize3 = function (a) {
22
- var len = length3(a);
17
+ const normalize3 = (a) => {
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
29
24
  * @returns {number}
30
25
  */
31
- var dot3 = function (a, b) {
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}
38
32
  */
39
- var length3 = function (a) {
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
  // *********************************************************
@@ -47,35 +40,32 @@ exports.length3 = length3;
47
40
  * @param {vec3} cartesian
48
41
  * @returns {vec2} long lat in radians
49
42
  */
50
- var cartesian3dToRadian = function (cartesian) {
51
- var x = cartesian[0];
52
- var y = cartesian[1];
53
- var z = cartesian[2];
43
+ const cartesian3dToRadian = (cartesian) => {
44
+ const x = cartesian[0];
45
+ const y = cartesian[1];
46
+ const z = cartesian[2];
54
47
  // const length = Math.sqrt(x * x + y * y + z * z);
55
- var long = Math.atan2(y, x);
56
- var lat = Math.asin(z); // length);
48
+ const long = Math.atan2(y, x);
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
- var radianToMercator = function (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))];
56
+ const radianToMercator = (xy) => {
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
71
62
  */
72
- var radianToCartesian3d = function (xy) {
73
- var x = Math.cos(xy[1]) * Math.cos(xy[0]);
74
- var y = Math.cos(xy[1]) * Math.sin(xy[0]);
75
- var z = -Math.sin(xy[1]);
63
+ const radianToCartesian3d = (xy) => {
64
+ const x = Math.cos(xy[1]) * Math.cos(xy[0]);
65
+ const y = Math.cos(xy[1]) * Math.sin(xy[0]);
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
  // *********************************************************
@@ -85,122 +75,109 @@ exports.radianToCartesian3d = radianToCartesian3d;
85
75
  * @param {fraction} ratio
86
76
  * @returns {vec3}
87
77
  */
88
- var sphericalLinearInterpolation_UnitVector = function (normalizedA, normalizedB, ratio) {
89
- var theta = Math.acos(dot3(normalizedA, normalizedB));
78
+ const sphericalLinearInterpolation_UnitVector = (normalizedA, normalizedB, ratio) => {
79
+ const theta = Math.acos(dot3(normalizedA, normalizedB));
90
80
  if (theta < 0.000001)
91
81
  return normalizedA; // CALIBRATE?
92
- var sinTheta = Math.sin(theta);
93
- var result = [
82
+ const sinTheta = Math.sin(theta);
83
+ const result = [
94
84
  (Math.sin((1.0 - ratio) * theta) * normalizedA[0] + Math.sin(ratio * theta) * normalizedB[0]) / sinTheta,
95
85
  (Math.sin((1.0 - ratio) * theta) * normalizedA[1] + Math.sin(ratio * theta) * normalizedB[1]) / sinTheta,
96
86
  (Math.sin((1.0 - ratio) * theta) * normalizedA[2] + Math.sin(ratio * theta) * normalizedB[2]) / sinTheta
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
104
93
  * @param {fraction} ratio
105
94
  * @returns
106
95
  */
107
- var sphericalLinearInterpolation_Mercator = function (normalizedA, normalizedB, ratio) {
108
- var unitVector = sphericalLinearInterpolation_UnitVector(normalizedA, normalizedB, ratio);
109
- var angles = cartesian3dToRadian(unitVector);
96
+ const sphericalLinearInterpolation_Mercator = (normalizedA, normalizedB, ratio) => {
97
+ const unitVector = sphericalLinearInterpolation_UnitVector(normalizedA, normalizedB, ratio);
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
116
104
  * @param {fraction} ratio
117
105
  */
118
- var sphericalLinearInterpolation_Cartesian3d = function (a, b, ratio) {
119
- var unitVector = sphericalLinearInterpolation_UnitVector(a, b, ratio);
120
- var height = a[3] + (b[3] - a[3]) * ratio;
106
+ const sphericalLinearInterpolation_Cartesian3d = (a, b, ratio) => {
107
+ const unitVector = sphericalLinearInterpolation_UnitVector(a, b, ratio);
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
127
114
  * @returns {vec3}
128
115
  */
129
- var wgs84ToUnitVector = function (coordinates) {
130
- var long = coordinates[0] * RADIANS;
131
- var lat = coordinates[1] * RADIANS;
132
- var x = Math.cos(lat) * Math.cos(long);
133
- var y = Math.cos(lat) * Math.sin(long);
134
- var z = Math.sin(lat);
116
+ const wgs84ToUnitVector = (coordinates) => {
117
+ const long = coordinates[0] * RADIANS;
118
+ const lat = coordinates[1] * RADIANS;
119
+ const x = Math.cos(lat) * Math.cos(long);
120
+ const y = Math.cos(lat) * Math.sin(long);
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
141
127
  * @param {number} height
142
128
  * @returns {vec3} cartesian3D
143
129
  */
144
- var wgs84ToCartesian3d = function (long, lat, height) {
145
- var longRad = long * RADIANS;
146
- var latRad = lat * RADIANS;
147
- var x = Math.cos(latRad) * Math.cos(longRad);
148
- var y = Math.cos(latRad) * Math.sin(longRad);
149
- var z = Math.sin(latRad);
150
- var radius = constants_1.WORLD_RADIUS_3D + height;
130
+ const wgs84ToCartesian3d = (long, lat, height) => {
131
+ const longRad = long * RADIANS;
132
+ const latRad = lat * RADIANS;
133
+ const x = Math.cos(latRad) * Math.cos(longRad);
134
+ const y = Math.cos(latRad) * Math.sin(longRad);
135
+ const z = Math.sin(latRad);
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
- var wgs84ToMercator = function (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))];
144
+ const wgs84ToMercator = (long, lat) => {
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
166
150
  */
167
- var pixelXYToRadians = function (pixelXY) {
168
- var long = (2.0 * pixelXY[0] - 1.0) * Math.PI;
169
- var lat = (2.0 * pixelXY[1] - 1.0) * Math.PI / 2.0;
151
+ const pixelXYToRadians = (pixelXY) => {
152
+ const long = (2.0 * pixelXY[0] - 1.0) * Math.PI;
153
+ const lat = (2.0 * pixelXY[1] - 1.0) * Math.PI / 2.0;
170
154
  return [long, lat];
171
155
  };
172
- var pixelXYLenghtToUnitVectorWithHeight = function (pixelXYHeight) {
173
- var _a = pixelXYToRadians(pixelXYHeight), long = _a[0], lat = _a[1];
174
- var radius = constants_1.WORLD_RADIUS_3D + pixelXYHeight[2];
156
+ const pixelXYLenghtToUnitVectorWithHeight = (pixelXYHeight) => {
157
+ const [long, lat] = pixelXYToRadians(pixelXYHeight);
158
+ const radius = WORLD_RADIUS_3D + pixelXYHeight[2];
175
159
  return radianToCartesian3d([long, lat]).concat(radius);
176
160
  };
177
- exports.pixelXYLenghtToUnitVectorWithHeight = pixelXYLenghtToUnitVectorWithHeight;
178
- var globe3Dcoordinates = function (globe, height) {
179
- if (height === void 0) { height = 0; }
180
- return function (longlats, _a) {
181
- var _b = _a.paddingCount, paddingCount = _b === void 0 ? 0 : _b, _c = _a.paddingValue, paddingValue = _c === void 0 ? NaN : _c;
182
- var len = longlats.length / 2;
183
- var result = new Float32Array(len * 3 + paddingCount * 3).fill(paddingValue);
184
- for (var i = 0; i < len; i++) {
185
- var long = longlats[i * 2];
186
- var lat = longlats[i * 2 + 1];
187
- var xyz = globe.api_GetCartesian3DPoint(long, lat, height, 0);
188
- result.set(xyz, i * 3);
189
- }
190
- return result;
191
- };
192
- };
193
- exports.globe3Dcoordinates = globe3Dcoordinates;
194
- var globe2Dcoordinates = function (globe) { return function (longlats, _a) {
195
- var _b = _a.paddingCount, paddingCount = _b === void 0 ? 0 : _b, _c = _a.paddingValue, paddingValue = _c === void 0 ? NaN : _c;
196
- var len = longlats.length / 2;
197
- var result = new Float32Array(len * 2 + paddingCount * 2).fill(paddingValue);
198
- for (var i = 0; i < len; i++) {
199
- var long = longlats[i * 2];
200
- var lat = longlats[i * 2 + 1];
201
- var xyz = globe.api_GetMercator2DPoint(long, lat);
161
+ const globe3Dcoordinates = (globe, height = 0) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
162
+ const len = longlats.length / 2;
163
+ const result = new Float32Array(len * 3 + paddingCount * 3).fill(paddingValue);
164
+ for (let i = 0; i < len; i++) {
165
+ const long = longlats[i * 2];
166
+ const lat = longlats[i * 2 + 1];
167
+ const xyz = globe.api_GetCartesian3DPoint(long, lat, height, 0);
168
+ result.set(xyz, i * 3);
169
+ }
170
+ return result;
171
+ };
172
+ const globe2Dcoordinates = (globe) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
173
+ const len = longlats.length / 2;
174
+ const result = new Float32Array(len * 2 + paddingCount * 2).fill(paddingValue);
175
+ for (let i = 0; i < len; i++) {
176
+ const long = longlats[i * 2];
177
+ const lat = longlats[i * 2 + 1];
178
+ const xyz = globe.api_GetMercator2DPoint(long, lat);
202
179
  result.set(xyz, i * 2);
203
180
  }
204
181
  return result;
205
- }; };
206
- exports.globe2Dcoordinates = globe2Dcoordinates;
182
+ };
183
+ export { RADIANS, normalize3, dot3, length3, cartesian3dToRadian, radianToMercator, radianToCartesian3d, sphericalLinearInterpolation_UnitVector, sphericalLinearInterpolation_Mercator, sphericalLinearInterpolation_Cartesian3d, wgs84ToUnitVector, wgs84ToCartesian3d, wgs84ToMercator, pixelXYLenghtToUnitVectorWithHeight, globe3Dcoordinates, globe2Dcoordinates, };
package/Math/plane.js CHANGED
@@ -1,62 +1,57 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.plane = void 0;
4
- var constants_1 = require("./constants");
5
- var vec3_1 = require("./vec3");
6
- var _0vector = /*@__PURE__*/ vec3_1.vec3.create(0, 0, 0);
7
- var _1vector = /*@__PURE__*/ vec3_1.vec3.create(1, 1, 1);
8
- exports.plane = Object.freeze({
9
- create: function (normal, distance) {
10
- if (normal === void 0) { normal = vec3_1.vec3.create(); }
11
- if (distance === void 0) { distance = 0; }
1
+ import { EPSILON } from "./constants";
2
+ import { vec3 } from "./vec3";
3
+ const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
4
+ const _1vector = /*@__PURE__*/ vec3.create(1, 1, 1);
5
+ export const plane = Object.freeze({
6
+ create(normal = vec3.create(), distance = 0) {
12
7
  return {
13
- normal: vec3_1.vec3.clone(normal),
8
+ normal: vec3.clone(normal),
14
9
  distance: distance
15
10
  };
16
11
  },
17
- set: function (out, normal, distance) {
18
- vec3_1.vec3.copy(out.normal, normal);
12
+ set(out, normal, distance) {
13
+ vec3.copy(out.normal, normal);
19
14
  out.distance = distance;
20
15
  return out;
21
16
  },
22
- fromValues: function (out, nx, ny, nz, distance) {
23
- vec3_1.vec3.set(out.normal, nx, ny, nz);
17
+ fromValues(out, nx, ny, nz, distance) {
18
+ vec3.set(out.normal, nx, ny, nz);
24
19
  out.distance = distance;
25
20
  },
26
- copy: function (out, a) {
27
- vec3_1.vec3.copy(out.normal, a.normal);
21
+ copy(out, a) {
22
+ vec3.copy(out.normal, a.normal);
28
23
  out.distance = a.distance;
29
24
  return out;
30
25
  },
31
- clone: function (a) {
26
+ clone(a) {
32
27
  return {
33
- normal: vec3_1.vec3.clone(a.normal),
28
+ normal: vec3.clone(a.normal),
34
29
  distance: a.distance
35
30
  };
36
31
  },
37
- distanceToPoint: function (plane, point) {
38
- return vec3_1.vec3.dot(plane.normal, point) - plane.distance;
32
+ distanceToPoint(plane, point) {
33
+ return vec3.dot(plane.normal, point) - plane.distance;
39
34
  },
40
- projectPoint: function (out, plane, point) {
41
- var distance = this.distanceToPoint(plane, point);
42
- vec3_1.vec3.multiplyScalar(out, plane.normal, distance);
43
- vec3_1.vec3.subtract(out, point, out);
35
+ projectPoint(out, plane, point) {
36
+ const distance = this.distanceToPoint(plane, point);
37
+ vec3.multiplyScalar(out, plane.normal, distance);
38
+ vec3.subtract(out, point, out);
44
39
  },
45
- equals: function (plane, other) {
46
- return vec3_1.vec3.equals(plane.normal, other.normal) && Math.abs(plane.distance - other.distance) < constants_1.EPSILON;
40
+ equals(plane, other) {
41
+ return vec3.equals(plane.normal, other.normal) && Math.abs(plane.distance - other.distance) < EPSILON;
47
42
  },
48
- fromNormalAndCoplanarPoint: function (out, normal, point) {
49
- vec3_1.vec3.copy(out.normal, normal);
50
- out.distance = vec3_1.vec3.dot(point, normal);
43
+ fromNormalAndCoplanarPoint(out, normal, point) {
44
+ vec3.copy(out.normal, normal);
45
+ out.distance = vec3.dot(point, normal);
51
46
  },
52
- fromPoints: function (out, a, b, c) {
53
- vec3_1.vec3.subtract(_0vector, b, a);
54
- vec3_1.vec3.subtract(_1vector, c, a);
55
- vec3_1.vec3.cross(out.normal, _0vector, _1vector);
56
- vec3_1.vec3.normalize(out.normal, out.normal);
57
- out.distance = vec3_1.vec3.dot(out.normal, a);
47
+ fromPoints(out, a, b, c) {
48
+ vec3.subtract(_0vector, b, a);
49
+ vec3.subtract(_1vector, c, a);
50
+ vec3.cross(out.normal, _0vector, _1vector);
51
+ vec3.normalize(out.normal, out.normal);
52
+ out.distance = vec3.dot(out.normal, a);
58
53
  },
59
- getUnitSphereRadiusAngle: function (plane) {
54
+ getUnitSphereRadiusAngle(plane) {
60
55
  return Math.acos(Math.max(Math.min(plane.distance, 1), -1));
61
56
  }
62
57
  });
@@ -1,80 +1,73 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.quaternion = void 0;
4
- var vec3_1 = require("./vec3");
5
- var constants_1 = require("./constants");
6
- exports.quaternion = Object.freeze({
7
- create: function (x, y, z, w) {
8
- if (x === void 0) { x = 0; }
9
- if (y === void 0) { y = 0; }
10
- if (z === void 0) { z = 0; }
11
- if (w === void 0) { w = 1; }
1
+ import { vec3 } from './vec3';
2
+ import { EPSILON } from './constants';
3
+ export const quaternion = Object.freeze({
4
+ create(x = 0, y = 0, z = 0, w = 1) {
12
5
  return [x, y, z, w];
13
6
  },
14
- set: function (out, x, y, z, w) {
7
+ set(out, x, y, z, w) {
15
8
  out[0] = x;
16
9
  out[1] = y;
17
10
  out[2] = z;
18
11
  out[3] = w;
19
12
  },
20
- copy: function (out, a) {
13
+ copy(out, a) {
21
14
  out[0] = a[0];
22
15
  out[1] = a[1];
23
16
  out[2] = a[2];
24
17
  out[3] = a[3];
25
18
  },
26
- clone: function (a) {
19
+ clone(a) {
27
20
  return [a[0], a[1], a[2], a[3]];
28
21
  },
29
- multiply: function (out, a, b) {
30
- var x = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
31
- var y = a[1] * b[3] + a[3] * b[1] + a[2] * b[0] - a[0] * b[2];
32
- var z = a[2] * b[3] + a[3] * b[2] + a[0] * b[1] - a[1] * b[0];
33
- var w = a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2];
22
+ multiply(out, a, b) {
23
+ const x = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
24
+ const y = a[1] * b[3] + a[3] * b[1] + a[2] * b[0] - a[0] * b[2];
25
+ const z = a[2] * b[3] + a[3] * b[2] + a[0] * b[1] - a[1] * b[0];
26
+ const w = a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2];
34
27
  this.set(out, x, y, z, w);
35
28
  return out;
36
29
  },
37
- randomUnit: function (out) {
38
- var u1 = Math.random();
39
- var u2 = Math.random();
40
- var u3 = Math.random();
41
- var sqrt1MinusU1 = Math.sqrt(1 - u1);
42
- var sqrtU1 = Math.sqrt(u1);
43
- var x = sqrt1MinusU1 * Math.sin(2 * Math.PI * u2);
44
- var y = sqrt1MinusU1 * Math.cos(2 * Math.PI * u2);
45
- var z = sqrtU1 * Math.sin(2 * Math.PI * u3);
46
- var w = sqrtU1 * Math.cos(2 * Math.PI * u3);
30
+ randomUnit(out) {
31
+ const u1 = Math.random();
32
+ const u2 = Math.random();
33
+ const u3 = Math.random();
34
+ const sqrt1MinusU1 = Math.sqrt(1 - u1);
35
+ const sqrtU1 = Math.sqrt(u1);
36
+ const x = sqrt1MinusU1 * Math.sin(2 * Math.PI * u2);
37
+ const y = sqrt1MinusU1 * Math.cos(2 * Math.PI * u2);
38
+ const z = sqrtU1 * Math.sin(2 * Math.PI * u3);
39
+ const w = sqrtU1 * Math.cos(2 * Math.PI * u3);
47
40
  this.set(out, x, y, z, w);
48
41
  this.normalize(out, out);
49
42
  return out;
50
43
  },
51
- rotateQuaternion: function (out, a, b) {
52
- var x = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
53
- var y = a[1] * b[3] + a[3] * b[1] + a[2] * b[0] - a[0] * b[2];
54
- var z = a[2] * b[3] + a[3] * b[2] + a[0] * b[1] - a[1] * b[0];
55
- var w = a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2];
44
+ rotateQuaternion(out, a, b) {
45
+ const x = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] - a[2] * b[1];
46
+ const y = a[1] * b[3] + a[3] * b[1] + a[2] * b[0] - a[0] * b[2];
47
+ const z = a[2] * b[3] + a[3] * b[2] + a[0] * b[1] - a[1] * b[0];
48
+ const w = a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2];
56
49
  this.set(out, x, y, z, w);
57
50
  this.normalize(out, out);
58
51
  },
59
- lengthSquared: function (a) {
52
+ lengthSquared(a) {
60
53
  return a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3];
61
54
  },
62
- length: function (a) {
55
+ length(a) {
63
56
  return Math.sqrt(this.lengthSquared(a));
64
57
  },
65
- normalize: function (out, input) {
66
- var len = Math.sqrt(this.lengthSquared(input));
67
- if (len < constants_1.EPSILON) {
58
+ normalize(out, input) {
59
+ const len = Math.sqrt(this.lengthSquared(input));
60
+ if (len < EPSILON) {
68
61
  this.set(out, 0, 0, 0, 1);
69
62
  }
70
63
  else {
71
- var invLen = 1 / len;
64
+ const invLen = 1 / len;
72
65
  this.set(out, input[0] * invLen, input[1] * invLen, input[2] * invLen, input[3] * invLen);
73
66
  }
74
67
  },
75
- fromUnitVectors: function (out, from, to) {
76
- var d = vec3_1.vec3.dot(from, to) + 1;
77
- if (d < constants_1.EPSILON) {
68
+ fromUnitVectors(out, from, to) {
69
+ const d = vec3.dot(from, to) + 1;
70
+ if (d < EPSILON) {
78
71
  if (Math.abs(from[0]) > Math.abs(from[2])) {
79
72
  this.set(out, -from[1], from[0], 0, 0);
80
73
  }
@@ -83,26 +76,26 @@ exports.quaternion = Object.freeze({
83
76
  }
84
77
  }
85
78
  else {
86
- var x = from[1] * to[2] - from[2] * to[1];
87
- var y = from[2] * to[0] - from[0] * to[2];
88
- var z = from[0] * to[1] - from[1] * to[0];
79
+ const x = from[1] * to[2] - from[2] * to[1];
80
+ const y = from[2] * to[0] - from[0] * to[2];
81
+ const z = from[0] * to[1] - from[1] * to[0];
89
82
  this.set(out, x, y, z, d);
90
83
  }
91
84
  },
92
- fromTwoQuaternions: function (out, from, to) {
93
- var x = from[0] * to[3] + from[3] * to[0] + from[1] * to[2] - from[2] * to[1];
94
- var y = from[1] * to[3] + from[3] * to[1] + from[2] * to[0] - from[0] * to[2];
95
- var z = from[2] * to[3] + from[3] * to[2] + from[0] * to[1] - from[1] * to[0];
96
- var w = from[3] * to[3] - from[0] * to[0] - from[1] * to[1] - from[2] * to[2];
85
+ fromTwoQuaternions(out, from, to) {
86
+ const x = from[0] * to[3] + from[3] * to[0] + from[1] * to[2] - from[2] * to[1];
87
+ const y = from[1] * to[3] + from[3] * to[1] + from[2] * to[0] - from[0] * to[2];
88
+ const z = from[2] * to[3] + from[3] * to[2] + from[0] * to[1] - from[1] * to[0];
89
+ const w = from[3] * to[3] - from[0] * to[0] - from[1] * to[1] - from[2] * to[2];
97
90
  this.set(out, x, y, z, w);
98
91
  this.normalize(out, out);
99
92
  },
100
- conjugate: function (out, a) {
93
+ conjugate(out, a) {
101
94
  this.set(out, -a[0], -a[1], -a[2], a[3]);
102
95
  },
103
- fromAxisAngle: function (out, axis, angle) {
104
- var halfAngle = angle / 2;
105
- var s = Math.sin(halfAngle);
96
+ fromAxisAngle(out, axis, angle) {
97
+ const halfAngle = angle / 2;
98
+ const s = Math.sin(halfAngle);
106
99
  this.set(out, axis[0] * s, axis[1] * s, axis[2] * s, Math.cos(halfAngle));
107
100
  },
108
101
  });
package/Math/types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/Math/utils.js CHANGED
@@ -1,4 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var vector3d_1 = require("./vector3d");
4
- var quaternion_1 = require("./quaternion");
1
+ import { Vector3D } from "./vector3d";
2
+ import { Quaternion } from "./quaternion";