@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.
Files changed (67) hide show
  1. package/dist/angle.d.ts +35 -35
  2. package/dist/boundingBox.d.ts +49 -49
  3. package/dist/boundingSphere.d.ts +14 -14
  4. package/dist/{bundle.cjs.js → bundle.cjs} +2149 -2149
  5. package/dist/bundle.cjs.map +1 -0
  6. package/dist/{bundle.esm.js → bundle.js} +2149 -2149
  7. package/dist/bundle.js.map +1 -0
  8. package/dist/cdn/{bundle.esm.js → bundle.js} +2150 -2184
  9. package/dist/cdn/bundle.js.map +1 -0
  10. package/dist/cdn/bundle.min.js +2 -0
  11. package/dist/cdn/bundle.min.js.map +1 -0
  12. package/dist/dimensions.d.ts +94 -94
  13. package/dist/euler.d.ts +57 -57
  14. package/dist/index.d.ts +21 -21
  15. package/dist/line3.d.ts +48 -48
  16. package/dist/math.d.ts +20 -20
  17. package/dist/matrix.d.ts +73 -73
  18. package/dist/matrix2.d.ts +29 -29
  19. package/dist/matrix4.d.ts +285 -285
  20. package/dist/plane.d.ts +51 -51
  21. package/dist/point.d.ts +80 -80
  22. package/dist/quaternion.d.ts +65 -65
  23. package/dist/ray.d.ts +52 -52
  24. package/dist/rectangle.d.ts +125 -125
  25. package/dist/vector3.d.ts +226 -226
  26. package/dist/vector4.d.ts +23 -23
  27. package/package.json +22 -13
  28. package/dist/bundle.cjs.js.map +0 -1
  29. package/dist/bundle.esm.js.map +0 -1
  30. package/dist/cdn/__tests__/angle.test.d.ts +0 -1
  31. package/dist/cdn/__tests__/boundingBox.test.d.ts +0 -1
  32. package/dist/cdn/__tests__/boundingSphere.test.d.ts +0 -1
  33. package/dist/cdn/__tests__/dimensions.test.d.ts +0 -1
  34. package/dist/cdn/__tests__/euler.test.d.ts +0 -1
  35. package/dist/cdn/__tests__/line3.test.d.ts +0 -1
  36. package/dist/cdn/__tests__/math.spec.d.ts +0 -1
  37. package/dist/cdn/__tests__/matrix.test.d.ts +0 -1
  38. package/dist/cdn/__tests__/matrix2.test.d.ts +0 -1
  39. package/dist/cdn/__tests__/matrix4.test.d.ts +0 -1
  40. package/dist/cdn/__tests__/plane.test.d.ts +0 -1
  41. package/dist/cdn/__tests__/point.test.d.ts +0 -1
  42. package/dist/cdn/__tests__/quaternion.test.d.ts +0 -1
  43. package/dist/cdn/__tests__/ray.test.d.ts +0 -1
  44. package/dist/cdn/__tests__/rectangle.test.d.ts +0 -1
  45. package/dist/cdn/__tests__/vector3.test.d.ts +0 -1
  46. package/dist/cdn/__tests__/vector4.test.d.ts +0 -1
  47. package/dist/cdn/angle.d.ts +0 -35
  48. package/dist/cdn/boundingBox.d.ts +0 -49
  49. package/dist/cdn/boundingSphere.d.ts +0 -14
  50. package/dist/cdn/bundle.esm.js.map +0 -1
  51. package/dist/cdn/bundle.esm.min.js +0 -16
  52. package/dist/cdn/bundle.esm.min.js.map +0 -1
  53. package/dist/cdn/dimensions.d.ts +0 -94
  54. package/dist/cdn/euler.d.ts +0 -57
  55. package/dist/cdn/index.d.ts +0 -21
  56. package/dist/cdn/line3.d.ts +0 -48
  57. package/dist/cdn/math.d.ts +0 -20
  58. package/dist/cdn/matrix.d.ts +0 -73
  59. package/dist/cdn/matrix2.d.ts +0 -29
  60. package/dist/cdn/matrix4.d.ts +0 -285
  61. package/dist/cdn/plane.d.ts +0 -51
  62. package/dist/cdn/point.d.ts +0 -80
  63. package/dist/cdn/quaternion.d.ts +0 -65
  64. package/dist/cdn/ray.d.ts +0 -52
  65. package/dist/cdn/rectangle.d.ts +0 -125
  66. package/dist/cdn/vector3.d.ts +0 -226
  67. package/dist/cdn/vector4.d.ts +0 -23
