@pirireis/webglobeplugins 0.9.6 → 0.9.7

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 (226) hide show
  1. package/package.json +5 -2
  2. package/Math/angle-calculation.js +0 -14
  3. package/Math/arc.ts +0 -76
  4. package/Math/bounds/line-bbox.js +0 -225
  5. package/Math/constants.ts +0 -11
  6. package/Math/frustum/camera.ts +0 -32
  7. package/Math/frustum/from-globeinfo.ts +0 -63
  8. package/Math/frustum/types.ts +0 -11
  9. package/Math/globe-util/horizon-plane.ts +0 -137
  10. package/Math/index.js +0 -0
  11. package/Math/juction/arc-plane.ts +0 -114
  12. package/Math/juction/line-sphere.ts +0 -30
  13. package/Math/juction/plane-plane.ts +0 -66
  14. package/Math/line.ts +0 -70
  15. package/Math/matrix4.ts +0 -0
  16. package/Math/methods.js +0 -237
  17. package/Math/plane.ts +0 -86
  18. package/Math/quaternion.ts +0 -120
  19. package/Math/roadmap.md +0 -10
  20. package/Math/types.ts +0 -45
  21. package/Math/utils.js +0 -3
  22. package/Math/vec3.ts +0 -155
  23. package/algorithms/search-binary.js +0 -14
  24. package/altitude-locator/adaptors.js +0 -0
  25. package/altitude-locator/draw-subset-obj.js +0 -27
  26. package/altitude-locator/keymethod.js +0 -0
  27. package/altitude-locator/plugin.js +0 -439
  28. package/altitude-locator/types.js +0 -26
  29. package/arrowfield/adaptor.js +0 -11
  30. package/arrowfield/index.js +0 -3
  31. package/arrowfield/plugin.js +0 -128
  32. package/bearing-line/index.js +0 -2
  33. package/bearing-line/plugin.js +0 -512
  34. package/circle-line-chain/chain-list-map.js +0 -221
  35. package/circle-line-chain/init.js +0 -0
  36. package/circle-line-chain/plugin.js +0 -469
  37. package/circle-line-chain/readme.md +0 -57
  38. package/circle-line-chain/util.js +0 -1
  39. package/compass-rose/compass-rose-padding-flat.js +0 -266
  40. package/compass-rose/compass-text-writer.js +0 -173
  41. package/compass-rose/index.js +0 -3
  42. package/compassrose/compassrose.js +0 -341
  43. package/compassrose/index.js +0 -2
  44. package/depth-locator/readme.md +0 -26
  45. package/globe-types.ts +0 -13
  46. package/heatwave/index.js +0 -4
  47. package/heatwave/isobar/objectarraylabels.js +0 -247
  48. package/heatwave/isobar/plugin.js +0 -340
  49. package/heatwave/isobar/quadtreecontours.js +0 -336
  50. package/heatwave/plugins/heatwaveglobeshell.js +0 -258
  51. package/jest.config.js +0 -6
  52. package/partialrings/buffer-manager.js +0 -89
  53. package/partialrings/goals.md +0 -17
  54. package/partialrings/index.js +0 -3
  55. package/partialrings/plugin.js +0 -160
  56. package/partialrings/program.js +0 -324
  57. package/pin/pin-object-array.js +0 -381
  58. package/pin/pin-point-totem.js +0 -77
  59. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -78
  60. package/point-heat-map/index.js +0 -0
  61. package/point-heat-map/plugin-webworker.js +0 -151
  62. package/point-heat-map/point-to-heat-map-flow.js +0 -150
  63. package/point-heat-map/readme.md +0 -15
  64. package/point-tracks/key-methods.js +0 -3
  65. package/point-tracks/plugin.js +0 -394
  66. package/programs/arrowfield/index.js +0 -2
  67. package/programs/arrowfield/logic.js +0 -286
  68. package/programs/arrowfield/object.js +0 -89
  69. package/programs/data2legend/density-to-legend.js +0 -115
  70. package/programs/data2legend/point-to-density-texture.js +0 -114
  71. package/programs/float2legendwithratio/index.js +0 -3
  72. package/programs/float2legendwithratio/logic.js +0 -194
  73. package/programs/float2legendwithratio/object.js +0 -141
  74. package/programs/globe-util/is-globe-moved.js +0 -27
  75. package/programs/globeshell/index.js +0 -2
  76. package/programs/globeshell/noise/noises.js +0 -0
  77. package/programs/globeshell/wiggle/index.js +0 -6
  78. package/programs/globeshell/wiggle/logic.js +0 -371
  79. package/programs/globeshell/wiggle/object.js +0 -93
  80. package/programs/helpers/blender/index.js +0 -0
  81. package/programs/helpers/blender/program.js +0 -91
  82. package/programs/helpers/fadeaway/index.js +0 -3
  83. package/programs/helpers/fadeaway/logic.js +0 -76
  84. package/programs/helpers/fadeaway/object.js +0 -20
  85. package/programs/helpers/index.js +0 -2
  86. package/programs/index.js +0 -21
  87. package/programs/interface.ts +0 -7
  88. package/programs/line-on-globe/angled-line.js +0 -206
  89. package/programs/line-on-globe/circle-accurate-3d.js +0 -167
  90. package/programs/line-on-globe/circle-accurate-flat.js +0 -262
  91. package/programs/line-on-globe/circle-accurate.js +0 -202
  92. package/programs/line-on-globe/circle.js +0 -191
  93. package/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -188
  94. package/programs/line-on-globe/index.js +0 -0
  95. package/programs/line-on-globe/lines-color-instanced-flat.js +0 -151
  96. package/programs/line-on-globe/linestrip.ts +0 -228
  97. package/programs/line-on-globe/naive-accurate-flexible.js +0 -239
  98. package/programs/line-on-globe/to-the-surface.js +0 -129
  99. package/programs/line-on-globe/util.js +0 -8
  100. package/programs/picking/pickable-renderer.js +0 -216
  101. package/programs/point-on-globe/element-globe-surface-glow.js +0 -168
  102. package/programs/point-on-globe/element-point-glow.js +0 -184
  103. package/programs/point-on-globe/square-pixel-point.js +0 -189
  104. package/programs/programcache.ts +0 -131
  105. package/programs/rings/distancering/circleflatprogram.js +0 -136
  106. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -378
  107. package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -420
  108. package/programs/rings/distancering/index.js +0 -5
  109. package/programs/rings/distancering/paddyflatprogram.js +0 -146
  110. package/programs/rings/distancering/paddyflatprogram2d.js +0 -150
  111. package/programs/rings/distancering/paddyflatprogram3d.js +0 -146
  112. package/programs/rings/distancering/shader.js +0 -0
  113. package/programs/rings/index.js +0 -1
  114. package/programs/rings/partial-ring/piece-of-pie.js +0 -315
  115. package/programs/totems/camerauniformblock.d.ts +0 -48
  116. package/programs/totems/camerauniformblock.js +0 -197
  117. package/programs/totems/canvas-webglobe-info.js +0 -136
  118. package/programs/totems/gpu-selection-uniform-block.js +0 -132
  119. package/programs/totems/index.ts +0 -2
  120. package/programs/two-d/pixel-circle.js +0 -0
  121. package/programs/two-d/pixel-padding-for-compass.js +0 -174
  122. package/programs/util.js +0 -20
  123. package/programs/vectorfields/index.js +0 -3
  124. package/programs/vectorfields/logics/drawrectangleparticles.js +0 -125
  125. package/programs/vectorfields/logics/index.js +0 -5
  126. package/programs/vectorfields/logics/pixelbased.js +0 -161
  127. package/programs/vectorfields/logics/ubo.js +0 -64
  128. package/programs/vectorfields/pingpongbuffermanager.js +0 -80
  129. package/publish.bat +0 -60
  130. package/rangerings/enum.js +0 -3
  131. package/rangerings/index.js +0 -5
  132. package/rangerings/plugin.js +0 -649
  133. package/rangerings/rangeringangletext.js +0 -368
  134. package/rangerings/ring-account.js +0 -129
  135. package/shaders/fragment-toy/firework.js +0 -55
  136. package/shaders/fragment-toy/singularity.js +0 -59
  137. package/shape-on-terrain/arc/naive/plugin.ts +0 -304
  138. package/shape-on-terrain/goal.md +0 -12
  139. package/tests/Math/junction/arc-plane.test.ts +0 -133
  140. package/tests/Math/junction/plane-plane.test.ts +0 -82
  141. package/tests/Math/plane.test.ts +0 -43
  142. package/tests/Math/vec3.test.ts +0 -14
  143. package/timetracks/adaptors-line-strip.js +0 -80
  144. package/timetracks/adaptors.js +0 -133
  145. package/timetracks/index.js +0 -6
  146. package/timetracks/plugin-line-strip.js +0 -295
  147. package/timetracks/plugin.js +0 -304
  148. package/timetracks/program-line-strip.js +0 -688
  149. package/timetracks/program.js +0 -850
  150. package/timetracks/programpoint-line-strip.js +0 -175
  151. package/timetracks/programpoint.js +0 -168
  152. package/timetracks/readme.md +0 -1
  153. package/tsconfig.json +0 -22
  154. package/types.ts +0 -17
  155. package/util/account/bufferoffsetmanager.js +0 -209
  156. package/util/account/index.js +0 -6
  157. package/util/account/single-attribute-buffer-management/buffer-manager.ts +0 -119
  158. package/util/account/single-attribute-buffer-management/buffer-orchestrator.ts +0 -173
  159. package/util/account/single-attribute-buffer-management/index.ts +0 -13
  160. package/util/account/single-attribute-buffer-management/object-store.ts +0 -65
  161. package/util/account/single-attribute-buffer-management/types.ts +0 -39
  162. package/util/account/util.js +0 -22
  163. package/util/algorithms/index.js +0 -0
  164. package/util/algorithms/search-binary.js +0 -26
  165. package/util/check/get.js +0 -13
  166. package/util/check/index.js +0 -0
  167. package/util/check/typecheck.js +0 -39
  168. package/util/geometry/index.js +0 -53
  169. package/util/gl-util/buffer/attribute-loader.ts +0 -85
  170. package/util/gl-util/buffer/index.ts +0 -6
  171. package/util/gl-util/buffer/types.ts +0 -13
  172. package/util/gl-util/draw-options/methods.ts +0 -66
  173. package/util/gl-util/draw-options/types.ts +0 -28
  174. package/util/gl-util/uniform-block/manager.ts +0 -187
  175. package/util/gl-util/uniform-block/roadmap.md +0 -70
  176. package/util/gl-util/uniform-block/shader.js +0 -0
  177. package/util/gl-util/uniform-block/types.ts +0 -27
  178. package/util/heatwavedatamanager/datamanager.js +0 -168
  179. package/util/heatwavedatamanager/index.js +0 -3
  180. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -133
  181. package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
  182. package/util/index.js +0 -13
  183. package/util/interpolation/index.js +0 -0
  184. package/util/interpolation/timetrack/index.js +0 -9
  185. package/util/interpolation/timetrack/timetrack-interpolator.js +0 -88
  186. package/util/interpolation/timetrack/web-worker-str.js +0 -180
  187. package/util/interpolation/timetrack/web-worker.js +0 -51
  188. package/util/jshelpers/data-filler.js +0 -19
  189. package/util/jshelpers/equality.js +0 -17
  190. package/util/jshelpers/index.js +0 -1
  191. package/util/jshelpers/timefilters.js +0 -32
  192. package/util/picking/fence.js +0 -46
  193. package/util/picking/picker-displayer.js +0 -177
  194. package/util/programs/draw-texture-on-canvas.js +0 -102
  195. package/util/programs/index.js +0 -1
  196. package/util/programs/shapesonglobe.js +0 -246
  197. package/util/programs/supersampletotextures.js +0 -142
  198. package/util/programs/texturetoglobe.js +0 -203
  199. package/util/shaderfunctions/geometrytransformations.ts +0 -388
  200. package/util/shaderfunctions/index.js +0 -2
  201. package/util/shaderfunctions/nodata.js +0 -10
  202. package/util/shaderfunctions/noisefunctions.js +0 -44
  203. package/util/surface-line-data/arc-bboxes.ts +0 -42
  204. package/util/surface-line-data/arcs-to-cuts.js +0 -74
  205. package/util/surface-line-data/cut-arc.js +0 -0
  206. package/util/surface-line-data/flow.ts +0 -52
  207. package/util/surface-line-data/rbush-manager.js +0 -0
  208. package/util/surface-line-data/types.ts +0 -27
  209. package/util/surface-line-data/web-worker.js +0 -0
  210. package/util/webglobe/gldefaultstates.js +0 -5
  211. package/util/webglobe/index.js +0 -2
  212. package/util/webglobe/rasteroverlay.js +0 -96
  213. package/util/webglobjectbuilders.ts +0 -456
  214. package/util/webglobjectbuilders1.js +0 -271
  215. package/waveparticles/adaptor.js +0 -16
  216. package/waveparticles/index.js +0 -3
  217. package/waveparticles/plugin.js +0 -313
  218. package/wind/imagetovectorfieldandmagnitude.js +0 -39
  219. package/wind/index.js +0 -5
  220. package/wind/plugin.js +0 -1057
  221. package/wind/vectorfieldimage.js +0 -27
  222. package/write-text/attached-text-writer.js +0 -105
  223. package/write-text/context-text.js +0 -125
  224. package/write-text/context-text3.js +0 -178
  225. package/write-text/index.js +0 -1
  226. package/write-text/writer-plugin.js +0 -7
