@pirireis/webglobeplugins 0.9.1 → 0.9.2
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/arc.ts +74 -245
- package/Math/constants.ts +4 -1
- package/Math/frustum/camera.ts +32 -0
- package/Math/frustum/from-globeinfo.ts +63 -0
- package/Math/frustum/types.ts +11 -0
- package/Math/globe-util/horizon-plane.ts +137 -0
- package/Math/juction/arc-plane.ts +90 -0
- package/Math/juction/line-sphere.ts +30 -0
- package/Math/juction/plane-plane.ts +66 -0
- package/Math/line.ts +70 -0
- package/Math/methods.js +29 -1
- package/Math/plane.ts +57 -138
- package/Math/quaternion.ts +108 -144
- package/Math/types.ts +39 -30
- package/Math/vec3.ts +155 -0
- package/altitude-locator/plugin.js +1 -1
- package/bearing-line/plugin.js +1 -1
- package/circle-line-chain/plugin.js +1 -1
- package/globe-types.ts +13 -0
- package/heatwave/plugins/heatwaveglobeshell.js +5 -9
- package/index.js +3 -0
- package/package.json +1 -1
- package/programs/interface.ts +7 -0
- package/programs/line-on-globe/circle-accurate-3d.js +1 -1
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
- package/programs/line-on-globe/lines-color-instanced-flat.js +1 -1
- package/programs/line-on-globe/linestrip.ts +228 -0
- package/programs/line-on-globe/naive-accurate-flexible.js +1 -1
- package/programs/line-on-globe/to-the-surface.js +1 -1
- package/programs/picking/pickable-renderer.js +1 -1
- package/programs/point-on-globe/element-globe-surface-glow.js +1 -1
- package/programs/point-on-globe/element-point-glow.js +1 -1
- package/programs/totems/camerauniformblock.js +24 -1
- package/shape-on-terrain/arc/naive/plugin.ts +304 -0
- package/tests/Math/junction/arc-plane.test.ts +129 -0
- package/tests/Math/junction/plane-plane.test.ts +82 -0
- package/tests/Math/plane.test.ts +30 -32
- package/tests/Math/vec3.test.ts +14 -0
- package/timetracks/plugin-line-strip.js +3 -1
- package/{types.js → types.ts} +2 -1
- package/util/account/{index.js → index.ts} +1 -2
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +0 -31
- package/util/account/single-attribute-buffer-management/index.ts +13 -0
- package/util/gl-util/buffer/{integrate-buffer.js → attribute-loader.ts} +17 -6
- package/util/gl-util/buffer/index.ts +6 -0
- package/util/gl-util/buffer/types.ts +13 -0
- package/util/gl-util/draw-options/methods.js +4 -4
- package/util/gl-util/draw-options/{types.js → types.ts} +10 -0
- package/util/gl-util/uniform-block/{manager.js → manager.ts} +24 -13
- package/util/gl-util/uniform-block/types.ts +27 -0
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +17 -17
- package/waveparticles/plugin.js +3 -0
- package/wind/plugin.js +6 -19
- package/Math/methodology/arc-part-on-screen.ts +0 -47
- package/Math/ray.ts +0 -101
- package/Math/vector3d.ts +0 -241
- package/shape-on-terrain/tree-search.js +0 -0
- package/surface-cover-shapes/arc/naive/data-manager.ts +0 -0
- package/surface-cover-shapes/arc/naive/plugin.ts +0 -0
- package/tests/Math/arc.test.ts +0 -112
- package/tests/Math/quaternion.test.ts +0 -98
- package/tests/Math/ray-plane.test.ts +0 -176
- package/tests/Math/vector3d.test.ts +0 -104
- package/util/account/single-attribute-buffer-management/index.js +0 -4
- package/util/gl-util/uniform-block/types.js +0 -7
- /package/{shape-on-terrain/intersection.js → Math/matrix4.ts} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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/methods.js
CHANGED
|
@@ -190,6 +190,32 @@ const pixelXYLenghtToUnitVectorWithHeight = (pixelXYHeight) => {
|
|
|
190
190
|
return radianToCartesian3d([long, lat]).concat(radius);
|
|
191
191
|
}
|
|
192
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
|
+
|
|
193
219
|
export {
|
|
194
220
|
RADIANS,
|
|
195
221
|
normalize3,
|
|
@@ -204,6 +230,8 @@ export {
|
|
|
204
230
|
wgs84ToUnitVector,
|
|
205
231
|
wgs84ToCartesian3d,
|
|
206
232
|
wgs84ToMercator,
|
|
207
|
-
pixelXYLenghtToUnitVectorWithHeight
|
|
233
|
+
pixelXYLenghtToUnitVectorWithHeight,
|
|
234
|
+
globe3Dcoordinates,
|
|
235
|
+
globe2Dcoordinates,
|
|
208
236
|
}
|
|
209
237
|
|
package/Math/plane.ts
CHANGED
|
@@ -1,167 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WORLD_RADIUS_MERCATOR } from "./constants";
|
|
3
|
-
import { Radians, Meter } from './types';
|
|
4
|
-
import { Ray } from './ray';
|
|
1
|
+
import { Vec3, Plane } from "./types";
|
|
5
2
|
|
|
3
|
+
import { EPSILON } from "./constants";
|
|
4
|
+
import { vec3 } from "./vec3";
|
|
6
5
|
|
|
7
|
-
const
|
|
6
|
+
const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
|
|
7
|
+
const _1vector = /*@__PURE__*/ vec3.create(1, 1, 1);
|
|
8
8
|
|
|
9
|
-
const _0vector = /*@__PURE__*/ new Vector3D(0, 0, 0);
|
|
10
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
|
+
},
|
|
11
17
|
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
set(out: Plane, normal: Vec3, distance: number): Plane {
|
|
20
|
+
vec3.copy(out.normal, normal);
|
|
21
|
+
out.distance = distance;
|
|
22
|
+
return out;
|
|
23
|
+
},
|
|
16
24
|
|
|
17
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
|
+
},
|
|
18
30
|
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
set(normal: Vector3D, constant: number): Plane {
|
|
27
|
-
this.normal.copy(normal);
|
|
28
|
-
this.constant = constant;
|
|
29
|
-
return this;
|
|
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
|
+
},
|
|
32
37
|
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
clone(a: Plane): Plane {
|
|
40
|
+
return {
|
|
41
|
+
normal: vec3.clone(a.normal),
|
|
42
|
+
distance: a.distance
|
|
43
|
+
};
|
|
44
|
+
},
|
|
39
45
|
|
|
40
46
|
|
|
47
|
+
distanceToPoint(plane: Plane, point: Vec3): number {
|
|
48
|
+
return vec3.dot(plane.normal, point) - plane.distance;
|
|
49
|
+
},
|
|
41
50
|
|
|
42
|
-
clone(): Plane {
|
|
43
|
-
return new Plane(this.normal.clone(), this.constant);
|
|
44
|
-
}
|
|
45
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
|
+
},
|
|
46
57
|
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
}
|
|
59
|
+
equals(plane: Plane, other: Plane): boolean {
|
|
60
|
+
return vec3.equals(plane.normal, other.normal) && Math.abs(plane.distance - other.distance) < EPSILON;
|
|
61
|
+
},
|
|
51
62
|
|
|
52
63
|
|
|
53
64
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
65
|
+
fromNormalAndCoplanarPoint(out: Plane, normal: Vec3, point: Vec3) {
|
|
66
|
+
vec3.copy(out.normal, normal);
|
|
67
|
+
out.distance = vec3.dot(point, normal);
|
|
68
|
+
},
|
|
59
69
|
|
|
60
70
|
|
|
61
|
-
equals(other: Plane): boolean { // assumes normals are normalized
|
|
62
|
-
return this.normal.equals(other.normal) && Math.abs(this.constant - other.constant) < VEC_EPSILON;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
equalsReverseOriantation(other: Plane): boolean { // assumes normals are normalized
|
|
67
|
-
_0vector.copy(this.normal).negate();
|
|
68
|
-
return _0vector.equals(other.normal) && Math.abs(this.constant + other.constant) < VEC_EPSILON;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
setFromNormalAndPoint(normal: Vector3D, point: Vector3D): Plane {
|
|
75
|
-
this.normal.copy(normal);
|
|
76
|
-
this.constant = point.dot(normal);
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
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
|
+
},
|
|
80
79
|
|
|
81
80
|
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
setFromPoints(p1: Vector3D, p2: Vector3D, p3: Vector3D): Plane {
|
|
90
|
-
this.normal = p2.clone().subtract(p1).cross(p3.subtract(p1)).normalize();
|
|
91
|
-
this.constant = p1.dot(this.normal);
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
static fromPoints(p1: Vector3D, p2: Vector3D, p3: Vector3D): Plane {
|
|
99
|
-
const normal = p2.subtract(p1).cross(p3.subtract(p1)).normalize();
|
|
100
|
-
const constant = p1.dot(normal);
|
|
101
|
-
return new Plane(normal, constant);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
static fromGlobeLookInfo(centerLongitude: Radians, centerLatitude: Radians, distance: Meter, target: Plane): boolean {
|
|
108
|
-
const radiansAngle = Math.PI * distance / WORLD_RADIUS_MERCATOR;
|
|
109
|
-
target.normal.setFromLonLat(centerLongitude, centerLatitude).normalize();
|
|
110
|
-
target.constant = Math.cos(radiansAngle);
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
intersectionPlane(other: Plane): { origin: Vector3D, direction: Vector3D } | Plane | null {
|
|
117
|
-
if (this.normal.equals(other.normal)) {
|
|
118
|
-
if (Math.abs(this.constant - other.constant) < VEC_EPSILON) {
|
|
119
|
-
console.log('same orientation', this, other);
|
|
120
|
-
return this.clone(); // planes are equal
|
|
121
|
-
}
|
|
122
|
-
console.log('same orientation null', this, other);
|
|
123
|
-
return null; // planes are parallel and not equal
|
|
124
|
-
}
|
|
125
|
-
// opposite orientation
|
|
126
|
-
if (_0vector.copy(this.normal).negate().equals(other.normal)) {
|
|
127
|
-
if (Math.abs(this.constant + other.constant) < VEC_EPSILON) {
|
|
128
|
-
console.log('opposite orientation', this, other);
|
|
129
|
-
return this.clone(); // planes are equal
|
|
130
|
-
}
|
|
131
|
-
console.log('opposite orientation null', this, other);
|
|
132
|
-
return null; // planes are parallel and not equal
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const nA = this.normal;
|
|
137
|
-
const nB = other.normal;
|
|
138
|
-
const dA = this.constant;
|
|
139
|
-
const dB = other.constant;
|
|
140
|
-
|
|
141
|
-
const direction = nA.clone().cross(nB).normalize();
|
|
142
|
-
|
|
143
|
-
// find a point on the line of intersection
|
|
144
|
-
const denomXY = nA.x * nB.y - nA.y * nB.x;
|
|
145
|
-
|
|
146
|
-
if (Math.abs(denomXY) > VEC_EPSILON) {
|
|
147
|
-
const x = (dA * nB.y - dB * nA.y) / denomXY;
|
|
148
|
-
const y = (dB * nA.x - dA * nB.x) / denomXY;
|
|
149
|
-
return { origin: new Vector3D(x, y, 0), direction };
|
|
150
|
-
}
|
|
151
|
-
const denomXZ = nA.x * nB.z - nA.z * nB.x;
|
|
152
|
-
if (Math.abs(denomXZ) > VEC_EPSILON) {
|
|
153
|
-
const x = (dA * nB.z - dB * nA.z) / denomXZ;
|
|
154
|
-
const z = (dB * nA.x - dA * nB.x) / denomXZ;
|
|
155
|
-
return { origin: new Vector3D(x, 0, z), direction };
|
|
156
|
-
}
|
|
157
|
-
const denomYZ = nA.y * nB.z - nA.z * nB.y;
|
|
158
|
-
if (Math.abs(denomYZ) > VEC_EPSILON) {
|
|
159
|
-
const y = (dA * nB.z - dB * nA.z) / denomYZ;
|
|
160
|
-
const z = (dB * nA.y - dA * nB.y) / denomYZ;
|
|
161
|
-
return { origin: new Vector3D(0, y, z), direction };
|
|
162
|
-
}
|
|
163
|
-
console.log('intersectionPlane null', this, other);
|
|
164
|
-
return null; // planes are parallel and not equal
|
|
82
|
+
getUnitSphereRadiusAngle(plane: Plane): number {
|
|
83
|
+
return Math.acos(Math.max(Math.min(plane.distance, 1), -1));
|
|
165
84
|
}
|
|
166
85
|
|
|
167
|
-
}
|
|
86
|
+
});
|