@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.
- package/Math/angle-calculation.js +9 -11
- package/Math/arc.js +38 -41
- package/Math/bounds/line-bbox.js +79 -83
- package/Math/constants.js +4 -9
- package/Math/frustum/types.js +1 -2
- package/Math/juction/arc-plane.js +33 -36
- package/Math/juction/line-sphere.js +15 -18
- package/Math/juction/plane-plane.js +20 -23
- package/Math/line.js +42 -47
- package/Math/methods.js +69 -92
- package/Math/plane.js +33 -38
- package/Math/quaternion.js +48 -55
- package/Math/types.js +1 -2
- package/Math/utils.js +2 -4
- package/Math/vec3.js +46 -52
- package/algorithms/search-binary.js +5 -8
- package/altitude-locator/draw-subset-obj.js +8 -11
- package/altitude-locator/plugin.js +114 -133
- package/altitude-locator/types.js +1 -3
- package/arrowfield/adaptor.js +3 -7
- package/arrowfield/index.js +3 -10
- package/arrowfield/plugin.js +63 -69
- package/bearing-line/index.js +2 -8
- package/bearing-line/plugin.js +218 -248
- package/circle-line-chain/chain-list-map.js +82 -92
- package/circle-line-chain/plugin.js +147 -182
- package/circle-line-chain/util.js +1 -5
- package/compass-rose/compass-rose-padding-flat.js +111 -140
- package/compass-rose/compass-text-writer.js +63 -75
- package/compass-rose/index.js +3 -7
- package/compassrose/compassrose.js +50 -57
- package/compassrose/index.js +2 -8
- package/heatwave/index.js +3 -10
- package/heatwave/isobar/objectarraylabels.js +50 -56
- package/heatwave/isobar/plugin.js +111 -170
- package/heatwave/isobar/quadtreecontours.js +78 -96
- package/heatwave/plugins/heatwaveglobeshell.js +73 -94
- package/index.js +12 -58
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +32 -70
- package/partialrings/index.js +2 -41
- package/partialrings/plugin.js +55 -98
- package/partialrings/program.js +141 -59
- package/pin/pin-object-array.js +89 -97
- package/pin/pin-point-totem.js +21 -22
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
- package/point-heat-map/plugin-webworker.js +45 -53
- package/point-heat-map/point-to-heat-map-flow.js +46 -51
- package/point-tracks/key-methods.js +2 -5
- package/point-tracks/plugin.js +141 -170
- package/programs/arrowfield/index.js +2 -7
- package/programs/arrowfield/logic.js +172 -67
- package/programs/arrowfield/object.js +35 -43
- package/programs/data2legend/density-to-legend.js +47 -26
- package/programs/data2legend/point-to-density-texture.js +56 -34
- package/programs/float2legendwithratio/index.js +2 -8
- package/programs/float2legendwithratio/logic.js +88 -45
- package/programs/float2legendwithratio/object.js +45 -54
- package/programs/globe-util/is-globe-moved.js +10 -13
- package/programs/globeshell/index.js +2 -8
- package/programs/globeshell/wiggle/index.js +2 -8
- package/programs/globeshell/wiggle/logic.js +191 -101
- package/programs/globeshell/wiggle/object.js +35 -43
- package/programs/helpers/blender/program.js +36 -22
- package/programs/helpers/fadeaway/index.js +2 -7
- package/programs/helpers/fadeaway/logic.js +36 -17
- package/programs/helpers/fadeaway/object.js +11 -18
- package/programs/helpers/index.js +2 -8
- package/programs/index.js +9 -58
- package/programs/line-on-globe/angled-line.js +95 -39
- package/programs/line-on-globe/circle-accurate-3d.js +86 -39
- package/programs/line-on-globe/circle-accurate-flat.js +116 -64
- package/programs/line-on-globe/circle-accurate.js +113 -46
- package/programs/line-on-globe/circle.js +106 -44
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
- package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
- package/programs/line-on-globe/linestrip.js +126 -63
- package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
- package/programs/line-on-globe/to-the-surface.js +62 -35
- package/programs/line-on-globe/util.js +2 -5
- package/programs/picking/pickable-renderer.js +127 -46
- package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
- package/programs/point-on-globe/element-point-glow.js +112 -47
- package/programs/point-on-globe/square-pixel-point.js +80 -34
- package/programs/programcache.js +14 -19
- package/programs/rings/distancering/circleflatprogram.js +76 -70
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
- package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
- package/programs/rings/distancering/index.js +5 -14
- package/programs/rings/distancering/paddyflatprogram.js +87 -70
- package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
- package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
- package/programs/rings/index.js +1 -17
- package/programs/rings/partial-ring/piece-of-pie.js +144 -44
- package/programs/totems/camerauniformblock.js +65 -56
- package/programs/totems/canvas-webglobe-info.js +49 -45
- package/programs/totems/gpu-selection-uniform-block.js +45 -45
- package/programs/totems/index.js +2 -40
- package/programs/two-d/pixel-padding-for-compass.js +94 -36
- package/programs/util.js +7 -10
- package/programs/vectorfields/index.js +3 -23
- package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
- package/programs/vectorfields/logics/index.js +4 -12
- package/programs/vectorfields/logics/pixelbased.js +94 -41
- package/programs/vectorfields/logics/ubo.js +32 -32
- package/programs/vectorfields/pingpongbuffermanager.js +30 -37
- package/rangerings/enum.js +2 -5
- package/rangerings/index.js +5 -15
- package/rangerings/plugin.js +223 -286
- package/rangerings/rangeringangletext.js +122 -137
- package/rangerings/ring-account.js +53 -75
- package/shaders/fragment-toy/firework.js +55 -4
- package/shaders/fragment-toy/singularity.js +56 -5
- package/timetracks/adaptors-line-strip.js +27 -44
- package/timetracks/adaptors.js +48 -67
- package/timetracks/index.js +5 -19
- package/timetracks/plugin-line-strip.js +65 -79
- package/timetracks/plugin.js +71 -85
- package/timetracks/program-line-strip.js +297 -107
- package/timetracks/program.js +421 -118
- package/timetracks/programpoint-line-strip.js +98 -48
- package/timetracks/programpoint.js +91 -48
- package/util/account/bufferoffsetmanager.js +72 -98
- package/util/account/index.js +3 -23
- package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
- package/util/account/single-attribute-buffer-management/index.js +4 -9
- package/util/account/single-attribute-buffer-management/object-store.js +29 -34
- package/util/account/single-attribute-buffer-management/types.js +1 -2
- package/util/account/util.js +2 -8
- package/util/algorithms/search-binary.js +5 -8
- package/util/check/get.js +5 -9
- package/util/check/typecheck.js +13 -24
- package/util/geometry/index.js +10 -18
- package/util/gl-util/buffer/attribute-loader.js +10 -26
- package/util/gl-util/buffer/index.js +2 -5
- package/util/gl-util/draw-options/methods.js +10 -15
- package/util/gl-util/uniform-block/manager.js +69 -72
- package/util/heatwavedatamanager/datamanager.js +56 -119
- package/util/heatwavedatamanager/index.js +3 -10
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
- package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
- package/util/index.js +13 -57
- package/util/interpolation/timetrack/index.js +2 -5
- package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
- package/util/interpolation/timetrack/web-worker-str.js +180 -5
- package/util/interpolation/timetrack/web-worker.js +4 -6
- package/util/jshelpers/data-filler.js +8 -11
- package/util/jshelpers/equality.js +1 -3
- package/util/jshelpers/index.js +2 -37
- package/util/jshelpers/timefilters.js +8 -10
- package/util/picking/fence.js +8 -11
- package/util/picking/picker-displayer.js +49 -58
- package/util/programs/draw-texture-on-canvas.js +41 -26
- package/util/programs/index.js +1 -17
- package/util/programs/shapesonglobe.js +104 -68
- package/util/programs/supersampletotextures.js +45 -43
- package/util/programs/texturetoglobe.js +99 -52
- package/util/shaderfunctions/geometrytransformations.js +323 -35
- package/util/shaderfunctions/index.js +2 -18
- package/util/shaderfunctions/nodata.js +8 -5
- package/util/shaderfunctions/noisefunctions.js +40 -12
- package/util/surface-line-data/arcs-to-cuts.js +20 -23
- package/util/webglobe/gldefaultstates.js +1 -4
- package/util/webglobe/index.js +2 -18
- package/util/webglobe/rasteroverlay.js +36 -41
- package/util/webglobjectbuilders.js +70 -93
- package/util/webglobjectbuilders1.js +63 -82
- package/waveparticles/adaptor.js +7 -10
- package/waveparticles/index.js +3 -10
- package/waveparticles/plugin.js +82 -90
- package/wind/imagetovectorfieldandmagnitude.js +16 -19
- package/wind/index.js +5 -14
- package/wind/plugin.js +454 -291
- package/wind/vectorfieldimage.js +6 -8
- package/write-text/attached-text-writer.js +48 -54
- package/write-text/context-text.js +52 -63
- package/write-text/context-text3.js +71 -80
- package/write-text/index.js +1 -5
package/Math/line.js
CHANGED
|
@@ -1,58 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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:
|
|
9
|
+
origin: vec3.clone(origin),
|
|
15
10
|
direction: direction_
|
|
16
11
|
};
|
|
17
12
|
},
|
|
18
|
-
set
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
set(out, origin, direction) {
|
|
14
|
+
vec3.copy(out.origin, origin);
|
|
15
|
+
vec3.copy(out.direction, direction);
|
|
21
16
|
},
|
|
22
|
-
copy
|
|
23
|
-
out.origin =
|
|
24
|
-
out.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
|
|
21
|
+
clone(a) {
|
|
27
22
|
return {
|
|
28
|
-
origin:
|
|
29
|
-
direction:
|
|
23
|
+
origin: vec3.clone(a.origin),
|
|
24
|
+
direction: vec3.clone(a.direction)
|
|
30
25
|
};
|
|
31
26
|
},
|
|
32
|
-
fromTwoPoints
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
at
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
closestPoint
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
contains
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return
|
|
52
|
-
},
|
|
53
|
-
applyQuaternion
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
-
exports.RADIANS = RADIANS;
|
|
12
|
+
const RADIANS = Math.PI / 180;
|
|
17
13
|
/**
|
|
18
14
|
* @param {vec3} a
|
|
19
15
|
* @returns {vec3}
|
|
20
16
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
|
|
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
|
-
|
|
65
|
-
return [
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
89
|
-
|
|
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
|
-
|
|
93
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
160
|
-
return [
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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:
|
|
8
|
+
normal: vec3.clone(normal),
|
|
14
9
|
distance: distance
|
|
15
10
|
};
|
|
16
11
|
},
|
|
17
|
-
set
|
|
18
|
-
|
|
12
|
+
set(out, normal, distance) {
|
|
13
|
+
vec3.copy(out.normal, normal);
|
|
19
14
|
out.distance = distance;
|
|
20
15
|
return out;
|
|
21
16
|
},
|
|
22
|
-
fromValues
|
|
23
|
-
|
|
17
|
+
fromValues(out, nx, ny, nz, distance) {
|
|
18
|
+
vec3.set(out.normal, nx, ny, nz);
|
|
24
19
|
out.distance = distance;
|
|
25
20
|
},
|
|
26
|
-
copy
|
|
27
|
-
|
|
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
|
|
26
|
+
clone(a) {
|
|
32
27
|
return {
|
|
33
|
-
normal:
|
|
28
|
+
normal: vec3.clone(a.normal),
|
|
34
29
|
distance: a.distance
|
|
35
30
|
};
|
|
36
31
|
},
|
|
37
|
-
distanceToPoint
|
|
38
|
-
return
|
|
32
|
+
distanceToPoint(plane, point) {
|
|
33
|
+
return vec3.dot(plane.normal, point) - plane.distance;
|
|
39
34
|
},
|
|
40
|
-
projectPoint
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
46
|
-
return
|
|
40
|
+
equals(plane, other) {
|
|
41
|
+
return vec3.equals(plane.normal, other.normal) && Math.abs(plane.distance - other.distance) < EPSILON;
|
|
47
42
|
},
|
|
48
|
-
fromNormalAndCoplanarPoint
|
|
49
|
-
|
|
50
|
-
out.distance =
|
|
43
|
+
fromNormalAndCoplanarPoint(out, normal, point) {
|
|
44
|
+
vec3.copy(out.normal, normal);
|
|
45
|
+
out.distance = vec3.dot(point, normal);
|
|
51
46
|
},
|
|
52
|
-
fromPoints
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
out.distance =
|
|
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
|
|
54
|
+
getUnitSphereRadiusAngle(plane) {
|
|
60
55
|
return Math.acos(Math.max(Math.min(plane.distance, 1), -1));
|
|
61
56
|
}
|
|
62
57
|
});
|
package/Math/quaternion.js
CHANGED
|
@@ -1,80 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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
|
|
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
|
|
19
|
+
clone(a) {
|
|
27
20
|
return [a[0], a[1], a[2], a[3]];
|
|
28
21
|
},
|
|
29
|
-
multiply
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
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
|
|
55
|
+
length(a) {
|
|
63
56
|
return Math.sqrt(this.lengthSquared(a));
|
|
64
57
|
},
|
|
65
|
-
normalize
|
|
66
|
-
|
|
67
|
-
if (len <
|
|
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
|
-
|
|
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
|
|
76
|
-
|
|
77
|
-
if (d <
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
93
|
+
conjugate(out, a) {
|
|
101
94
|
this.set(out, -a[0], -a[1], -a[2], a[3]);
|
|
102
95
|
},
|
|
103
|
-
fromAxisAngle
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/Math/utils.js
CHANGED