@@ -1,125 +0,0 @@
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,226 +0,0 @@
1
- import * as Euler from './euler';
2
- import * as Matrix4 from './matrix4';
3
- /**
4
- * A `Vector3` represents a vector of 3 dimensions values. It may represent a
5
- * point or direction.
6
- */
7
- export interface Vector3 {
8
- x: number;
9
- y: number;
10
- z: number;
11
- }
12
- /**
13
- * A `Vector3` representation as an array.
14
- */
15
- export declare type Vector3AsArray = [x: number, y: number, z: number];
16
- /**
17
- * Returns a new `Vector3` either with the provided x, y, and z dimensions,
18
- * or from the provided `Partial<Vector3>` object populated with zeroes
19
- * wherever a component is missing.
20
- *
21
- * Providing no values to this function will result in a zero-length vector.
22
- */
23
- export declare function create(x: number, y: number, z: number): Vector3;
24
- export declare function create(partialVector: Partial<Vector3>): Vector3;
25
- export declare function create(): Vector3;
26
- /**
27
- * Checks if each component of the given vector is populated with a numeric
28
- * component. A component is invalid if it contains a non-finite or NaN value.
29
- */
30
- export declare function isValid({ x, y, z }: Vector3): boolean;
31
- /**
32
- * Returns a vector representing the scale elements of `matrix`.
33
- */
34
- export declare function fromMatrixScale(matrix: Matrix4.Matrix4): Vector3;
35
- /**
36
- * Returns a vector representing the position elements of `matrix`.
37
- */
38
- export declare function fromMatrixPosition(matrix: Matrix4.Matrix4): Vector3;
39
- /**
40
- * Parses a JSON string representation of a Vector3 and returns an object.
41
- *
42
- * @param json A JSON string, either in the form `[x,y,z]` or `{"x": 0, "y": 0, "z": 0}`
43
- * @returns A parsed Vector3.
44
- */
45
- export declare function fromJson(json: string): Vector3;
46
- /**
47
- * Creates a `Vector3` from an array. Pass `offset` to read values from the
48
- * starting index.
49
- *
50
- * @see #toArray()
51
- * @see #create()
52
- */
53
- export declare function fromArray(nums: number[], offset?: number): Vector3;
54
- /**
55
- * Converts a Vector3 to an array where the values of the vector will be
56
- * represented as [x, y, z];
57
- *
58
- * @see #fromArray()
59
- * @see #create()
60
- */
61
- export declare function toArray({ x, y, z }: Vector3): Vector3AsArray;
62
- /**
63
- * Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
64
- */
65
- export declare function right(): Vector3;
66
- /**
67
- * Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
68
- */
69
- export declare function up(): Vector3;
70
- /**
71
- * Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
72
- */
73
- export declare function forward(): Vector3;
74
- /**
75
- * Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
76
- */
77
- export declare function left(): Vector3;
78
- /**
79
- * Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
80
- */
81
- export declare function down(): Vector3;
82
- /**
83
- * Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
84
- */
85
- export declare function back(): Vector3;
86
- /**
87
- * Returns a vector at the origin, Vector3(0, 0, 0).
88
- */
89
- export declare function origin(): Vector3;
90
- /**
91
- * Returns a vector with that will have a magnitude of 1.
92
- */
93
- export declare function normalize(vector: Vector3): Vector3;
94
- /**
95
- * Returns the straight-line length from (0, 0, 0) to the given vector.
96
- */
97
- export declare function magnitude(vector: Vector3): number;
98
- /**
99
- * Returns the straight-line length from (0, 0, 0) to the given vector).
100
- *
101
- * When comparing lengths of vectors, you should use this function as it's
102
- * slightly more efficient to calculate.
103
- */
104
- export declare function magnitudeSquared(vector: Vector3): number;
105
- /**
106
- * Returns a vector that is the cross product of two vectors.
107
- *
108
- * The cross product of two vectors results in a third vector which is
109
- * perpendicular to the two input vectors. The result's magnitude is equal to
110
- * the magnitudes of the two inputs multiplied together and then multiplied by
111
- * the sine of the angle between the inputs. You can determine the direction of
112
- * the result vector using the "left hand rule".
113
- */
114
- export declare function cross(a: Vector3, b: Vector3): Vector3;
115
- /**
116
- * Returns a vector that is the sum of two vectors.
117
- */
118
- export declare function add(a: Vector3, ...vectors: Vector3[]): Vector3;
119
- /**
120
- * Returns a vector that is the difference between two vectors.
121
- */
122
- export declare function subtract(a: Vector3, ...vectors: Vector3[]): Vector3;
123
- /**
124
- * Returns a vector that where each component of `b` is multiplied with `a`.
125
- */
126
- export declare function multiply(a: Vector3, b: Vector3): Vector3;
127
- /**
128
- * Returns a vector where each value of a vector is multiplied by the `scalar`.
129
- */
130
- export declare function scale(scalar: number, vector: Vector3): Vector3;
131
- /**
132
- * Returns a value representing the dot product of two vectors.
133
- *
134
- * The dot product is a float value equal to the magnitudes of the two vectors
135
- * multiplied together and then multiplied by the cosine of the angle between
136
- * them.
137
- */
138
- export declare function dot(a: Vector3, b: Vector3): number;
139
- /**
140
- * Returns the angle, in radians, between two vectors.
141
- *
142
- * The angle returned is the unsigned angle between the two vectors. This means
143
- * the smaller of the two possible angles between the two vectors is used. The
144
- * result is never greater than 180 degrees.
145
- */
146
- export declare function angleTo(a: Vector3, b: Vector3): number;
147
- /**
148
- * Returns the Euler angle, in radians with the `xyz` ordering, between two vectors.
149
- *
150
- * This method will normalize both vectors for the calculation, and uses the
151
- * algorithm described in https://www.xarg.org/proof/quaternion-from-two-vectors/.
152
- */
153
- export declare function eulerTo(a: Vector3, b: Vector3): Euler.Euler;
154
- /**
155
- * Performs a projection of a `vector` onto `onNormal`.
156
- *
157
- * A projection is represented as the nearest point along a normal to a vector,
158
- * which constructs a triangle from the origin, to the vector, to the projected
159
- * point.
160
- *
161
- * ```
162
- * Vector --> * * <-- Projected
163
- * \
164
- * \ | <-- Normal
165
- * \|
166
- * * <-- Origin
167
- * ```
168
- */
169
- export declare function project(vector: Vector3, onNormal: Vector3): Vector3;
170
- /**
171
- * Returns a vector that is rotated about an origin point.
172
- *
173
- * @param angle The angle to rotate, in radians.
174
- * @param point The origin point to rotate around.
175
- * @param axisDirection The direction used to compute the axis.
176
- * @param axisPosition The point of the axis.
177
- */
178
- export declare function rotateAboutAxis(angle: number, point: Vector3, axisDirection: Vector3, axisPosition: Vector3): Vector3;
179
- /**
180
- * Returns a vector that is multiplied with a matrix.
181
- */
182
- export declare function transformMatrix(vector: Vector3, m: Matrix4.Matrix4): Vector3;
183
- /**
184
- * Euclidean distance between two vectors
185
- */
186
- export declare function distance(a: Vector3, b: Vector3): number;
187
- /**
188
- * Returns the squared distance between two vectors. If you're just comparing
189
- * distances, this is slightly more efficient than `distanceTo`.
190
- */
191
- export declare function distanceSquared(a: Vector3, b: Vector3): number;
192
- /**
193
- * Returns `true` if two vectors have the same values.
194
- */
195
- export declare function isEqual(a: Vector3, b: Vector3): boolean;
196
- /**
197
- * Returns a vector that contains the largest components of `a` and `b`.
198
- */
199
- export declare function max(a: Vector3, b: Vector3): Vector3;
200
- /**
201
- * Returns a vector that contains the smallest components of `a` and `b`.
202
- */
203
- export declare function min(a: Vector3, b: Vector3): Vector3;
204
- /**
205
- * Returns a vector that each of its component negated.
206
- */
207
- export declare function negate(vector: Vector3): Vector3;
208
- /**
209
- * Performs a linear interpolation between `a` and `b` and returns the result.
210
- * The value of `t` is clamped between `[0, 1]`.
211
- *
212
- * @param a The start value.
213
- * @param b The end value.
214
- * @param t A value between 0 and 1.
215
- * @returns A point between `a` and `b`.
216
- */
217
- export declare function lerp(a: Vector3, b: Vector3, t: number): Vector3;
218
- /**
219
- * Maps a normalized device coordinate (NDC) space to world space coordinates.
220
- *
221
- * @param ndc A point in normalized device coordinates.
222
- * @param worldMatrix A camera's world matrix.
223
- * @param projectionMatrixInverse A camera's inverse projection matrix.
224
- * @returns A point in world space coordinates.
225
- */
226
- export declare function transformNdcToWorldSpace(ndc: Vector3, worldMatrix: Matrix4.Matrix4, projectionMatrixInverse: Matrix4.Matrix4): Vector3;
@@ -1,23 +0,0 @@
1
- /**
2
- * A `Vector4` represents a vector of 4 dimension values. It may represent a
3
- * point or direction. It may also be used to represent a quadruplet of values,
4
- * such as a row or column in a transformation matrix.
5
- */
6
- export interface Vector4 {
7
- x: number;
8
- y: number;
9
- z: number;
10
- w: number;
11
- }
12
- /**
13
- * Returns a new Vector4. If `value` is undefined, then `{x: 0, y: 0, z: 0,
14
- * w: 0}` is returned.
15
- */
16
- export declare function create(value?: Partial<Vector4>): Vector4;
17
- /**
18
- * Parses a JSON string representation of a `Vector4`.
19
- *
20
- * @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
21
- * @returns A parsed `Vector4`.
22
- */
23
- export declare function fromJson(json: string): Vector4;