@vertexvis/geometry 0.24.5 → 1.0.0-canary.0
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/dist/angle.d.ts +35 -35
- package/dist/boundingBox.d.ts +49 -49
- package/dist/boundingSphere.d.ts +14 -14
- package/dist/{bundle.cjs.js → bundle.cjs} +2149 -2149
- package/dist/bundle.cjs.map +1 -0
- package/dist/{bundle.esm.js → bundle.js} +2149 -2149
- package/dist/bundle.js.map +1 -0
- package/dist/cdn/{bundle.esm.js → bundle.js} +2150 -2184
- package/dist/cdn/bundle.js.map +1 -0
- package/dist/cdn/bundle.min.js +2 -0
- package/dist/cdn/bundle.min.js.map +1 -0
- package/dist/dimensions.d.ts +94 -94
- package/dist/euler.d.ts +57 -57
- package/dist/index.d.ts +21 -21
- package/dist/line3.d.ts +48 -48
- package/dist/math.d.ts +20 -20
- package/dist/matrix.d.ts +73 -73
- package/dist/matrix2.d.ts +29 -29
- package/dist/matrix4.d.ts +285 -285
- package/dist/plane.d.ts +51 -51
- package/dist/point.d.ts +80 -80
- package/dist/quaternion.d.ts +65 -65
- package/dist/ray.d.ts +52 -52
- package/dist/rectangle.d.ts +125 -125
- package/dist/vector3.d.ts +226 -226
- package/dist/vector4.d.ts +23 -23
- package/package.json +22 -13
- package/dist/bundle.cjs.js.map +0 -1
- package/dist/bundle.esm.js.map +0 -1
- package/dist/cdn/__tests__/angle.test.d.ts +0 -1
- package/dist/cdn/__tests__/boundingBox.test.d.ts +0 -1
- package/dist/cdn/__tests__/boundingSphere.test.d.ts +0 -1
- package/dist/cdn/__tests__/dimensions.test.d.ts +0 -1
- package/dist/cdn/__tests__/euler.test.d.ts +0 -1
- package/dist/cdn/__tests__/line3.test.d.ts +0 -1
- package/dist/cdn/__tests__/math.spec.d.ts +0 -1
- package/dist/cdn/__tests__/matrix.test.d.ts +0 -1
- package/dist/cdn/__tests__/matrix2.test.d.ts +0 -1
- package/dist/cdn/__tests__/matrix4.test.d.ts +0 -1
- package/dist/cdn/__tests__/plane.test.d.ts +0 -1
- package/dist/cdn/__tests__/point.test.d.ts +0 -1
- package/dist/cdn/__tests__/quaternion.test.d.ts +0 -1
- package/dist/cdn/__tests__/ray.test.d.ts +0 -1
- package/dist/cdn/__tests__/rectangle.test.d.ts +0 -1
- package/dist/cdn/__tests__/vector3.test.d.ts +0 -1
- package/dist/cdn/__tests__/vector4.test.d.ts +0 -1
- package/dist/cdn/angle.d.ts +0 -35
- package/dist/cdn/boundingBox.d.ts +0 -49
- package/dist/cdn/boundingSphere.d.ts +0 -14
- package/dist/cdn/bundle.esm.js.map +0 -1
- package/dist/cdn/bundle.esm.min.js +0 -16
- package/dist/cdn/bundle.esm.min.js.map +0 -1
- package/dist/cdn/dimensions.d.ts +0 -94
- package/dist/cdn/euler.d.ts +0 -57
- package/dist/cdn/index.d.ts +0 -21
- package/dist/cdn/line3.d.ts +0 -48
- package/dist/cdn/math.d.ts +0 -20
- package/dist/cdn/matrix.d.ts +0 -73
- package/dist/cdn/matrix2.d.ts +0 -29
- package/dist/cdn/matrix4.d.ts +0 -285
- package/dist/cdn/plane.d.ts +0 -51
- package/dist/cdn/point.d.ts +0 -80
- package/dist/cdn/quaternion.d.ts +0 -65
- package/dist/cdn/ray.d.ts +0 -52
- package/dist/cdn/rectangle.d.ts +0 -125
- package/dist/cdn/vector3.d.ts +0 -226
- package/dist/cdn/vector4.d.ts +0 -23
package/dist/point.d.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import * as Angle from './angle';
|
|
2
|
-
/**
|
|
3
|
-
* A `Point` represents a cartesian coordinate with a horizontal and vertical
|
|
4
|
-
* position or length.
|
|
5
|
-
*/
|
|
6
|
-
export interface Point {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Returns a new `Point` with the given horizontal and vertical position.
|
|
12
|
-
*/
|
|
13
|
-
export declare function create(x?: number, y?: number): Point;
|
|
14
|
-
/**
|
|
15
|
-
* Converts a polar coordinate (length and angle) into a Cartesian coordinate.
|
|
16
|
-
*/
|
|
17
|
-
export declare function polar(length: number, radians: Angle.Angle): Point;
|
|
18
|
-
/**
|
|
19
|
-
* Returns the distance between two points.
|
|
20
|
-
*/
|
|
21
|
-
export declare function distance(a: Point, b: Point): number;
|
|
22
|
-
/**
|
|
23
|
-
* Returns a new `Point` where `b` is subtracted from `a`.
|
|
24
|
-
*/
|
|
25
|
-
export declare function subtract(a: Point, b: Point): Point;
|
|
26
|
-
/**
|
|
27
|
-
* Returns a new `Point` where `b` is added to `a`.
|
|
28
|
-
*/
|
|
29
|
-
export declare function add(a: Point, b: Point): Point;
|
|
30
|
-
/**
|
|
31
|
-
* Returns `true` if the `x` and `y` positions of `a` and `b` are equal.
|
|
32
|
-
*/
|
|
33
|
-
export declare function isEqual(a: Point, b: Point): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Performs a linear interpolation between `a` and `b` and returns the result.
|
|
36
|
-
* The value of `t` is clamped between `[0, 1]`.
|
|
37
|
-
*
|
|
38
|
-
* @param a The start value.
|
|
39
|
-
* @param b The end value.
|
|
40
|
-
* @param t A value between 0 and 1.
|
|
41
|
-
* @returns A point between `a` and `b`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function lerp(a: Point, b: Point, t: number): Point;
|
|
44
|
-
/**
|
|
45
|
-
* Returns a new `Point` where `x` and `y` are inverted.
|
|
46
|
-
*/
|
|
47
|
-
export declare function negate(pt: Point): Point;
|
|
48
|
-
/**
|
|
49
|
-
* Returns a new `Point` where `x` and `y` are multiplied by the given scale
|
|
50
|
-
* factors.
|
|
51
|
-
*/
|
|
52
|
-
export declare function scale(pt: Point, scaleX: number, scaleY: number): Point;
|
|
53
|
-
/**
|
|
54
|
-
* Returns a new `Point` where `x` and `y` are multiplied by the given scale
|
|
55
|
-
* factor.
|
|
56
|
-
*/
|
|
57
|
-
export declare function scaleProportional(pt: Point, scale: number): Point;
|
|
58
|
-
/**
|
|
59
|
-
* Returns the magnitude of a point.
|
|
60
|
-
*/
|
|
61
|
-
export declare function magnitude(pt: Point): number;
|
|
62
|
-
/**
|
|
63
|
-
* Transforms a vector into the corresponding normal (unit) vector.
|
|
64
|
-
*/
|
|
65
|
-
export declare function normalizeVector(pt: Point): Point;
|
|
66
|
-
/**
|
|
67
|
-
* Returns a new normal (unit) vector pointing between the two given points.
|
|
68
|
-
*/
|
|
69
|
-
export declare function normalDirectionVector(ptA: Point, ptB: Point): Point;
|
|
70
|
-
/**
|
|
71
|
-
* Returns a vector orthogonal to the vector between the two given points.
|
|
72
|
-
*/
|
|
73
|
-
export declare function orthogonalVector(ptA: Point, ptB: Point): Point;
|
|
74
|
-
/**
|
|
75
|
-
* Parses a JSON string representation of a Point and returns an object.
|
|
76
|
-
*
|
|
77
|
-
* @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
|
|
78
|
-
* @returns A parsed Point.
|
|
79
|
-
*/
|
|
80
|
-
export declare function fromJson(json: string): Point;
|
|
1
|
+
import * as Angle from './angle';
|
|
2
|
+
/**
|
|
3
|
+
* A `Point` represents a cartesian coordinate with a horizontal and vertical
|
|
4
|
+
* position or length.
|
|
5
|
+
*/
|
|
6
|
+
export interface Point {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns a new `Point` with the given horizontal and vertical position.
|
|
12
|
+
*/
|
|
13
|
+
export declare function create(x?: number, y?: number): Point;
|
|
14
|
+
/**
|
|
15
|
+
* Converts a polar coordinate (length and angle) into a Cartesian coordinate.
|
|
16
|
+
*/
|
|
17
|
+
export declare function polar(length: number, radians: Angle.Angle): Point;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the distance between two points.
|
|
20
|
+
*/
|
|
21
|
+
export declare function distance(a: Point, b: Point): number;
|
|
22
|
+
/**
|
|
23
|
+
* Returns a new `Point` where `b` is subtracted from `a`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function subtract(a: Point, b: Point): Point;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a new `Point` where `b` is added to `a`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function add(a: Point, b: Point): Point;
|
|
30
|
+
/**
|
|
31
|
+
* Returns `true` if the `x` and `y` positions of `a` and `b` are equal.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isEqual(a: Point, b: Point): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Performs a linear interpolation between `a` and `b` and returns the result.
|
|
36
|
+
* The value of `t` is clamped between `[0, 1]`.
|
|
37
|
+
*
|
|
38
|
+
* @param a The start value.
|
|
39
|
+
* @param b The end value.
|
|
40
|
+
* @param t A value between 0 and 1.
|
|
41
|
+
* @returns A point between `a` and `b`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function lerp(a: Point, b: Point, t: number): Point;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a new `Point` where `x` and `y` are inverted.
|
|
46
|
+
*/
|
|
47
|
+
export declare function negate(pt: Point): Point;
|
|
48
|
+
/**
|
|
49
|
+
* Returns a new `Point` where `x` and `y` are multiplied by the given scale
|
|
50
|
+
* factors.
|
|
51
|
+
*/
|
|
52
|
+
export declare function scale(pt: Point, scaleX: number, scaleY: number): Point;
|
|
53
|
+
/**
|
|
54
|
+
* Returns a new `Point` where `x` and `y` are multiplied by the given scale
|
|
55
|
+
* factor.
|
|
56
|
+
*/
|
|
57
|
+
export declare function scaleProportional(pt: Point, scale: number): Point;
|
|
58
|
+
/**
|
|
59
|
+
* Returns the magnitude of a point.
|
|
60
|
+
*/
|
|
61
|
+
export declare function magnitude(pt: Point): number;
|
|
62
|
+
/**
|
|
63
|
+
* Transforms a vector into the corresponding normal (unit) vector.
|
|
64
|
+
*/
|
|
65
|
+
export declare function normalizeVector(pt: Point): Point;
|
|
66
|
+
/**
|
|
67
|
+
* Returns a new normal (unit) vector pointing between the two given points.
|
|
68
|
+
*/
|
|
69
|
+
export declare function normalDirectionVector(ptA: Point, ptB: Point): Point;
|
|
70
|
+
/**
|
|
71
|
+
* Returns a vector orthogonal to the vector between the two given points.
|
|
72
|
+
*/
|
|
73
|
+
export declare function orthogonalVector(ptA: Point, ptB: Point): Point;
|
|
74
|
+
/**
|
|
75
|
+
* Parses a JSON string representation of a Point and returns an object.
|
|
76
|
+
*
|
|
77
|
+
* @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
|
|
78
|
+
* @returns A parsed Point.
|
|
79
|
+
*/
|
|
80
|
+
export declare function fromJson(json: string): Point;
|
package/dist/quaternion.d.ts
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import * as Euler from './euler';
|
|
2
|
-
import * as Matrix4 from './matrix4';
|
|
3
|
-
import * as Vector3 from './vector3';
|
|
4
|
-
/**
|
|
5
|
-
* A type that represents a
|
|
6
|
-
* [quaternion](http://en.wikipedia.org/wiki/Quaternion). Quaternions are used
|
|
7
|
-
* in 3D graphics to represent
|
|
8
|
-
* [rotations](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation).
|
|
9
|
-
*/
|
|
10
|
-
export interface Quaternion {
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
z: number;
|
|
14
|
-
w: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* An array representation of a `Quaternion`.
|
|
18
|
-
*/
|
|
19
|
-
export
|
|
20
|
-
/**
|
|
21
|
-
* Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
|
|
22
|
-
* w: 1}` is returned.
|
|
23
|
-
*/
|
|
24
|
-
export declare function create(value?: Partial<Quaternion>): Quaternion;
|
|
25
|
-
/**
|
|
26
|
-
* Parses a JSON string representation of a `Quaternion`.
|
|
27
|
-
*
|
|
28
|
-
* @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
|
|
29
|
-
* @returns A parsed `Quaternion`.
|
|
30
|
-
*/
|
|
31
|
-
export declare function fromJson(json: string): Quaternion;
|
|
32
|
-
/**
|
|
33
|
-
* Returns a quaternion with that will have a magnitude of 1.
|
|
34
|
-
*/
|
|
35
|
-
export declare function normalize(q: Quaternion): Quaternion;
|
|
36
|
-
/**
|
|
37
|
-
* Returns the magnitude of the provided quaternion.
|
|
38
|
-
*/
|
|
39
|
-
export declare function magnitude(q: Quaternion): number;
|
|
40
|
-
/**
|
|
41
|
-
* Returns a quaternion where each component is multiplied by the `scalar`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function scale(scalar: number, q: Quaternion): Quaternion;
|
|
44
|
-
/**
|
|
45
|
-
* Creates a `Quaternion` that is rotated the given radians around an axis.
|
|
46
|
-
*
|
|
47
|
-
* @param axis The axis to rotate around.
|
|
48
|
-
* @param radians The rotation, in radians.
|
|
49
|
-
* @returns A rotated quaternion.
|
|
50
|
-
*/
|
|
51
|
-
export declare function fromAxisAngle(axis: Vector3.Vector3, radians: number): Quaternion;
|
|
52
|
-
/**
|
|
53
|
-
* Returns a quaternion using the upper 3x3 of a pure rotation matrix
|
|
54
|
-
* (unscaled).
|
|
55
|
-
*/
|
|
56
|
-
export declare function fromMatrixRotation(matrix: Matrix4.Matrix4): Quaternion;
|
|
57
|
-
export declare function fromEuler(euler: Euler.Euler): Quaternion;
|
|
58
|
-
/**
|
|
59
|
-
* Multiplies `a` x `b` and returns a new quaternion with the result.
|
|
60
|
-
*/
|
|
61
|
-
export declare function multiply(a: Quaternion, b: Quaternion): Quaternion;
|
|
62
|
-
/**
|
|
63
|
-
* Type guard that checks if the given type is a Quaternion.
|
|
64
|
-
*/
|
|
65
|
-
export declare function isType(obj: unknown): obj is Quaternion;
|
|
1
|
+
import * as Euler from './euler';
|
|
2
|
+
import * as Matrix4 from './matrix4';
|
|
3
|
+
import * as Vector3 from './vector3';
|
|
4
|
+
/**
|
|
5
|
+
* A type that represents a
|
|
6
|
+
* [quaternion](http://en.wikipedia.org/wiki/Quaternion). Quaternions are used
|
|
7
|
+
* in 3D graphics to represent
|
|
8
|
+
* [rotations](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation).
|
|
9
|
+
*/
|
|
10
|
+
export interface Quaternion {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
z: number;
|
|
14
|
+
w: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* An array representation of a `Quaternion`.
|
|
18
|
+
*/
|
|
19
|
+
export type QuaternionAsArray = [x: number, y: number, z: number, w: number];
|
|
20
|
+
/**
|
|
21
|
+
* Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
|
|
22
|
+
* w: 1}` is returned.
|
|
23
|
+
*/
|
|
24
|
+
export declare function create(value?: Partial<Quaternion>): Quaternion;
|
|
25
|
+
/**
|
|
26
|
+
* Parses a JSON string representation of a `Quaternion`.
|
|
27
|
+
*
|
|
28
|
+
* @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
|
|
29
|
+
* @returns A parsed `Quaternion`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fromJson(json: string): Quaternion;
|
|
32
|
+
/**
|
|
33
|
+
* Returns a quaternion with that will have a magnitude of 1.
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalize(q: Quaternion): Quaternion;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the magnitude of the provided quaternion.
|
|
38
|
+
*/
|
|
39
|
+
export declare function magnitude(q: Quaternion): number;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a quaternion where each component is multiplied by the `scalar`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function scale(scalar: number, q: Quaternion): Quaternion;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a `Quaternion` that is rotated the given radians around an axis.
|
|
46
|
+
*
|
|
47
|
+
* @param axis The axis to rotate around.
|
|
48
|
+
* @param radians The rotation, in radians.
|
|
49
|
+
* @returns A rotated quaternion.
|
|
50
|
+
*/
|
|
51
|
+
export declare function fromAxisAngle(axis: Vector3.Vector3, radians: number): Quaternion;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a quaternion using the upper 3x3 of a pure rotation matrix
|
|
54
|
+
* (unscaled).
|
|
55
|
+
*/
|
|
56
|
+
export declare function fromMatrixRotation(matrix: Matrix4.Matrix4): Quaternion;
|
|
57
|
+
export declare function fromEuler(euler: Euler.Euler): Quaternion;
|
|
58
|
+
/**
|
|
59
|
+
* Multiplies `a` x `b` and returns a new quaternion with the result.
|
|
60
|
+
*/
|
|
61
|
+
export declare function multiply(a: Quaternion, b: Quaternion): Quaternion;
|
|
62
|
+
/**
|
|
63
|
+
* Type guard that checks if the given type is a Quaternion.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isType(obj: unknown): obj is Quaternion;
|
package/dist/ray.d.ts
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import * as Plane from './plane';
|
|
2
|
-
import * as Vector3 from './vector3';
|
|
3
|
-
/**
|
|
4
|
-
* A `Ray` represents an infinite line starting at `origin` and going in
|
|
5
|
-
* `direction`.
|
|
6
|
-
*/
|
|
7
|
-
export interface Ray {
|
|
8
|
-
/**
|
|
9
|
-
* The origin point of the ray.
|
|
10
|
-
*/
|
|
11
|
-
origin: Vector3.Vector3;
|
|
12
|
-
/**
|
|
13
|
-
* A normal that describes the direction of the ray from origin.
|
|
14
|
-
*/
|
|
15
|
-
direction: Vector3.Vector3;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new ray with the given values, or using default values if none are
|
|
19
|
-
* provided. The direction defaults to `{x: 0, y: 0, z: -1}` if undefined.
|
|
20
|
-
*
|
|
21
|
-
* @param value The values of the ray.
|
|
22
|
-
* @returns A new ray.
|
|
23
|
-
*/
|
|
24
|
-
export declare function create(value?: Partial<Ray>): Ray;
|
|
25
|
-
/**
|
|
26
|
-
* Returns a point at the given distance along this ray.
|
|
27
|
-
*
|
|
28
|
-
* @param ray The ray to get the point on.
|
|
29
|
-
* @param distance A distance from origin along the ray's direction.
|
|
30
|
-
* @returns A point on the ray.
|
|
31
|
-
*/
|
|
32
|
-
export declare function at(ray: Ray, distance: number): Vector3.Vector3;
|
|
33
|
-
/**
|
|
34
|
-
* Computes the distance of the `ray`s origin to the given `plane`. Returns a
|
|
35
|
-
* distance of 0 if the ray is coplanar and returns `undefined` if the ray does
|
|
36
|
-
* not intersect with the plane.
|
|
37
|
-
*
|
|
38
|
-
* @param ray The ray to get the distance for.
|
|
39
|
-
* @param plane The plane to compute the distance to.
|
|
40
|
-
* @returns The distance to the plane, or `undefined` if it cannot be computed.
|
|
41
|
-
*/
|
|
42
|
-
export declare function distanceToPlane(ray: Ray, plane: Plane.Plane): number | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Computes the intersection point of the given `ray` to the given `plane`. If
|
|
45
|
-
* the ray does not intersect with the plane, then `undefined` is returned.
|
|
46
|
-
*
|
|
47
|
-
* @param ray The ray to intersect.
|
|
48
|
-
* @param plane The plane to intersect with.
|
|
49
|
-
* @returns The intersection point, or `undefined` if the ray does not
|
|
50
|
-
* intersect.
|
|
51
|
-
*/
|
|
52
|
-
export declare function intersectPlane(ray: Ray, plane: Plane.Plane): Vector3.Vector3 | undefined;
|
|
1
|
+
import * as Plane from './plane';
|
|
2
|
+
import * as Vector3 from './vector3';
|
|
3
|
+
/**
|
|
4
|
+
* A `Ray` represents an infinite line starting at `origin` and going in
|
|
5
|
+
* `direction`.
|
|
6
|
+
*/
|
|
7
|
+
export interface Ray {
|
|
8
|
+
/**
|
|
9
|
+
* The origin point of the ray.
|
|
10
|
+
*/
|
|
11
|
+
origin: Vector3.Vector3;
|
|
12
|
+
/**
|
|
13
|
+
* A normal that describes the direction of the ray from origin.
|
|
14
|
+
*/
|
|
15
|
+
direction: Vector3.Vector3;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new ray with the given values, or using default values if none are
|
|
19
|
+
* provided. The direction defaults to `{x: 0, y: 0, z: -1}` if undefined.
|
|
20
|
+
*
|
|
21
|
+
* @param value The values of the ray.
|
|
22
|
+
* @returns A new ray.
|
|
23
|
+
*/
|
|
24
|
+
export declare function create(value?: Partial<Ray>): Ray;
|
|
25
|
+
/**
|
|
26
|
+
* Returns a point at the given distance along this ray.
|
|
27
|
+
*
|
|
28
|
+
* @param ray The ray to get the point on.
|
|
29
|
+
* @param distance A distance from origin along the ray's direction.
|
|
30
|
+
* @returns A point on the ray.
|
|
31
|
+
*/
|
|
32
|
+
export declare function at(ray: Ray, distance: number): Vector3.Vector3;
|
|
33
|
+
/**
|
|
34
|
+
* Computes the distance of the `ray`s origin to the given `plane`. Returns a
|
|
35
|
+
* distance of 0 if the ray is coplanar and returns `undefined` if the ray does
|
|
36
|
+
* not intersect with the plane.
|
|
37
|
+
*
|
|
38
|
+
* @param ray The ray to get the distance for.
|
|
39
|
+
* @param plane The plane to compute the distance to.
|
|
40
|
+
* @returns The distance to the plane, or `undefined` if it cannot be computed.
|
|
41
|
+
*/
|
|
42
|
+
export declare function distanceToPlane(ray: Ray, plane: Plane.Plane): number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Computes the intersection point of the given `ray` to the given `plane`. If
|
|
45
|
+
* the ray does not intersect with the plane, then `undefined` is returned.
|
|
46
|
+
*
|
|
47
|
+
* @param ray The ray to intersect.
|
|
48
|
+
* @param plane The plane to intersect with.
|
|
49
|
+
* @returns The intersection point, or `undefined` if the ray does not
|
|
50
|
+
* intersect.
|
|
51
|
+
*/
|
|
52
|
+
export declare function intersectPlane(ray: Ray, plane: Plane.Plane): Vector3.Vector3 | undefined;
|
package/dist/rectangle.d.ts
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import * as Dimensions from './dimensions';
|
|
2
|
-
import * as Point from './point';
|
|
3
|
-
/**
|
|
4
|
-
* A `Rectangle` is an object with position and size.
|
|
5
|
-
*/
|
|
6
|
-
export interface Rectangle {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Returns a new `Rectangle` with the given position and size.
|
|
14
|
-
*/
|
|
15
|
-
export declare function create(x: number, y: number, width: number, height: number): Rectangle;
|
|
16
|
-
/**
|
|
17
|
-
* Returns a new `Rectangle` at the origin point and given size.
|
|
18
|
-
*/
|
|
19
|
-
export declare function fromDimensions(dimensions: Dimensions.Dimensions): Rectangle;
|
|
20
|
-
/**
|
|
21
|
-
* Returns a new `Rectangle` with the given position and size.
|
|
22
|
-
*/
|
|
23
|
-
export declare function fromPointAndDimensions(point: Point.Point, dimensions: Dimensions.Dimensions): Rectangle;
|
|
24
|
-
/**
|
|
25
|
-
* Returns a new `Rectangle` with the given top-left and bottom-right positions.
|
|
26
|
-
* The returned rectangle will always returns a positive width and height.
|
|
27
|
-
*/
|
|
28
|
-
export declare function fromPoints(topLeftPt: Point.Point, bottomRightPt: Point.Point): Rectangle;
|
|
29
|
-
/**
|
|
30
|
-
* Returns a rectangle where the longest length of `rect` will be equal to the
|
|
31
|
-
* shortest length of `to`. The shortest length of `rect` will be proportionally
|
|
32
|
-
* scaled to match the aspect ratio of `rect`. The returned rectangle will be
|
|
33
|
-
* centered within `to`.
|
|
34
|
-
*
|
|
35
|
-
* @see {@link cropFit}
|
|
36
|
-
*/
|
|
37
|
-
export declare function containFit(to: Rectangle, rect: Rectangle): Rectangle;
|
|
38
|
-
/**
|
|
39
|
-
* Returns a rectangle where the shortest length of `rect` will be equal to the
|
|
40
|
-
* longest length of `to`. The longest length of `rect` will be proportionally
|
|
41
|
-
* scaled to match the aspect ratio of `rect`. The returned rectangle will be
|
|
42
|
-
* centered within `to`.
|
|
43
|
-
*
|
|
44
|
-
* @see {@link containFit}
|
|
45
|
-
*/
|
|
46
|
-
export declare function cropFit(to: Rectangle, rect: Rectangle): Rectangle;
|
|
47
|
-
/**
|
|
48
|
-
* Returns a rectangle where each side of `rect` will be reduced proportionally
|
|
49
|
-
* to have an area less than or equal to the provided `to` value. The returned
|
|
50
|
-
* rectangle will be centered within the original bounds of `rect`.
|
|
51
|
-
*
|
|
52
|
-
* @param to - the maximum area this rectangle can have
|
|
53
|
-
* @param rect - the rectangle to scale to fit the specified area
|
|
54
|
-
*/
|
|
55
|
-
export declare function scaleFit(to: number, rect: Rectangle): Rectangle;
|
|
56
|
-
/**
|
|
57
|
-
* Returns a rectangle where the position and dimensions are scaled by the given
|
|
58
|
-
* factors. If `scaleY` is omitted, then the position and dimensions are scaled
|
|
59
|
-
* uniformly by `scaleOrScaleX`.
|
|
60
|
-
*
|
|
61
|
-
* @param rect The rectangle to scale.
|
|
62
|
-
* @param scaleOrScaleX The uniform scale factor, or the horizontal scale
|
|
63
|
-
* factor.
|
|
64
|
-
* @param scaleY The vertical scale factor.
|
|
65
|
-
* @returns A scaled rectangle.
|
|
66
|
-
*/
|
|
67
|
-
export declare function scale(rect: Rectangle, scaleOrScaleX: number, scaleY?: number): Rectangle;
|
|
68
|
-
/**
|
|
69
|
-
* Returns true if two rectangles are equal in position and size.
|
|
70
|
-
*/
|
|
71
|
-
export declare function isEqual(a: Rectangle, b: Rectangle): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Returns a rectangle that has its position shifted by a given offset. The
|
|
74
|
-
* size of the rectangle is unchanged.
|
|
75
|
-
*/
|
|
76
|
-
export declare function offset(delta: Point.Point, rect: Rectangle): Rectangle;
|
|
77
|
-
/**
|
|
78
|
-
* Returns the area of the rectangle.
|
|
79
|
-
*/
|
|
80
|
-
export declare function area(rect: Rectangle): number;
|
|
81
|
-
/**
|
|
82
|
-
* Returns the center point of the rectangle.
|
|
83
|
-
*/
|
|
84
|
-
export declare function center(rect: Rectangle): Point.Point;
|
|
85
|
-
/**
|
|
86
|
-
* Returns the top-left position of the rectangle, as a point.
|
|
87
|
-
*/
|
|
88
|
-
export declare function topLeft(rect: Rectangle): Point.Point;
|
|
89
|
-
/**
|
|
90
|
-
* Returns the bottom-right position of the rectangle, as a point.
|
|
91
|
-
*/
|
|
92
|
-
export declare function bottomRight(rect: Rectangle): Point.Point;
|
|
93
|
-
/**
|
|
94
|
-
* Returns `true` if the given rectangle has a portrait aspect ratio.
|
|
95
|
-
*/
|
|
96
|
-
export declare function isPortrait(rect: Rectangle): boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Returns `true` if the given rectangle has a landscape aspect ratio.
|
|
99
|
-
*/
|
|
100
|
-
export declare function isLandscape(rect: Rectangle): boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Returns `true` if the given rectangle has a square aspect ratio.
|
|
103
|
-
*/
|
|
104
|
-
export declare function isSquare(rect: Rectangle): boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Pads a rectangle by the given amount, maintaining the center position.
|
|
107
|
-
*
|
|
108
|
-
* @param rect The rectangle to apply padding to.
|
|
109
|
-
* @param padding The padding to add.
|
|
110
|
-
*/
|
|
111
|
-
export declare function pad(rect: Rectangle, padding: number): Rectangle;
|
|
112
|
-
/**
|
|
113
|
-
* Returns `true` if the given rectangle contains all the given `points`.
|
|
114
|
-
*
|
|
115
|
-
* @param rect The rectangle to check against.
|
|
116
|
-
* @param points The points to check.
|
|
117
|
-
*/
|
|
118
|
-
export declare function containsPoints(rect: Rectangle, ...points: Point.Point[]): boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Parses a JSON string representation of a Rectangle and returns an object.
|
|
121
|
-
*
|
|
122
|
-
* @param json A JSON string, either in the form `[x,y,width,height]` or `{"x": 0, "y": 0, "width": 10, "height": 10}`
|
|
123
|
-
* @returns A parsed Point.
|
|
124
|
-
*/
|
|
125
|
-
export declare function fromJson(json: string): Rectangle;
|
|
1
|
+
import * as Dimensions from './dimensions';
|
|
2
|
+
import * as Point from './point';
|
|
3
|
+
/**
|
|
4
|
+
* A `Rectangle` is an object with position and size.
|
|
5
|
+
*/
|
|
6
|
+
export interface Rectangle {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns a new `Rectangle` with the given position and size.
|
|
14
|
+
*/
|
|
15
|
+
export declare function create(x: number, y: number, width: number, height: number): Rectangle;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a new `Rectangle` at the origin point and given size.
|
|
18
|
+
*/
|
|
19
|
+
export declare function fromDimensions(dimensions: Dimensions.Dimensions): Rectangle;
|
|
20
|
+
/**
|
|
21
|
+
* Returns a new `Rectangle` with the given position and size.
|
|
22
|
+
*/
|
|
23
|
+
export declare function fromPointAndDimensions(point: Point.Point, dimensions: Dimensions.Dimensions): Rectangle;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a new `Rectangle` with the given top-left and bottom-right positions.
|
|
26
|
+
* The returned rectangle will always returns a positive width and height.
|
|
27
|
+
*/
|
|
28
|
+
export declare function fromPoints(topLeftPt: Point.Point, bottomRightPt: Point.Point): Rectangle;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a rectangle where the longest length of `rect` will be equal to the
|
|
31
|
+
* shortest length of `to`. The shortest length of `rect` will be proportionally
|
|
32
|
+
* scaled to match the aspect ratio of `rect`. The returned rectangle will be
|
|
33
|
+
* centered within `to`.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link cropFit}
|
|
36
|
+
*/
|
|
37
|
+
export declare function containFit(to: Rectangle, rect: Rectangle): Rectangle;
|
|
38
|
+
/**
|
|
39
|
+
* Returns a rectangle where the shortest length of `rect` will be equal to the
|
|
40
|
+
* longest length of `to`. The longest length of `rect` will be proportionally
|
|
41
|
+
* scaled to match the aspect ratio of `rect`. The returned rectangle will be
|
|
42
|
+
* centered within `to`.
|
|
43
|
+
*
|
|
44
|
+
* @see {@link containFit}
|
|
45
|
+
*/
|
|
46
|
+
export declare function cropFit(to: Rectangle, rect: Rectangle): Rectangle;
|
|
47
|
+
/**
|
|
48
|
+
* Returns a rectangle where each side of `rect` will be reduced proportionally
|
|
49
|
+
* to have an area less than or equal to the provided `to` value. The returned
|
|
50
|
+
* rectangle will be centered within the original bounds of `rect`.
|
|
51
|
+
*
|
|
52
|
+
* @param to - the maximum area this rectangle can have
|
|
53
|
+
* @param rect - the rectangle to scale to fit the specified area
|
|
54
|
+
*/
|
|
55
|
+
export declare function scaleFit(to: number, rect: Rectangle): Rectangle;
|
|
56
|
+
/**
|
|
57
|
+
* Returns a rectangle where the position and dimensions are scaled by the given
|
|
58
|
+
* factors. If `scaleY` is omitted, then the position and dimensions are scaled
|
|
59
|
+
* uniformly by `scaleOrScaleX`.
|
|
60
|
+
*
|
|
61
|
+
* @param rect The rectangle to scale.
|
|
62
|
+
* @param scaleOrScaleX The uniform scale factor, or the horizontal scale
|
|
63
|
+
* factor.
|
|
64
|
+
* @param scaleY The vertical scale factor.
|
|
65
|
+
* @returns A scaled rectangle.
|
|
66
|
+
*/
|
|
67
|
+
export declare function scale(rect: Rectangle, scaleOrScaleX: number, scaleY?: number): Rectangle;
|
|
68
|
+
/**
|
|
69
|
+
* Returns true if two rectangles are equal in position and size.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isEqual(a: Rectangle, b: Rectangle): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Returns a rectangle that has its position shifted by a given offset. The
|
|
74
|
+
* size of the rectangle is unchanged.
|
|
75
|
+
*/
|
|
76
|
+
export declare function offset(delta: Point.Point, rect: Rectangle): Rectangle;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the area of the rectangle.
|
|
79
|
+
*/
|
|
80
|
+
export declare function area(rect: Rectangle): number;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the center point of the rectangle.
|
|
83
|
+
*/
|
|
84
|
+
export declare function center(rect: Rectangle): Point.Point;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the top-left position of the rectangle, as a point.
|
|
87
|
+
*/
|
|
88
|
+
export declare function topLeft(rect: Rectangle): Point.Point;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the bottom-right position of the rectangle, as a point.
|
|
91
|
+
*/
|
|
92
|
+
export declare function bottomRight(rect: Rectangle): Point.Point;
|
|
93
|
+
/**
|
|
94
|
+
* Returns `true` if the given rectangle has a portrait aspect ratio.
|
|
95
|
+
*/
|
|
96
|
+
export declare function isPortrait(rect: Rectangle): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Returns `true` if the given rectangle has a landscape aspect ratio.
|
|
99
|
+
*/
|
|
100
|
+
export declare function isLandscape(rect: Rectangle): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Returns `true` if the given rectangle has a square aspect ratio.
|
|
103
|
+
*/
|
|
104
|
+
export declare function isSquare(rect: Rectangle): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Pads a rectangle by the given amount, maintaining the center position.
|
|
107
|
+
*
|
|
108
|
+
* @param rect The rectangle to apply padding to.
|
|
109
|
+
* @param padding The padding to add.
|
|
110
|
+
*/
|
|
111
|
+
export declare function pad(rect: Rectangle, padding: number): Rectangle;
|
|
112
|
+
/**
|
|
113
|
+
* Returns `true` if the given rectangle contains all the given `points`.
|
|
114
|
+
*
|
|
115
|
+
* @param rect The rectangle to check against.
|
|
116
|
+
* @param points The points to check.
|
|
117
|
+
*/
|
|
118
|
+
export declare function containsPoints(rect: Rectangle, ...points: Point.Point[]): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Parses a JSON string representation of a Rectangle and returns an object.
|
|
121
|
+
*
|
|
122
|
+
* @param json A JSON string, either in the form `[x,y,width,height]` or `{"x": 0, "y": 0, "width": 10, "height": 10}`
|
|
123
|
+
* @returns A parsed Point.
|
|
124
|
+
*/
|
|
125
|
+
export declare function fromJson(json: string): Rectangle;
|