@pirireis/webglobeplugins 0.9.11 → 0.9.12

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