@@ -1,114 +0,0 @@
1
- import { Vec3, Plane, Line, Sphere, Arc } from "../types";
2
- import { EPSILON } from "../constants";
3
- import { vec3 } from "../vec3";
4
- import { line } from "../line";
5
- import { plane } from "../plane";
6
- import { arc } from "../arc";
7
- import { planePlaneJuction } from "./plane-plane";
8
- import { lineSphereIntersection } from "./line-sphere";
9
-
10
- const _intersectionLine = /*@__PURE__*/ line.create();
11
- const _originPlane = /*@__PURE__*/ plane.create();
12
- _originPlane.distance = 0;
13
- const _originSphere = /*@__PURE__*/ { center: vec3.create(0, 0, 0), radius: 1 } as Sphere;
14
-
15
- const _intersectionPoints: [Vec3, Vec3] = /*@__PURE__*/[vec3.create(), vec3.create()];
16
-
17
- // 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
18
-
19
-
20
-
21
- /**
22
- *
23
- * @param out \
24
- * @param inArc
25
- * @param juctionPlane
26
- * @returns number of arcs segments in the junction divided by the junction plane.
27
- */
28
- export function arcSlice(out: [Arc, Arc], inArc: Arc, juctionPlane: Plane): number {
29
-
30
- // arc coverPlane and junctionPlane intersection exist in the range of unit sphere
31
- const coverRadiusAngle = plane.getUnitSphereRadiusAngle(inArc.coverPlane);
32
- const visibleRadiusAngle = plane.getUnitSphereRadiusAngle(juctionPlane);
33
- // TODO: RESEARCH efficient approach --
34
- const angleBetween_Cover_Visible = Math.acos(vec3.dot(inArc.coverPlane.normal, juctionPlane.normal));
35
-
36
- if (coverRadiusAngle + visibleRadiusAngle < angleBetween_Cover_Visible - EPSILON) { // case A: out of range
37
- return 0; // No intersection
38
- }
39
- // ------------------------------------
40
-
41
- // the case when the arc is completely covered by the juction plane
42
-
43
- if (visibleRadiusAngle + EPSILON >= angleBetween_Cover_Visible + coverRadiusAngle) { // case B: fully visible
44
- arc.copy(out[0], inArc);
45
- return 1;
46
- }
47
- // plane-plane intersection line should be calculated for the rest of the calculations
48
-
49
- vec3.copy(_originPlane.normal, inArc.normal);
50
- const isPlaneJunctions = planePlaneJuction(_intersectionLine, _originPlane, juctionPlane);
51
-
52
- if (!isPlaneJunctions) { // case C: planes are parallel.
53
- // case A covers opposite directions
54
- // case B Covers they face each other
55
- throw new Error("Unexpected case: planes are parallel, case A and B should Cover it");
56
- }
57
- // --- read until here ---
58
-
59
- // calculate the intersection points
60
-
61
- const isSphereIntersection = lineSphereIntersection(_intersectionPoints, _intersectionLine, _originSphere);
62
-
63
- if (!isSphereIntersection) {
64
- // other edge caes should be covered by now
65
- return 0; // No intersection
66
- }
67
-
68
-
69
- const i0IsCovered = plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[0]) > -EPSILON;
70
- const i1IsCovered = plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[1]) > -EPSILON;
71
-
72
-
73
- const p0IsVisible = plane.distanceToPoint(juctionPlane, inArc.p0) > -EPSILON;
74
- const p1IsVisible = plane.distanceToPoint(juctionPlane, inArc.p1) > -EPSILON;
75
-
76
- if (!p0IsVisible && !p1IsVisible && !i0IsCovered && !i1IsCovered) {
77
- return 0; // No intersection
78
- }
79
-
80
- if (i0IsCovered && i1IsCovered && p0IsVisible && p1IsVisible) {
81
- // calculate which points are closer
82
- const p0i0DistanceSquared = vec3.distanceSquared(inArc.p0, _intersectionPoints[0]);
83
- const p0i1DistanceSquared = vec3.distanceSquared(inArc.p0, _intersectionPoints[1]);
84
- const case0 = p0i0DistanceSquared < p0i1DistanceSquared;
85
- arc.set(out[0], inArc.p0, case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
86
- arc.set(out[1], inArc.p1, !case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
87
- return 2;
88
- }
89
-
90
-
91
- if (i0IsCovered && i1IsCovered) {
92
- arc.set(out[0], _intersectionPoints[0], _intersectionPoints[1]);
93
- return 1;
94
- }
95
-
96
-
97
- if (p0IsVisible && p1IsVisible) {
98
- arc.copy(out[0], inArc);
99
- return 1;
100
- }
101
-
102
- if ((p0IsVisible || p1IsVisible) !== (i0IsCovered || i1IsCovered)) {
103
- throw new Error("Unexpected case: one covered and one visible point must be present");
104
- }
105
-
106
- arc.set(
107
- out[0],
108
- p0IsVisible ? inArc.p0 : inArc.p1,
109
- i0IsCovered ? _intersectionPoints[0] : _intersectionPoints[1]
110
- );
111
-
112
- return 1;
113
- }
114
-
@@ -1,30 +0,0 @@
1
- import { Vec3, Line, Sphere } from "../types";
2
-
3
- import { vec3 } from "../vec3";
4
- import { line } from "../line";
5
-
6
- const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
7
-
8
-
9
- export function lineSphereIntersection(out: [Vec3, Vec3], inLine: Line, inSphere: Sphere): boolean {
10
-
11
- vec3.subtract(_0vector, inLine.origin, inSphere.center);
12
- const distanceSquared = vec3.lengthSquared(_0vector);
13
- const radiusSquared = inSphere.radius * inSphere.radius;
14
- const dot = vec3.dot(_0vector, inLine.direction);
15
- const dotSquared = dot * dot;
16
-
17
- const _a = dotSquared + radiusSquared - distanceSquared;
18
- if (_a < 0) {
19
- return false; // no intersection
20
- } else {
21
- const a = Math.sqrt(_a);
22
- const t1 = dot - a;
23
- const t2 = dot + a;
24
-
25
- line.at(out[0], inLine, t1);
26
- line.at(out[1], inLine, t2);
27
-
28
- return true;
29
- }
30
- }
@@ -1,66 +0,0 @@
1
- import { Plane, Line, Vec3 } from "../types";
2
- import { EPSILON } from "../constants";
3
- import { plane } from "../plane";
4
- import { line } from "../line";
5
- import { vec3 } from "../vec3";
6
-
7
- const _normal1 = vec3.create();
8
- const _normal2 = vec3.create();
9
-
10
- export function planePlaneJuction(out: Line, plane1: Plane, plane2: Plane): boolean {
11
- vec3.copy(_normal1, plane1.normal);
12
- vec3.copy(_normal2, plane2.normal);
13
- const distance1 = plane1.distance;
14
- const distance2 = plane2.distance;
15
-
16
- const { origin, direction } = out;
17
-
18
- const dot = vec3.dot(_normal1, _normal2);
19
-
20
- if (Math.abs(dot) > 1 - EPSILON) {
21
- return false; // Planes are parallel, no intersection
22
- }
23
-
24
- vec3.cross(direction, _normal1, _normal2);
25
-
26
- const magnitudeSquired = vec3.lengthSquared(out.direction);
27
- if (magnitudeSquired < EPSILON) {
28
- return false; // No valid intersection line
29
- }
30
-
31
- const magnitude = Math.sqrt(magnitudeSquired);
32
- direction[0] /= magnitude;
33
- direction[1] /= magnitude;
34
- direction[2] /= magnitude;
35
-
36
-
37
-
38
- let determinant: number;
39
- // Calculate the intersection point
40
- // set z = 0
41
- determinant = _normal1[0] * _normal2[1] - _normal1[1] * _normal2[0];
42
- if (Math.abs(determinant) > EPSILON) {
43
- origin[0] = (distance1 * _normal2[1] - distance2 * _normal1[1]) / determinant;
44
- origin[1] = (distance2 * _normal1[0] - distance1 * _normal2[0]) / determinant;
45
- origin[2] = 0;
46
- } else {
47
- // set y = 0
48
- determinant = _normal1[0] * _normal2[2] - _normal1[2] * _normal2[0];
49
- if (Math.abs(determinant) > EPSILON) {
50
- origin[0] = (distance1 * _normal2[2] - distance2 * _normal1[2]) / determinant;
51
- origin[1] = 0;
52
- origin[2] = (distance2 * _normal1[0] - distance1 * _normal2[0]) / determinant;
53
- } else {
54
- // set x = 0
55
- determinant = _normal1[1] * _normal2[2] - _normal1[2] * _normal2[1];
56
- if (Math.abs(determinant) > EPSILON) {
57
- origin[0] = 0;
58
- origin[1] = (distance1 * _normal2[2] - distance2 * _normal1[2]) / determinant;
59
- origin[2] = (distance2 * _normal1[1] - distance1 * _normal2[1]) / determinant;
60
- } else {
61
- return false; // No valid intersection point
62
- }
63
- }
64
- }
65
- return true;
66
- }
package/Math/line.ts DELETED
@@ -1,70 +0,0 @@
1
- import { EPSILON } from './constants';
2
- import { Vec3, Line, Quaternion } from './types';
3
- import { vec3 } from './vec3';
4
-
5
-
6
- const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
7
-
8
-
9
- export const line = Object.freeze({
10
- create(origin = vec3.create(), direction = vec3.create()): Line {
11
- const direction_ = vec3.clone(direction);
12
- vec3.normalize(direction_, direction_);
13
- return {
14
- origin: vec3.clone(origin),
15
- direction: direction_
16
- };
17
- },
18
-
19
- set(out: Line, origin: Vec3, direction: Vec3) {
20
- vec3.copy(out.origin, origin);
21
- vec3.copy(out.direction, direction);
22
- },
23
-
24
- copy(out: Line, a: Line) {
25
- out.origin = vec3.copy(out.origin, a.origin);
26
- out.direction = vec3.copy(out.direction, a.direction);
27
- },
28
-
29
- clone(a: Line): Line {
30
- return {
31
- origin: vec3.clone(a.origin),
32
- direction: vec3.clone(a.direction)
33
- }
34
- },
35
-
36
- fromTwoPoints(out: Line, a: Vec3, b: Vec3) {
37
- vec3.subtract(out.direction, b, a);
38
- vec3.normalize(out.direction, out.direction);
39
- vec3.copy(out.origin, a);
40
- },
41
-
42
- at(out: Vec3, line: Line, distance: number) {
43
- vec3.multiplyScalar(_0vector, line.direction, distance);
44
- vec3.add(out, _0vector, line.origin);
45
- },
46
-
47
-
48
- closestPoint(out: Vec3, line: Line, point: Vec3) {
49
- vec3.subtract(_0vector, point, line.origin);
50
- const dot = vec3.dot(_0vector, line.direction);
51
- vec3.copy(out, line.direction);
52
- vec3.multiplyScalar(out, out, dot);
53
- vec3.add(out, out, line.origin);
54
- },
55
-
56
-
57
- contains(line: Line, point: Vec3): boolean {
58
- vec3.subtract(_0vector, point, line.origin);
59
- vec3.cross(_0vector, _0vector, line.direction);
60
- return vec3.lengthSquared(_0vector) < EPSILON;
61
- },
62
-
63
- applyQuaternion(out: Line, line: Line, quaternion: Quaternion) {
64
- vec3.applyQuaternion(out.origin, line.origin, quaternion);
65
- vec3.applyQuaternion(out.direction, line.direction, quaternion);
66
- vec3.normalize(out.direction, out.direction);
67
- }
68
-
69
-
70
- })
package/Math/matrix4.ts DELETED
File without changes
package/Math/methods.js DELETED
@@ -1,237 +0,0 @@
1
-
2
- import { WORLD_RADIUS_3D, WORLD_RADIUS_MERCATOR } from './constants.ts';
3
-
4
- /**
5
- * @typedef {Array<number>} vec3 [x, y, z]
6
- * @typedef {Array<number>} vec2 [x, y]
7
- * @typedef {Array<number>} vec4 [x, y, z, w]
8
- * @typedef {number} fraction a number between 0 and 1
9
- * @typedef {Array<number>} wgs84 [long, lat]
10
- */
11
-
12
- // *********************************************************
13
- // **************** VECTOR OPERATIONS **********************
14
- // *********************************************************
15
- const RADIANS = Math.PI / 180;
16
-
17
-
18
- /**
19
- * @param {vec3} a
20
- * @returns {vec3}
21
- */
22
- const normalize3 = (a) => {
23
- const len = length3(a);
24
- return [a[0] / len, a[1] / len, a[2] / len];
25
- }
26
-
27
-
28
- /**
29
- * @param {vec3} a
30
- * @param {vec3} b
31
- * @returns {number}
32
- */
33
- const dot3 = (a, b) => {
34
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
35
- }
36
-
37
-
38
- /**
39
- * @param {vec3} a
40
- * @returns {number}
41
- */
42
- const length3 = (a) => {
43
- return Math.sqrt(dot3(a, a));
44
- }
45
-
46
-
47
- // *********************************************************
48
- // **************** TRANSFORMATIONS ************************
49
- // *********************************************************
50
-
51
- /**
52
- * @param {vec3} cartesian
53
- * @returns {vec2} long lat in radians
54
- */
55
- const cartesian3dToRadian = (cartesian) => {
56
- const x = cartesian[0];
57
- const y = cartesian[1];
58
- const z = cartesian[2];
59
- // const length = Math.sqrt(x * x + y * y + z * z);
60
- const long = Math.atan2(y, x);
61
- const lat = Math.asin(z)// length);
62
- return [long, lat];
63
- }
64
-
65
-
66
- /**
67
- * @param {vec2} xy long lat in radians
68
- * @returns {vec2} long lat in mercator meters
69
- */
70
- const radianToMercator = (xy) => {
71
- return [WORLD_RADIUS_MERCATOR * xy[0], WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + xy[1] / 2))];
72
- }
73
-
74
- /**
75
- * @param {vec2} xy long lat radians
76
- * @returns {vec3} cartesian
77
- */
78
-
79
- const radianToCartesian3d = (xy) => {
80
- const x = Math.cos(xy[1]) * Math.cos(xy[0]);
81
- const y = Math.cos(xy[1]) * Math.sin(xy[0]);
82
- const z = -Math.sin(xy[1]);
83
- return [x, y, z];
84
- }
85
-
86
-
87
- // *********************************************************
88
- // ***************** INTERPOLATIONS ************************
89
- // *********************************************************
90
-
91
- /**
92
- * @param {vec3} normalizedA
93
- * @param {vec3} normalizedB
94
- * @param {fraction} ratio
95
- * @returns {vec3}
96
- */
97
- const sphericalLinearInterpolation_UnitVector = (normalizedA, normalizedB, ratio) => {
98
- const theta = Math.acos(dot3(normalizedA, normalizedB));
99
- if (theta < 0.000001) return normalizedA; // CALIBRATE?
100
- const sinTheta = Math.sin(theta);
101
- const result = [
102
- (Math.sin((1.0 - ratio) * theta) * normalizedA[0] + Math.sin(ratio * theta) * normalizedB[0]) / sinTheta,
103
- (Math.sin((1.0 - ratio) * theta) * normalizedA[1] + Math.sin(ratio * theta) * normalizedB[1]) / sinTheta,
104
- (Math.sin((1.0 - ratio) * theta) * normalizedA[2] + Math.sin(ratio * theta) * normalizedB[2]) / sinTheta
105
- ];
106
- return result;
107
- }
108
-
109
-
110
- /**
111
- * @param {vec3} normalizedA
112
- * @param {vec3} normalizedB
113
- * @param {fraction} ratio
114
- * @returns
115
- */
116
- const sphericalLinearInterpolation_Mercator = (normalizedA, normalizedB, ratio) => {
117
- const unitVector = sphericalLinearInterpolation_UnitVector(normalizedA, normalizedB, ratio);
118
- const angles = cartesian3dToRadian(unitVector);
119
- return radianToMercator(angles);
120
- }
121
-
122
- /**
123
- * @param {vec4} a vec3 unit vector and length
124
- * @param {vec4} b vec3 unit vector and length
125
- * @param {fraction} ratio
126
- */
127
- const sphericalLinearInterpolation_Cartesian3d = (a, b, ratio) => {
128
- const unitVector = sphericalLinearInterpolation_UnitVector(a, b, ratio);
129
- const height = a[3] + (b[3] - a[3]) * ratio;
130
- return [unitVector[0] * height, unitVector[1] * height, unitVector[2] * height];
131
- }
132
-
133
-
134
- /**
135
- *
136
- * @param {wgs84} coordinates
137
- * @returns {vec3}
138
- */
139
- const wgs84ToUnitVector = (coordinates) => {
140
- const long = coordinates[0] * RADIANS;
141
- const lat = coordinates[1] * RADIANS;
142
-
143
- const x = Math.cos(lat) * Math.cos(long);
144
- const y = Math.cos(lat) * Math.sin(long);
145
- const z = Math.sin(lat);
146
- return [x, y, z];
147
- }
148
-
149
- /**
150
- * @param {number} long wgs84
151
- * @param {number} lat wgs84
152
- * @param {number} height
153
- * @returns {vec3} cartesian3D
154
- */
155
- const wgs84ToCartesian3d = (long, lat, height) => {
156
- const longRad = long * RADIANS;
157
- const latRad = lat * RADIANS;
158
- const x = Math.cos(latRad) * Math.cos(longRad);
159
- const y = Math.cos(latRad) * Math.sin(longRad);
160
- const z = Math.sin(latRad);
161
- const radius = WORLD_RADIUS_3D + height;
162
- return [x * radius, y * radius, z * radius];
163
- }
164
-
165
- /**
166
- * @param {number} long
167
- * @param {number} lat
168
- * @returns {vec2} mercator
169
- */
170
- const wgs84ToMercator = (long, lat) => {
171
- return [WORLD_RADIUS_MERCATOR * long * RADIANS, WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + lat * RADIANS / 2))];
172
- }
173
-
174
-
175
-
176
- /**
177
- * @param {vec2} pixelXY
178
- * @returns {vec2} long lat in radians
179
- */
180
-
181
- const pixelXYToRadians = (pixelXY) => {
182
- const long = (2.0 * pixelXY[0] - 1.0) * Math.PI;
183
- const lat = (2.0 * pixelXY[1] - 1.0) * Math.PI / 2.0;
184
- return [long, lat]
185
- }
186
-
187
- const pixelXYLenghtToUnitVectorWithHeight = (pixelXYHeight) => {
188
- const [long, lat] = pixelXYToRadians(pixelXYHeight);
189
- const radius = WORLD_RADIUS_3D + pixelXYHeight[2];
190
- return radianToCartesian3d([long, lat]).concat(radius);
191
- }
192
-
193
-
194
- const globe3Dcoordinates = (globe, height = 0) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
195
- const len = longlats.length / 2;
196
- const result = new Float32Array(len * 3 + paddingCount * 3).fill(paddingValue);
197
- for (let i = 0; i < len; i++) {
198
- const long = longlats[i * 2];
199
- const lat = longlats[i * 2 + 1];
200
- const xyz = globe.api_GetCartesian3DPoint(long, lat, height, 0);
201
- result.set(xyz, i * 3);
202
- }
203
- return result;
204
- }
205
-
206
- const globe2Dcoordinates = (globe) => (longlats, { paddingCount = 0, paddingValue = NaN }) => {
207
- const len = longlats.length / 2;
208
- const result = new Float32Array(len * 2 + paddingCount * 2).fill(paddingValue);
209
- for (let i = 0; i < len; i++) {
210
- const long = longlats[i * 2];
211
- const lat = longlats[i * 2 + 1];
212
- const xyz = globe.api_GetMercator2DPoint(long, lat);
213
- result.set(xyz, i * 2);
214
- }
215
- return result;
216
- }
217
-
218
-
219
- export {
220
- RADIANS,
221
- normalize3,
222
- dot3,
223
- length3,
224
- cartesian3dToRadian,
225
- radianToMercator,
226
- radianToCartesian3d,
227
- sphericalLinearInterpolation_UnitVector,
228
- sphericalLinearInterpolation_Mercator,
229
- sphericalLinearInterpolation_Cartesian3d,
230
- wgs84ToUnitVector,
231
- wgs84ToCartesian3d,
232
- wgs84ToMercator,
233
- pixelXYLenghtToUnitVectorWithHeight,
234
- globe3Dcoordinates,
235
- globe2Dcoordinates,
236
- }
237
-
package/Math/plane.ts DELETED
@@ -1,86 +0,0 @@
1
- import { Vec3, Plane } from "./types";
2
-
3
- import { EPSILON } from "./constants";
4
- import { vec3 } from "./vec3";
5
-
6
- const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
7
- const _1vector = /*@__PURE__*/ vec3.create(1, 1, 1);
8
-
9
-
10
- export const plane = Object.freeze({
11
- create(normal = vec3.create(), distance = 0): Plane {
12
- return {
13
- normal: vec3.clone(normal),
14
- distance: distance
15
- };
16
- },
17
-
18
-
19
- set(out: Plane, normal: Vec3, distance: number): Plane {
20
- vec3.copy(out.normal, normal);
21
- out.distance = distance;
22
- return out;
23
- },
24
-
25
-
26
- fromValues(out: Plane, nx: number, ny: number, nz: number, distance: number) {
27
- vec3.set(out.normal, nx, ny, nz);
28
- out.distance = distance;
29
- },
30
-
31
-
32
- copy(out: Plane, a: Plane): Plane {
33
- vec3.copy(out.normal, a.normal);
34
- out.distance = a.distance;
35
- return out;
36
- },
37
-
38
-
39
- clone(a: Plane): Plane {
40
- return {
41
- normal: vec3.clone(a.normal),
42
- distance: a.distance
43
- };
44
- },
45
-
46
-
47
- distanceToPoint(plane: Plane, point: Vec3): number {
48
- return vec3.dot(plane.normal, point) - plane.distance;
49
- },
50
-
51
-
52
- projectPoint(out: Vec3, plane: Plane, point: Vec3) {
53
- const distance = this.distanceToPoint(plane, point);
54
- vec3.multiplyScalar(out, plane.normal, distance);
55
- vec3.subtract(out, point, out);
56
- },
57
-
58
-
59
- equals(plane: Plane, other: Plane): boolean {
60
- return vec3.equals(plane.normal, other.normal) && Math.abs(plane.distance - other.distance) < EPSILON;
61
- },
62
-
63
-
64
-
65
- fromNormalAndCoplanarPoint(out: Plane, normal: Vec3, point: Vec3) {
66
- vec3.copy(out.normal, normal);
67
- out.distance = vec3.dot(point, normal);
68
- },
69
-
70
-
71
-
72
- fromPoints(out: Plane, a: Vec3, b: Vec3, c: Vec3) {
73
- vec3.subtract(_0vector, b, a);
74
- vec3.subtract(_1vector, c, a);
75
- vec3.cross(out.normal, _0vector, _1vector);
76
- vec3.normalize(out.normal, out.normal);
77
- out.distance = vec3.dot(out.normal, a);
78
- },
79
-
80
-
81
-
82
- getUnitSphereRadiusAngle(plane: Plane): number {
83
- return Math.acos(Math.max(Math.min(plane.distance, 1), -1));
84
- }
85
-
86
- });