-
Notifications
You must be signed in to change notification settings - Fork 1
/
Sphere.d.ts
147 lines (147 loc) · 5.18 KB
/
Sphere.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { Box3 } from './Box3';
import { Vector3 } from './Vector3';
import type { Matrix4 } from './Matrix4';
import { Plane } from './Plane';
import { Base } from './Base';
/**
* A sphere defined by a center and radius.
*/
export declare class Sphere extends Base {
/**
* A Vector3 defining the center of the sphere.
* Default is (0, 0, 0).
*/
center: Vector3;
/**
* The radius of the sphere. Default is -1.
*/
radius: number;
/**
* Creates a new Sphere.
* @param center - center of the sphere. Default is a Vector3 at (0, 0, 0).
* @param radius - radius of the sphere. Default is -1.
*/
constructor(center?: Vector3, radius?: number);
/**
* Read-only flag to check if a given object is of type Sphere.
*/
get isSphere(): boolean;
/**
* Sets the center and radius properties of this sphere.
* Please note that this method only copies the values from the given center.
* @param center - Center of the sphere.
* @param radius - Radius of the sphere.
* @returns This instance
*/
set(center: Vector3, radius: number): this;
/**
* Computes the minimum bounding sphere for an array of points.
* If optionalCenteris given, it is used as the sphere's center.
* Otherwise, the center of the axis-aligned bounding box
* encompassing points is calculated.
* @param points - an Array of Vector3 positions.
* @param optionalCenter - Optional Vector3 position for the sphere's center.
* @returns This instance.
*/
setFromPoints(points: Vector3[], optionalCenter?: Vector3): this;
/**
* Copies the values of the passed sphere's center and radius properties to this sphere.
* @param sphere - The sphere to copy.
* @returns This instance.
*/
copy(sphere: Sphere): this;
/**
* Checks to see if the sphere is empty (the radius set to a negative number).
* Spheres with a radius of 0 contain only their center point and are
* not considered to be empty.
* @returns True if empty.
*/
isEmpty(): boolean;
/**
* Makes the sphere empty by setting center to (0, 0, 0) and radius to -1.
* @returns This instance.
*/
makeEmpty(): this;
/**
* Checks to see if the sphere contains the provided point inclusive of the surface of the sphere.
* @param point - The Vector3 to be checked
* @returns True if point is contained by this sphere.
*/
containsPoint(point: Vector3): boolean;
/**
* Computes the closest distance from the boundary of the sphere to a point.
* If the sphere contains the point, the distance will be negative.
* @param point - The point to compute the distance to.
* @returns The distance to the point.
*/
distanceToPoint(point: Vector3): number;
/**
* Checks to see if two spheres intersect.
* @param sphere - Sphere to check for intersection against.
* @returns True if the spheres intersect.
*/
intersectsSphere(sphere: Sphere): boolean;
/**
* Determines whether or not this sphere intersects a given box.
* @param box - Box3 to check for intersection against.
* @returns True if the sphere and box intersect.
*/
intersectsBox(box: Box3): boolean;
/**
* Determines whether or not this sphere intersects a given plane.
* @param plane - Plane to check for intersection against.
* @returns True if this sphere and plane intersect.
*/
intersectsPlane(plane: Plane): boolean;
/**
* Clamps a point within the sphere. If the point is outside the sphere,
* it will clamp it to the closest point on the edge of the sphere.
* Points already inside the sphere will not be affected.
* @param point - Vector3 The point to clamp.
* @param target - The result will be copied into this Vector3.
* @returns The clamped point.
*/
clampPoint(point: Vector3, target?: Vector3): Vector3;
/**
* Copmute a minimum bounding box for the sphere.
* @param target — the result will be copied into this Box3.
* @returns The bounding box.
*/
getBoundingBox(target?: Box3): Box3;
/**
* Transforms this sphere with the provided Matrix4.
* @param matrix - the Matrix4 to apply
* @returns This instance.
*/
applyMatrix4(matrix: Matrix4): this;
/**
* Translate the sphere's center by the provided offset Vector3.
* @param offset - The x, y, z offsets
* @returns This instance.
*/
translate(offset: Vector3): this;
/**
* Expands the boundaries of this sphere to include point.
* @param point - Vector3 that should be included in the sphere.
* @returns This instance.
*/
expandByPoint(point: Vector3): this;
/**
* Expands this sphere to enclose both the original sphere and the given sphere
* [based on algorithm](https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769)
* @param sphere - Bounding sphere that will be unioned with this sphere.
* @returns This instance.
*/
union(sphere: Sphere): this;
/**
* Checks to see if the two spheres' centers and radii are equal.
* @param sphere - The sphere to compare for equality.
* @returns True if the 2 spheres are equal.
*/
equals(sphere: Sphere): boolean;
/**
* Create new sphere with the same center and radius as this one.
* @returns The new sphere.
*/
clone(): Sphere;
}