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