@galacean/engine-math 1.6.7 → 1.6.8

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.
@@ -1,103 +0,0 @@
1
- import { BoundingSphere } from "./BoundingSphere";
2
- import { IClone } from "./IClone";
3
- import { ICopy } from "./ICopy";
4
- import { Matrix } from "./Matrix";
5
- import { Vector3, Vector3Like } from "./Vector3";
6
- /**
7
- * Axis Aligned Bound Box (AABB).
8
- */
9
- export declare class BoundingBox implements IClone<BoundingBox>, ICopy<BoundingBox, BoundingBox> {
10
- private static _tempVec30;
11
- private static _tempVec31;
12
- /**
13
- * Calculate a bounding box from the center point and the extent of the bounding box.
14
- * @param center - The center point
15
- * @param extent - The extent of the bounding box
16
- * @param out - The calculated bounding box
17
- */
18
- static fromCenterAndExtent(center: Vector3, extent: Vector3, out: BoundingBox): void;
19
- /**
20
- * Calculate a bounding box that fully contains the given points.
21
- * @param points - The given points
22
- * @param out - The calculated bounding box
23
- */
24
- static fromPoints(points: Vector3[], out: BoundingBox): void;
25
- /**
26
- * Calculate a bounding box from a given sphere.
27
- * @param sphere - The given sphere
28
- * @param out - The calculated bounding box
29
- */
30
- static fromSphere(sphere: BoundingSphere, out: BoundingBox): void;
31
- /**
32
- * Transform a bounding box.
33
- * @param source - The original bounding box
34
- * @param matrix - The transform to apply to the bounding box
35
- * @param out - The transformed bounding box
36
- */
37
- static transform(source: BoundingBox, matrix: Matrix, out: BoundingBox): void;
38
- /**
39
- * Calculate a bounding box that is as large as the total combined area of the two specified boxes.
40
- * @param box1 - The first box to merge
41
- * @param box2 - The second box to merge
42
- * @param out - The merged bounding box
43
- * @returns The merged bounding box
44
- */
45
- static merge(box1: BoundingBox, box2: BoundingBox, out: BoundingBox): BoundingBox;
46
- /** The minimum point of the box. */
47
- readonly min: Vector3;
48
- /** The maximum point of the box. */
49
- readonly max: Vector3;
50
- /**
51
- * Constructor of BoundingBox.
52
- * @param min - The minimum point of the box
53
- * @param max - The maximum point of the box
54
- */
55
- constructor(min?: Vector3, max?: Vector3);
56
- /**
57
- * Get the center point of this bounding box.
58
- * @param out - The center point of this bounding box
59
- * @returns The center point of this bounding box
60
- */
61
- getCenter(out: Vector3): Vector3;
62
- /**
63
- * Get the extent of this bounding box.
64
- * @param out - The extent of this bounding box
65
- * @returns The extent of this bounding box
66
- */
67
- getExtent(out: Vector3): Vector3;
68
- /**
69
- * Get the eight corners of this bounding box.
70
- * @param out - An array of points representing the eight corners of this bounding box
71
- * @returns An array of points representing the eight corners of this bounding box
72
- */
73
- getCorners(out?: Vector3[]): Vector3[];
74
- /**
75
- * Transform a bounding box.
76
- * @param matrix - The transform to apply to the bounding box
77
- * @returns The transformed bounding box
78
- */
79
- transform(matrix: Matrix): BoundingBox;
80
- /**
81
- * Creates a clone of this box.
82
- * @returns A clone of this box
83
- */
84
- clone(): BoundingBox;
85
- /**
86
- * Copy this bounding box from the specified box.
87
- * @param source - The specified box
88
- * @returns This bounding box
89
- */
90
- copyFrom(source: BoundingBox): BoundingBox;
91
- /**
92
- * Serialize this bounding box to a JSON representation.
93
- * @returns A JSON representation of this bounding box
94
- */
95
- toJSON(): BoundingBoxLike;
96
- }
97
- interface BoundingBoxLike {
98
- /** {@inheritDoc BoundingBox.min} */
99
- min: Vector3Like;
100
- /** {@inheritDoc BoundingBox.max} */
101
- max: Vector3Like;
102
- }
103
- export {};
@@ -1,63 +0,0 @@
1
- import { BoundingBox } from "./BoundingBox";
2
- import { BoundingSphere } from "./BoundingSphere";
3
- import { FrustumFace } from "./enums/FrustumFace";
4
- import { IClone } from "./IClone";
5
- import { ICopy } from "./ICopy";
6
- import { Matrix } from "./Matrix";
7
- import { Plane } from "./Plane";
8
- /**
9
- * A bounding frustum.
10
- */
11
- export declare class BoundingFrustum implements IClone<BoundingFrustum>, ICopy<BoundingFrustum, BoundingFrustum> {
12
- /** The near plane of this frustum. */
13
- near: Plane;
14
- /** The far plane of this frustum. */
15
- far: Plane;
16
- /** The left plane of this frustum. */
17
- left: Plane;
18
- /** The right plane of this frustum. */
19
- right: Plane;
20
- /** The bottom plane of this frustum. */
21
- bottom: Plane;
22
- /** The top plane of this frustum. */
23
- top: Plane;
24
- /**
25
- * Constructor of BoundingFrustum.
26
- * @param matrix - The view-projection matrix
27
- */
28
- constructor(matrix?: Matrix);
29
- /**
30
- * Get the plane by the given frustum face.
31
- * @param face - The frustum face
32
- * @returns The plane get
33
- */
34
- getPlane(face: FrustumFace): Plane;
35
- /**
36
- * Update all planes from the given matrix.
37
- * @param matrix - The given view-projection matrix
38
- */
39
- calculateFromMatrix(matrix: Matrix): void;
40
- /**
41
- * Get whether or not a specified bounding box intersects with this frustum (Contains or Intersects).
42
- * @param box - The box for testing
43
- * @returns True if bounding box intersects with this frustum, false otherwise
44
- */
45
- intersectsBox(box: BoundingBox): boolean;
46
- /**
47
- * Get whether or not a specified bounding sphere intersects with this frustum (Contains or Intersects).
48
- * @param sphere - The sphere for testing
49
- * @returns True if bounding sphere intersects with this frustum, false otherwise
50
- */
51
- intersectsSphere(sphere: BoundingSphere): boolean;
52
- /**
53
- * Creates a clone of this frustum.
54
- * @returns A clone of this frustum
55
- */
56
- clone(): BoundingFrustum;
57
- /**
58
- * Copy this frustum from the specified frustum.
59
- * @param source - The specified frustum
60
- * @returns This frustum
61
- */
62
- copyFrom(source: BoundingFrustum): BoundingFrustum;
63
- }
@@ -1,43 +0,0 @@
1
- import { BoundingBox } from "./BoundingBox";
2
- import { IClone } from "./IClone";
3
- import { ICopy } from "./ICopy";
4
- import { Vector3 } from "./Vector3";
5
- /**
6
- * A bounding sphere.
7
- * */
8
- export declare class BoundingSphere implements IClone<BoundingSphere>, ICopy<BoundingSphere, BoundingSphere> {
9
- private static _tempVec30;
10
- /**
11
- * Calculate a bounding sphere that fully contains the given points.
12
- * @param points - The given points
13
- * @param out - The calculated bounding sphere
14
- */
15
- static fromPoints(points: Vector3[], out: BoundingSphere): void;
16
- /**
17
- * Calculate a bounding sphere from a given box.
18
- * @param box - The given box
19
- * @param out - The calculated bounding sphere
20
- */
21
- static fromBox(box: BoundingBox, out: BoundingSphere): void;
22
- /** The center point of the sphere. */
23
- readonly center: Vector3;
24
- /** The radius of the sphere. */
25
- radius: number;
26
- /**
27
- * Constructor of BoundingSphere.
28
- * @param center - The center point of the sphere
29
- * @param radius - The radius of the sphere
30
- */
31
- constructor(center?: Vector3, radius?: number);
32
- /**
33
- * Creates a clone of this sphere.
34
- * @returns A clone of this sphere
35
- */
36
- clone(): BoundingSphere;
37
- /**
38
- * Copy this sphere from the specified sphere.
39
- * @param source - The specified sphere
40
- * @returns This sphere
41
- */
42
- copyFrom(source: BoundingSphere): BoundingSphere;
43
- }
@@ -1,122 +0,0 @@
1
- import { BoundingBox } from "./BoundingBox";
2
- import { BoundingFrustum } from "./BoundingFrustum";
3
- import { BoundingSphere } from "./BoundingSphere";
4
- import { ContainmentType } from "./enums/ContainmentType";
5
- import { PlaneIntersectionType } from "./enums/PlaneIntersectionType";
6
- import { Plane } from "./Plane";
7
- import { Ray } from "./Ray";
8
- import { Vector3 } from "./Vector3";
9
- /**
10
- * Contains static methods to help in determining intersections, containment, etc.
11
- */
12
- export declare class CollisionUtil {
13
- private static _tempVec30;
14
- private static _tempVec31;
15
- private static _tempVec32;
16
- /**
17
- * Calculate the intersection point of three plane.
18
- * @param p1 - Plane 1
19
- * @param p2 - Plane 2
20
- * @param p3 - Plane 3
21
- * @param out - intersection point
22
- */
23
- static intersectionPointThreePlanes(p1: Plane, p2: Plane, p3: Plane, out: Vector3): void;
24
- /**
25
- * Calculate the distance from a point to a plane.
26
- * @param plane - The plane
27
- * @param point - The point
28
- * @returns The distance from a point to a plane
29
- */
30
- static distancePlaneAndPoint(plane: Plane, point: Vector3): number;
31
- /**
32
- * Get the intersection type between a plane and a point.
33
- * @param plane - The plane
34
- * @param point - The point
35
- * @returns The intersection type
36
- */
37
- static intersectsPlaneAndPoint(plane: Plane, point: Vector3): PlaneIntersectionType;
38
- /**
39
- * Get the intersection type between a plane and a box (AABB).
40
- * @param plane - The plane
41
- * @param box - The box
42
- * @returns The intersection type
43
- */
44
- static intersectsPlaneAndBox(plane: Plane, box: BoundingBox): PlaneIntersectionType;
45
- /**
46
- * Get the intersection type between a plane and a sphere.
47
- * @param plane - The plane
48
- * @param sphere - The sphere
49
- * @returns The intersection type
50
- */
51
- static intersectsPlaneAndSphere(plane: Plane, sphere: BoundingSphere): PlaneIntersectionType;
52
- /**
53
- * Get the intersection type between a ray and a plane.
54
- * @param ray - The ray
55
- * @param plane - The plane
56
- * @returns The distance from ray to plane if intersecting, -1 otherwise
57
- */
58
- static intersectsRayAndPlane(ray: Ray, plane: Plane): number;
59
- /**
60
- * Get the intersection type between a ray and a box (AABB).
61
- * @param ray - The ray
62
- * @param box - The box
63
- * @returns The distance from ray to box if intersecting, -1 otherwise
64
- */
65
- static intersectsRayAndBox(ray: Ray, box: BoundingBox): number;
66
- /**
67
- * Get the intersection type between a ray and a sphere.
68
- * @param ray - The ray
69
- * @param sphere - The sphere
70
- * @returns The distance from ray to sphere if intersecting, -1 otherwise
71
- */
72
- static intersectsRayAndSphere(ray: Ray, sphere: BoundingSphere): number;
73
- /**
74
- * Check whether the boxes intersect.
75
- * @param boxA - The first box to check
76
- * @param boxB - The second box to check
77
- * @returns True if the boxes intersect, false otherwise
78
- */
79
- static intersectsBoxAndBox(boxA: BoundingBox, boxB: BoundingBox): boolean;
80
- /**
81
- * Check whether the spheres intersect.
82
- * @param sphereA - The first sphere to check
83
- * @param sphereB - The second sphere to check
84
- * @returns True if the spheres intersect, false otherwise
85
- */
86
- static intersectsSphereAndSphere(sphereA: BoundingSphere, sphereB: BoundingSphere): boolean;
87
- /**
88
- * Check whether the sphere and the box intersect.
89
- * @param sphere - The sphere to check
90
- * @param box - The box to check
91
- * @returns True if the sphere and the box intersect, false otherwise
92
- */
93
- static intersectsSphereAndBox(sphere: BoundingSphere, box: BoundingBox): boolean;
94
- /**
95
- * Get whether or not a specified bounding box intersects with this frustum (Contains or Intersects).
96
- * @param frustum - The frustum
97
- * @param box - The box
98
- * @returns True if bounding box intersects with this frustum, false otherwise
99
- */
100
- static intersectsFrustumAndBox(frustum: BoundingFrustum, box: BoundingBox): boolean;
101
- /**
102
- * Get the containment type between a frustum and a point.
103
- * @param frustum - The frustum
104
- * @param point - The point
105
- * @returns The containment type
106
- */
107
- static frustumContainsPoint(frustum: BoundingFrustum, point: Vector3): ContainmentType;
108
- /**
109
- * Get the containment type between a frustum and a box (AABB).
110
- * @param frustum - The frustum
111
- * @param box - The box
112
- * @returns The containment type
113
- */
114
- static frustumContainsBox(frustum: BoundingFrustum, box: BoundingBox): ContainmentType;
115
- /**
116
- * Get the containment type between a frustum and a sphere.
117
- * @param frustum - The frustum
118
- * @param sphere - The sphere
119
- * @returns The containment type
120
- */
121
- static frustumContainsSphere(frustum: BoundingFrustum, sphere: BoundingSphere): ContainmentType;
122
- }
package/types/Color.d.ts DELETED
@@ -1,175 +0,0 @@
1
- import { IClone } from "./IClone";
2
- import { ICopy } from "./ICopy";
3
- /**
4
- * Describes a color in the from of RGBA (in order: R, G, B, A).
5
- */
6
- export declare class Color implements IClone<Color>, ICopy<ColorLike, Color> {
7
- /**
8
- * Modify a value from the sRGB space to the linear space.
9
- * @param value - The value in sRGB space
10
- * @returns The value in linear space
11
- */
12
- static sRGBToLinearSpace(value: number): number;
13
- /**
14
- * Modify a value from the linear space to the sRGB space.
15
- * @param value - The value in linear space
16
- * @returns The value in sRGB space
17
- */
18
- static linearToSRGBSpace(value: number): number;
19
- /**
20
- * Determines whether the specified colors are equals.
21
- * @param left - The first color to compare
22
- * @param right - The second color to compare
23
- * @returns True if the specified colors are equals, false otherwise
24
- */
25
- static equals(left: Color, right: Color): boolean;
26
- /**
27
- * Determines the sum of two colors.
28
- * @param left - The first color to add
29
- * @param right - The second color to add
30
- * @param out - The sum of two colors
31
- * @returns The added color
32
- */
33
- static add(left: Color, right: Color, out: Color): Color;
34
- /**
35
- * Determines the difference between two colors.
36
- * @param left - The first color to subtract
37
- * @param right - The second color to subtract
38
- * @param out - The difference between two colors
39
- */
40
- static subtract(left: Color, right: Color, out: Color): void;
41
- /**
42
- * Scale a color by the given value.
43
- * @param left - The color to scale
44
- * @param s - The amount by which to scale the color
45
- * @param out - The scaled color
46
- * @returns The scaled color
47
- */
48
- static scale(left: Color, s: number, out: Color): Color;
49
- /**
50
- * Performs a linear interpolation between two color.
51
- * @param start - The first color
52
- * @param end - The second color
53
- * @param t - The blend amount where 0 returns start and 1 end
54
- * @param out - The result of linear blending between two color
55
- */
56
- static lerp(start: Color, end: Color, t: number, out: Color): Color;
57
- /**
58
- * The red component of the color, 0~1.
59
- */
60
- get r(): number;
61
- set r(value: number);
62
- /**
63
- * The green component of the color, 0~1.
64
- */
65
- get g(): number;
66
- set g(value: number);
67
- /**
68
- * The blue component of the color, 0~1.
69
- */
70
- get b(): number;
71
- set b(value: number);
72
- /**
73
- * The alpha component of the color, 0~1.
74
- */
75
- get a(): number;
76
- set a(value: number);
77
- /**
78
- * Constructor of Color.
79
- * @param r - The red component of the color
80
- * @param g - The green component of the color
81
- * @param b - The blue component of the color
82
- * @param a - The alpha component of the color
83
- */
84
- constructor(r?: number, g?: number, b?: number, a?: number);
85
- /**
86
- * Set the value of this color.
87
- * @param r - The red component of the color
88
- * @param g - The green component of the color
89
- * @param b - The blue component of the color
90
- * @param a - The alpha component of the color
91
- * @returns This color.
92
- */
93
- set(r: number, g: number, b: number, a: number): Color;
94
- /**
95
- * Determines the sum of this color and the specified color.
96
- * @param color - The specified color
97
- * @returns The added color
98
- */
99
- add(color: Color): Color;
100
- /**
101
- * Scale this color by the given value.
102
- * @param s - The amount by which to scale the color
103
- * @returns The scaled color
104
- */
105
- scale(s: number): Color;
106
- /**
107
- * Creates a clone of this color.
108
- * @returns A clone of this color
109
- */
110
- clone(): Color;
111
- /**
112
- * Copy from color like object.
113
- * @param source - Color like object.
114
- * @returns This vector
115
- */
116
- copyFrom(source: ColorLike): Color;
117
- /**
118
- * Copy to color like object.
119
- * @param target - Color like object.
120
- * @returns This Color like object
121
- */
122
- copyTo(target: ColorLike): ColorLike;
123
- /**
124
- * Copy from array like object.
125
- * @param source - Array like object
126
- * @param offset - The start offset
127
- * @returns This color
128
- */
129
- copyFromArray(source: ArrayLike<number>, offset?: number): Color;
130
- /**
131
- * Copy the value of this color to an array.
132
- * @param out - The color
133
- * @param outOffset - The start offset
134
- */
135
- copyToArray(out: number[] | Float32Array | Float64Array, outOffset?: number): void;
136
- /**
137
- * Modify components (r, g, b) of this color from gamma space to linear space.
138
- * @param out - The color in linear space
139
- * @returns The color in linear space
140
- */
141
- toLinear(out: Color): Color;
142
- /**
143
- * Modify components (r, g, b) of this color from linear space to sRGB space.
144
- * @param out - The color in sRGB space
145
- * @returns The color in sRGB space
146
- */
147
- toSRGB(out: Color): Color;
148
- /**
149
- * Gets the brightness.
150
- * @returns The Hue-Saturation-Brightness (HSB) saturation for this
151
- */
152
- getBrightness(): number;
153
- /**
154
- * Serialize this color to a JSON representation.
155
- * @return A JSON representation of this color
156
- */
157
- toJSON(): ColorLike;
158
- /** @deprecated Please use `sRGBToLinearSpace` instead. */
159
- static gammaToLinearSpace(value: number): number;
160
- /** @deprecated Please use `linearToSRGBSpace` instead. */
161
- static linearToGammaSpace(value: number): number;
162
- /** @deprecated Please use `toSRGB` instead. */
163
- toGamma(out: Color): Color;
164
- }
165
- interface ColorLike {
166
- /** {@inheritDoc Color._r} */
167
- r: number;
168
- /** {@inheritDoc Color._g} */
169
- g: number;
170
- /** {@inheritDoc Color._b} */
171
- b: number;
172
- /** {@inheritDoc Color._a} */
173
- a: number;
174
- }
175
- export {};
package/types/IClone.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Clone interface.
3
- */
4
- export interface IClone<T> {
5
- /**
6
- * Clone and return object.
7
- * @returns Clone object
8
- */
9
- clone(): T;
10
- }
package/types/ICopy.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * Copy interface.
3
- */
4
- export interface ICopy<S, T> {
5
- /**
6
- * Copy from source object.
7
- * @returns This object
8
- */
9
- copyFrom(source: S): T;
10
- /**
11
- * Copy to target object.
12
- * @returns This target object
13
- */
14
- copyTo?(target: S): S;
15
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * Common utility methods for math operations.
3
- */
4
- export declare class MathUtil {
5
- /** The value for which all absolute numbers smaller than are considered equal to zero. */
6
- static readonly zeroTolerance: number;
7
- /** The conversion factor that radian to degree. */
8
- static readonly radToDegreeFactor: number;
9
- /** The conversion factor that degree to radian. */
10
- static readonly degreeToRadFactor: number;
11
- /**
12
- * Clamps the specified value.
13
- * @param v - The specified value
14
- * @param min - The min value
15
- * @param max - The max value
16
- * @returns The result of clamping a value between min and max
17
- */
18
- static clamp(v: number, min: number, max: number): number;
19
- /**
20
- * Checks if a and b are almost equals.
21
- * The absolute value of the difference between a and b is close to zero.
22
- * @param a - The left value to compare
23
- * @param b - The right value to compare
24
- * @returns True if a almost equal to b, false otherwise
25
- */
26
- static equals(a: number, b: number): boolean;
27
- /**
28
- * Determines whether the specified v is pow2.
29
- * @param v - The specified v
30
- * @returns True if the specified v is pow2, false otherwise
31
- */
32
- static isPowerOf2(v: number): boolean;
33
- /**
34
- * Modify the specified r from radian to degree.
35
- * @param r - The specified r
36
- * @returns The degree value
37
- */
38
- static radianToDegree(r: number): number;
39
- /**
40
- * Modify the specified d from degree to radian.
41
- * @param d - The specified d
42
- * @returns The radian value
43
- */
44
- static degreeToRadian(d: number): number;
45
- /**
46
- * Linearly interpolate between two values
47
- * @param start - Specify the start of the range in which to interpolate
48
- * @param end - Specify the end of the range in which to interpolate
49
- * @param t - The blend amount where 0 returns start and 1 end
50
- * @returns The result of linear blending between start and end
51
- */
52
- static lerp(start: number, end: number, t: number): number;
53
- }