@flighthq/geometry 0.1.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/aabb.d.ts +88 -0
- package/dist/aabb.d.ts.map +1 -0
- package/dist/aabb.js +230 -0
- package/dist/aabb.js.map +1 -0
- package/dist/boundingSphere.d.ts +62 -0
- package/dist/boundingSphere.d.ts.map +1 -0
- package/dist/boundingSphere.js +188 -0
- package/dist/boundingSphere.js.map +1 -0
- package/dist/capsule.d.ts +38 -0
- package/dist/capsule.d.ts.map +1 -0
- package/dist/capsule.js +215 -0
- package/dist/capsule.js.map +1 -0
- package/dist/frustum.d.ts +49 -0
- package/dist/frustum.d.ts.map +1 -0
- package/dist/frustum.js +149 -0
- package/dist/frustum.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/matrix.d.ts +152 -0
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +488 -0
- package/dist/matrix.js.map +1 -0
- package/dist/matrix3.d.ts +63 -0
- package/dist/matrix3.d.ts.map +1 -0
- package/dist/matrix3.js +408 -0
- package/dist/matrix3.js.map +1 -0
- package/dist/matrix3Pool.d.ts +6 -0
- package/dist/matrix3Pool.d.ts.map +1 -0
- package/dist/matrix3Pool.js +26 -0
- package/dist/matrix3Pool.js.map +1 -0
- package/dist/matrix4.d.ts +238 -0
- package/dist/matrix4.d.ts.map +1 -0
- package/dist/matrix4.js +931 -0
- package/dist/matrix4.js.map +1 -0
- package/dist/matrix4Pool.d.ts +6 -0
- package/dist/matrix4Pool.d.ts.map +1 -0
- package/dist/matrix4Pool.js +26 -0
- package/dist/matrix4Pool.js.map +1 -0
- package/dist/matrixPool.d.ts +6 -0
- package/dist/matrixPool.d.ts.map +1 -0
- package/dist/matrixPool.js +26 -0
- package/dist/matrixPool.js.map +1 -0
- package/dist/obb.d.ts +44 -0
- package/dist/obb.d.ts.map +1 -0
- package/dist/obb.js +248 -0
- package/dist/obb.js.map +1 -0
- package/dist/plane.d.ts +66 -0
- package/dist/plane.d.ts.map +1 -0
- package/dist/plane.js +140 -0
- package/dist/plane.js.map +1 -0
- package/dist/quaternion.d.ts +128 -0
- package/dist/quaternion.d.ts.map +1 -0
- package/dist/quaternion.js +508 -0
- package/dist/quaternion.js.map +1 -0
- package/dist/quaternionPool.d.ts +6 -0
- package/dist/quaternionPool.d.ts.map +1 -0
- package/dist/quaternionPool.js +29 -0
- package/dist/quaternionPool.js.map +1 -0
- package/dist/ray3d.d.ts +69 -0
- package/dist/ray3d.d.ts.map +1 -0
- package/dist/ray3d.js +264 -0
- package/dist/ray3d.js.map +1 -0
- package/dist/rectangle.d.ts +56 -0
- package/dist/rectangle.d.ts.map +1 -0
- package/dist/rectangle.js +235 -0
- package/dist/rectangle.js.map +1 -0
- package/dist/rectanglePool.d.ts +6 -0
- package/dist/rectanglePool.d.ts.map +1 -0
- package/dist/rectanglePool.js +29 -0
- package/dist/rectanglePool.js.map +1 -0
- package/dist/typedarray.d.ts +4 -0
- package/dist/typedarray.d.ts.map +1 -0
- package/dist/typedarray.js +25 -0
- package/dist/typedarray.js.map +1 -0
- package/dist/vector2.d.ts +130 -0
- package/dist/vector2.d.ts.map +1 -0
- package/dist/vector2.js +250 -0
- package/dist/vector2.js.map +1 -0
- package/dist/vector2Pool.d.ts +6 -0
- package/dist/vector2Pool.d.ts.map +1 -0
- package/dist/vector2Pool.js +20 -0
- package/dist/vector2Pool.js.map +1 -0
- package/dist/vector3.d.ts +220 -0
- package/dist/vector3.d.ts.map +1 -0
- package/dist/vector3.js +380 -0
- package/dist/vector3.js.map +1 -0
- package/dist/vector3Pool.d.ts +6 -0
- package/dist/vector3Pool.d.ts.map +1 -0
- package/dist/vector3Pool.js +28 -0
- package/dist/vector3Pool.js.map +1 -0
- package/dist/vector4.d.ts +180 -0
- package/dist/vector4.d.ts.map +1 -0
- package/dist/vector4.js +333 -0
- package/dist/vector4.js.map +1 -0
- package/dist/vector4Pool.d.ts +6 -0
- package/dist/vector4Pool.d.ts.map +1 -0
- package/dist/vector4Pool.js +29 -0
- package/dist/vector4Pool.js.map +1 -0
- package/package.json +38 -0
- package/src/aabb.test.ts +341 -0
- package/src/boundingSphere.test.ts +247 -0
- package/src/capsule.test.ts +157 -0
- package/src/frustum.test.ts +160 -0
- package/src/matrix.test.ts +1111 -0
- package/src/matrix3.test.ts +752 -0
- package/src/matrix3Pool.test.ts +73 -0
- package/src/matrix4.test.ts +1627 -0
- package/src/matrix4Pool.test.ts +71 -0
- package/src/matrixPool.test.ts +69 -0
- package/src/obb.test.ts +183 -0
- package/src/plane.test.ts +225 -0
- package/src/quaternion.test.ts +531 -0
- package/src/quaternionPool.test.ts +64 -0
- package/src/ray3d.test.ts +297 -0
- package/src/rectangle.test.ts +982 -0
- package/src/rectanglePool.test.ts +71 -0
- package/src/typedarray.test.ts +118 -0
- package/src/vector2.test.ts +958 -0
- package/src/vector2Pool.test.ts +65 -0
- package/src/vector3.test.ts +749 -0
- package/src/vector3Pool.test.ts +68 -0
- package/src/vector4.test.ts +660 -0
- package/src/vector4Pool.test.ts +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector3Pool.js","sourceRoot":"","sources":["../src/vector3Pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,mBAAmB;IACjC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAU,CAAC;IAEf,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,CAAC,GAAG,IAAI,CAAC,GAAG,EAAa,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,CAAC,GAAG,aAAa,EAAE,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAU;IACvC,IAAI,CAAC,CAAC;QAAE,OAAO;IACf,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACf,CAAC;AAED,MAAM,IAAI,GAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { Vector3Like, Vector4, Vector4Like } from '@flighthq/types';
|
|
2
|
+
/**
|
|
3
|
+
* Adds the x, y, z and w components of two vector objects
|
|
4
|
+
* and writes to out.
|
|
5
|
+
*/
|
|
6
|
+
export declare function addVector4(out: Vector4Like, a: Readonly<Vector4Like>, b: Readonly<Vector4Like>): void;
|
|
7
|
+
/**
|
|
8
|
+
* Clamps each component of a Vector4Like independently to [min, max].
|
|
9
|
+
*
|
|
10
|
+
* Safe when `out` aliases `value`, `min`, or `max`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function clampVector4(out: Vector4Like, value: Readonly<Vector4Like>, min: Readonly<Vector4Like>, max: Readonly<Vector4Like>): void;
|
|
13
|
+
export declare function cloneVector4(source: Readonly<Vector4Like>): Vector4;
|
|
14
|
+
/**
|
|
15
|
+
* Copies the x, y, z and w components of another vector.
|
|
16
|
+
*/
|
|
17
|
+
export declare function copyVector4(out: Vector4Like, source: Readonly<Vector4Like>): void;
|
|
18
|
+
/**
|
|
19
|
+
* The Vector4Like class represents a vector or point in four-dimensional space using the
|
|
20
|
+
* Cartesian coordinates x, y, z, and w.
|
|
21
|
+
*
|
|
22
|
+
* In this space, each component represents an independent axis. When Vector4Like is used
|
|
23
|
+
* for three-dimensional graphics or homogeneous coordinates, the x, y, and z components
|
|
24
|
+
* typically represent spatial position, while the w component may be used for perspective
|
|
25
|
+
* projection or other higher-dimensional calculations.
|
|
26
|
+
*
|
|
27
|
+
* Invariants:
|
|
28
|
+
*
|
|
29
|
+
* - `X_AXIS = new Vector4Like(1, 0, 0, 0);`
|
|
30
|
+
* - `Y_AXIS = new Vector4Like(0, 1, 0, 0);`
|
|
31
|
+
* - `Z_AXIS = new Vector4Like(0, 0, 1, 0);`
|
|
32
|
+
* - `W_UNIT = new Vector4Like(0, 0, 0, 1);`
|
|
33
|
+
* - `length = Math.sqrt(x ** 2 + y ** 2 + z ** 2 + w ** 2);`
|
|
34
|
+
* - `lengthSquared = x ** 2 + y ** 2 + z ** 2 + w ** 2;`
|
|
35
|
+
*/
|
|
36
|
+
export declare function createVector4(x?: number, y?: number, z?: number, w?: number): Vector4;
|
|
37
|
+
/**
|
|
38
|
+
* Component-wise division of two vectors (Hadamard division). Each component of
|
|
39
|
+
* `source` is divided by the corresponding component of `divisor`. Components with a
|
|
40
|
+
* zero divisor produce `0` in the output.
|
|
41
|
+
*
|
|
42
|
+
* Safe when `out` aliases `source` or `divisor`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function divideVector4(out: Vector4Like, source: Readonly<Vector4Like>, divisor: Readonly<Vector4Like>): void;
|
|
45
|
+
export declare function equalsVector4(a: Readonly<Vector4Like> | null | undefined, b: Readonly<Vector4Like> | null | undefined): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the angle in radians between two vectors. The returned angle is the
|
|
48
|
+
* smallest radian the first Vector4Like object rotates until it aligns with the
|
|
49
|
+
* second Vector4Like object.
|
|
50
|
+
**/
|
|
51
|
+
export declare function getVector4AngleBetween(a: Readonly<Vector4Like>, b: Readonly<Vector4Like>): number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the distance between two Vector4Like objects.
|
|
54
|
+
**/
|
|
55
|
+
export declare function getVector4Distance(a: Readonly<Vector4Like>, b: Readonly<Vector4Like>): number;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the distance (squared) between two Vector4Like objects.
|
|
58
|
+
*
|
|
59
|
+
* This avoids Math.sqrt for better performance.
|
|
60
|
+
**/
|
|
61
|
+
export declare function getVector4DistanceSquared(a: Readonly<Vector4Like>, b: Readonly<Vector4Like>): number;
|
|
62
|
+
/**
|
|
63
|
+
* If the current Vector4Like object and the one specified as the parameter are unit
|
|
64
|
+
* vertices, this method returns the cosine of the angle between the two vertices.
|
|
65
|
+
* Unit vertices are vertices that point to the same direction but their length is
|
|
66
|
+
* one. They remove the length of the vector as a factor in the result. You can use
|
|
67
|
+
* the `normalize()` method to convert a vector to a unit vector.
|
|
68
|
+
**/
|
|
69
|
+
export declare function getVector4Dot(a: Readonly<Vector4Like>, b: Readonly<Vector4Like>): number;
|
|
70
|
+
/**
|
|
71
|
+
* The length, magnitude, of the current Vector4Like object from the origin (0,0,0) to
|
|
72
|
+
* the object's x, y, z and w coordinates. A unit vector has
|
|
73
|
+
* a length or magnitude of one.
|
|
74
|
+
**/
|
|
75
|
+
export declare function getVector4Length(source: Readonly<Vector4Like>): number;
|
|
76
|
+
/**
|
|
77
|
+
* The square of the length of the current Vector4Like object, calculated using the `x`,
|
|
78
|
+
* `y`, `z`, and 'w' properties. Use the `lengthSquared()`
|
|
79
|
+
* method whenever possible instead of the slower `Math.sqrt()` method call of the
|
|
80
|
+
* `Vector4Like.length()` method.
|
|
81
|
+
**/
|
|
82
|
+
export declare function getVector4LengthSquared(source: Readonly<Vector4Like>): number;
|
|
83
|
+
/**
|
|
84
|
+
* Linear interpolation between two Vector4Like objects at parameter `t` in [0, 1].
|
|
85
|
+
* `t=0` returns `a`; `t=1` returns `b`.
|
|
86
|
+
*
|
|
87
|
+
* Safe when `out` aliases `a` or `b` (all inputs are read into locals first).
|
|
88
|
+
*/
|
|
89
|
+
export declare function interpolateVector4(out: Vector4Like, a: Readonly<Vector4Like>, b: Readonly<Vector4Like>, t: number): void;
|
|
90
|
+
/**
|
|
91
|
+
* Writes the per-component maximum of two vectors.
|
|
92
|
+
*
|
|
93
|
+
* Safe when `out` aliases `a` or `b`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function maxVector4(out: Vector4Like, a: Readonly<Vector4Like>, b: Readonly<Vector4Like>): void;
|
|
96
|
+
/**
|
|
97
|
+
* Writes the per-component minimum of two vectors.
|
|
98
|
+
*
|
|
99
|
+
* Safe when `out` aliases `a` or `b`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function minVector4(out: Vector4Like, a: Readonly<Vector4Like>, b: Readonly<Vector4Like>): void;
|
|
102
|
+
/**
|
|
103
|
+
* Component-wise product of two vectors (Hadamard product).
|
|
104
|
+
*
|
|
105
|
+
* Safe when `out` aliases `a` or `b`.
|
|
106
|
+
*/
|
|
107
|
+
export declare function multiplyVector4(out: Vector4Like, a: Readonly<Vector4Like>, b: Readonly<Vector4Like>): void;
|
|
108
|
+
/**
|
|
109
|
+
* Compares the elements of the current Vector4Like object with the elements of a
|
|
110
|
+
* specified Vector4Like object to determine whether they are nearly equal.
|
|
111
|
+
*
|
|
112
|
+
* The two Vector4Like objects are nearly equal if the value of all the elements of the two
|
|
113
|
+
* vertices are equal, or the result of the comparison is within the tolerance range.
|
|
114
|
+
**/
|
|
115
|
+
export declare function nearEqualsVector4(a: Readonly<Vector4Like>, b: Readonly<Vector4Like>, tolerance?: number): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Sets the current Vector4Like object to its inverse. The inverse object is also
|
|
118
|
+
* considered the opposite of the original object. The value of the `x`, `y`, and `z`
|
|
119
|
+
* properties of the current Vector4Like object is changed to -x, -y, and -z.
|
|
120
|
+
**/
|
|
121
|
+
export declare function negateVector4(out: Vector4Like, source: Readonly<Vector4Like>): void;
|
|
122
|
+
/**
|
|
123
|
+
* Converts a Vector4Like object to a unit vector by dividing all elements
|
|
124
|
+
* (x, y, z and w) by the length of the vector.
|
|
125
|
+
*
|
|
126
|
+
* Returns the original length.
|
|
127
|
+
**/
|
|
128
|
+
export declare function normalizeVector4(out: Vector4Like, source: Readonly<Vector4Like>): number;
|
|
129
|
+
/**
|
|
130
|
+
* Offsets each component of the current Vector4Like object by a scalar per axis.
|
|
131
|
+
**/
|
|
132
|
+
export declare function offsetVector4(out: Vector4Like, source: Readonly<Vector4Like>, dx: number, dy: number, dz: number, dw: number): void;
|
|
133
|
+
/**
|
|
134
|
+
* Divides the value of the `x`, `y`, and `z` properties of the current Vector4Like
|
|
135
|
+
* object by the value of its `w` property.
|
|
136
|
+
**/
|
|
137
|
+
export declare function projectVector4(out: Vector3Like, source: Readonly<Vector4Like>): void;
|
|
138
|
+
/**
|
|
139
|
+
* Reflects an incident vector about a unit normal. The result is the reflection of
|
|
140
|
+
* `incident` across the hyperplane whose normal is `normal`.
|
|
141
|
+
*
|
|
142
|
+
* Formula: out = incident - 2 * dot(incident, normal) * normal
|
|
143
|
+
*
|
|
144
|
+
* Safe when `out` aliases `incident` or `normal`.
|
|
145
|
+
*/
|
|
146
|
+
export declare function reflectVector4(out: Vector4Like, incident: Readonly<Vector4Like>, normal: Readonly<Vector4Like>): void;
|
|
147
|
+
/**
|
|
148
|
+
* Scales the current Vector4Like object by a scalar, a magnitude. The Vector4Like object's
|
|
149
|
+
* x, y, z and w elements are multiplied by the provided scalar number.
|
|
150
|
+
**/
|
|
151
|
+
export declare function scaleVector4(out: Vector4Like, source: Readonly<Vector4Like>, scalar: number): void;
|
|
152
|
+
/**
|
|
153
|
+
* Sets the members of Vector4Like to the specified values
|
|
154
|
+
**/
|
|
155
|
+
export declare function setVector4(out: Vector4Like, x: number, y: number, z: number, w: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* Reads a Vector4Like from a Float32Array at a byte offset.
|
|
158
|
+
*/
|
|
159
|
+
export declare function setVector4FromFloat32Array(out: Vector4Like, offset: number, source: Readonly<Float32Array>): void;
|
|
160
|
+
/**
|
|
161
|
+
* Copies the x, y, and z components of a Vector3Like into a Vector4Like, setting w to the
|
|
162
|
+
* given value (default 0). Use `w = 1` for a position, `w = 0` for a direction.
|
|
163
|
+
*
|
|
164
|
+
* Safe when `out` aliases any part of `source`.
|
|
165
|
+
*/
|
|
166
|
+
export declare function setVector4FromVector3(out: Vector4Like, source: Readonly<Vector3Like>, w?: number): void;
|
|
167
|
+
/**
|
|
168
|
+
* Subtracts the value of the x, y, z and w elements of the current Vector4Like object
|
|
169
|
+
* from the values of the x, y, z and w elements of another Vector4Like object.
|
|
170
|
+
**/
|
|
171
|
+
export declare function subtractVector4(out: Vector4Like, source: Readonly<Vector4Like>, other: Readonly<Vector4Like>): void;
|
|
172
|
+
/**
|
|
173
|
+
* Writes a Vector4Like into a Float32Array at a byte offset.
|
|
174
|
+
*/
|
|
175
|
+
export declare function writeVector4ToFloat32Array(out: Float32Array, offset: number, source: Readonly<Vector4Like>): void;
|
|
176
|
+
export declare const VECTOR4_W_UNIT: Readonly<Vector4>;
|
|
177
|
+
export declare const VECTOR4_X_AXIS: Readonly<Vector4>;
|
|
178
|
+
export declare const VECTOR4_Y_AXIS: Readonly<Vector4>;
|
|
179
|
+
export declare const VECTOR4_Z_AXIS: Readonly<Vector4>;
|
|
180
|
+
//# sourceMappingURL=vector4.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector4.d.ts","sourceRoot":"","sources":["../src/vector4.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAKrG;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC5B,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC1B,GAAG,EAAE,QAAQ,CAAC,WAA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AAI,GAAG,IAAI,CAQlG;AAED;;;IAGI;AACJ,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAKnH;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAKjH;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,OAAO,CAA6B,CAAC;AAC3E,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,OAAO,CAA6B,CAAC;AAC3E,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,OAAO,CAA6B,CAAC;AAC3E,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,OAAO,CAA6B,CAAC"}
|
package/dist/vector4.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { createEntity } from '@flighthq/entity';
|
|
2
|
+
/**
|
|
3
|
+
* Adds the x, y, z and w components of two vector objects
|
|
4
|
+
* and writes to out.
|
|
5
|
+
*/
|
|
6
|
+
export function addVector4(out, a, b) {
|
|
7
|
+
out.x = a.x + b.x;
|
|
8
|
+
out.y = a.y + b.y;
|
|
9
|
+
out.z = a.z + b.z;
|
|
10
|
+
out.w = a.w + b.w;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Clamps each component of a Vector4Like independently to [min, max].
|
|
14
|
+
*
|
|
15
|
+
* Safe when `out` aliases `value`, `min`, or `max`.
|
|
16
|
+
*/
|
|
17
|
+
export function clampVector4(out, value, min, max) {
|
|
18
|
+
const vx = value.x, vy = value.y, vz = value.z, vw = value.w;
|
|
19
|
+
const minX = min.x, minY = min.y, minZ = min.z, minW = min.w;
|
|
20
|
+
const maxX = max.x, maxY = max.y, maxZ = max.z, maxW = max.w;
|
|
21
|
+
out.x = vx < minX ? minX : vx > maxX ? maxX : vx;
|
|
22
|
+
out.y = vy < minY ? minY : vy > maxY ? maxY : vy;
|
|
23
|
+
out.z = vz < minZ ? minZ : vz > maxZ ? maxZ : vz;
|
|
24
|
+
out.w = vw < minW ? minW : vw > maxW ? maxW : vw;
|
|
25
|
+
}
|
|
26
|
+
export function cloneVector4(source) {
|
|
27
|
+
return createVector4(source.x, source.y, source.z, source.w);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Copies the x, y, z and w components of another vector.
|
|
31
|
+
*/
|
|
32
|
+
export function copyVector4(out, source) {
|
|
33
|
+
out.x = source.x;
|
|
34
|
+
out.y = source.y;
|
|
35
|
+
out.z = source.z;
|
|
36
|
+
out.w = source.w;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The Vector4Like class represents a vector or point in four-dimensional space using the
|
|
40
|
+
* Cartesian coordinates x, y, z, and w.
|
|
41
|
+
*
|
|
42
|
+
* In this space, each component represents an independent axis. When Vector4Like is used
|
|
43
|
+
* for three-dimensional graphics or homogeneous coordinates, the x, y, and z components
|
|
44
|
+
* typically represent spatial position, while the w component may be used for perspective
|
|
45
|
+
* projection or other higher-dimensional calculations.
|
|
46
|
+
*
|
|
47
|
+
* Invariants:
|
|
48
|
+
*
|
|
49
|
+
* - `X_AXIS = new Vector4Like(1, 0, 0, 0);`
|
|
50
|
+
* - `Y_AXIS = new Vector4Like(0, 1, 0, 0);`
|
|
51
|
+
* - `Z_AXIS = new Vector4Like(0, 0, 1, 0);`
|
|
52
|
+
* - `W_UNIT = new Vector4Like(0, 0, 0, 1);`
|
|
53
|
+
* - `length = Math.sqrt(x ** 2 + y ** 2 + z ** 2 + w ** 2);`
|
|
54
|
+
* - `lengthSquared = x ** 2 + y ** 2 + z ** 2 + w ** 2;`
|
|
55
|
+
*/
|
|
56
|
+
export function createVector4(x, y, z, w) {
|
|
57
|
+
return createEntity({ x: x ?? 0, y: y ?? 0, z: z ?? 0, w: w ?? 0 });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Component-wise division of two vectors (Hadamard division). Each component of
|
|
61
|
+
* `source` is divided by the corresponding component of `divisor`. Components with a
|
|
62
|
+
* zero divisor produce `0` in the output.
|
|
63
|
+
*
|
|
64
|
+
* Safe when `out` aliases `source` or `divisor`.
|
|
65
|
+
*/
|
|
66
|
+
export function divideVector4(out, source, divisor) {
|
|
67
|
+
const sx = source.x, sy = source.y, sz = source.z, sw = source.w;
|
|
68
|
+
const dx = divisor.x, dy = divisor.y, dz = divisor.z, dw = divisor.w;
|
|
69
|
+
out.x = dx !== 0 ? sx / dx : 0;
|
|
70
|
+
out.y = dy !== 0 ? sy / dy : 0;
|
|
71
|
+
out.z = dz !== 0 ? sz / dz : 0;
|
|
72
|
+
out.w = dw !== 0 ? sw / dw : 0;
|
|
73
|
+
}
|
|
74
|
+
export function equalsVector4(a, b) {
|
|
75
|
+
if (!a || !b)
|
|
76
|
+
return false;
|
|
77
|
+
return a.x === b.x && a.y === b.y && a.z === b.z && a.w === b.w;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Returns the angle in radians between two vectors. The returned angle is the
|
|
81
|
+
* smallest radian the first Vector4Like object rotates until it aligns with the
|
|
82
|
+
* second Vector4Like object.
|
|
83
|
+
**/
|
|
84
|
+
export function getVector4AngleBetween(a, b) {
|
|
85
|
+
const la = getVector4Length(a);
|
|
86
|
+
const lb = getVector4Length(b);
|
|
87
|
+
if (la === 0 || lb === 0)
|
|
88
|
+
return NaN; // undefined angle
|
|
89
|
+
const _dot = getVector4Dot(a, b) / (la * lb);
|
|
90
|
+
// clamp dot to [-1, 1] to avoid floating point errors
|
|
91
|
+
return Math.acos(Math.min(1, Math.max(-1, _dot)));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns the distance between two Vector4Like objects.
|
|
95
|
+
**/
|
|
96
|
+
export function getVector4Distance(a, b) {
|
|
97
|
+
const x = b.x - a.x;
|
|
98
|
+
const y = b.y - a.y;
|
|
99
|
+
const z = b.z - a.z;
|
|
100
|
+
const w = b.w - a.w;
|
|
101
|
+
return Math.sqrt(x ** 2 + y ** 2 + z ** 2 + w ** 2);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the distance (squared) between two Vector4Like objects.
|
|
105
|
+
*
|
|
106
|
+
* This avoids Math.sqrt for better performance.
|
|
107
|
+
**/
|
|
108
|
+
export function getVector4DistanceSquared(a, b) {
|
|
109
|
+
const x = b.x - a.x;
|
|
110
|
+
const y = b.y - a.y;
|
|
111
|
+
const z = b.z - a.z;
|
|
112
|
+
const w = b.w - a.w;
|
|
113
|
+
return x ** 2 + y ** 2 + z ** 2 + w ** 2;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* If the current Vector4Like object and the one specified as the parameter are unit
|
|
117
|
+
* vertices, this method returns the cosine of the angle between the two vertices.
|
|
118
|
+
* Unit vertices are vertices that point to the same direction but their length is
|
|
119
|
+
* one. They remove the length of the vector as a factor in the result. You can use
|
|
120
|
+
* the `normalize()` method to convert a vector to a unit vector.
|
|
121
|
+
**/
|
|
122
|
+
export function getVector4Dot(a, b) {
|
|
123
|
+
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The length, magnitude, of the current Vector4Like object from the origin (0,0,0) to
|
|
127
|
+
* the object's x, y, z and w coordinates. A unit vector has
|
|
128
|
+
* a length or magnitude of one.
|
|
129
|
+
**/
|
|
130
|
+
export function getVector4Length(source) {
|
|
131
|
+
return Math.sqrt(source.x ** 2 + source.y ** 2 + source.z ** 2 + source.w ** 2);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The square of the length of the current Vector4Like object, calculated using the `x`,
|
|
135
|
+
* `y`, `z`, and 'w' properties. Use the `lengthSquared()`
|
|
136
|
+
* method whenever possible instead of the slower `Math.sqrt()` method call of the
|
|
137
|
+
* `Vector4Like.length()` method.
|
|
138
|
+
**/
|
|
139
|
+
export function getVector4LengthSquared(source) {
|
|
140
|
+
return source.x ** 2 + source.y ** 2 + source.z ** 2 + source.w ** 2;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Linear interpolation between two Vector4Like objects at parameter `t` in [0, 1].
|
|
144
|
+
* `t=0` returns `a`; `t=1` returns `b`.
|
|
145
|
+
*
|
|
146
|
+
* Safe when `out` aliases `a` or `b` (all inputs are read into locals first).
|
|
147
|
+
*/
|
|
148
|
+
export function interpolateVector4(out, a, b, t) {
|
|
149
|
+
const ax = a.x, ay = a.y, az = a.z, aw = a.w;
|
|
150
|
+
out.x = ax + t * (b.x - ax);
|
|
151
|
+
out.y = ay + t * (b.y - ay);
|
|
152
|
+
out.z = az + t * (b.z - az);
|
|
153
|
+
out.w = aw + t * (b.w - aw);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Writes the per-component maximum of two vectors.
|
|
157
|
+
*
|
|
158
|
+
* Safe when `out` aliases `a` or `b`.
|
|
159
|
+
*/
|
|
160
|
+
export function maxVector4(out, a, b) {
|
|
161
|
+
out.x = a.x > b.x ? a.x : b.x;
|
|
162
|
+
out.y = a.y > b.y ? a.y : b.y;
|
|
163
|
+
out.z = a.z > b.z ? a.z : b.z;
|
|
164
|
+
out.w = a.w > b.w ? a.w : b.w;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Writes the per-component minimum of two vectors.
|
|
168
|
+
*
|
|
169
|
+
* Safe when `out` aliases `a` or `b`.
|
|
170
|
+
*/
|
|
171
|
+
export function minVector4(out, a, b) {
|
|
172
|
+
out.x = a.x < b.x ? a.x : b.x;
|
|
173
|
+
out.y = a.y < b.y ? a.y : b.y;
|
|
174
|
+
out.z = a.z < b.z ? a.z : b.z;
|
|
175
|
+
out.w = a.w < b.w ? a.w : b.w;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Component-wise product of two vectors (Hadamard product).
|
|
179
|
+
*
|
|
180
|
+
* Safe when `out` aliases `a` or `b`.
|
|
181
|
+
*/
|
|
182
|
+
export function multiplyVector4(out, a, b) {
|
|
183
|
+
out.x = a.x * b.x;
|
|
184
|
+
out.y = a.y * b.y;
|
|
185
|
+
out.z = a.z * b.z;
|
|
186
|
+
out.w = a.w * b.w;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Compares the elements of the current Vector4Like object with the elements of a
|
|
190
|
+
* specified Vector4Like object to determine whether they are nearly equal.
|
|
191
|
+
*
|
|
192
|
+
* The two Vector4Like objects are nearly equal if the value of all the elements of the two
|
|
193
|
+
* vertices are equal, or the result of the comparison is within the tolerance range.
|
|
194
|
+
**/
|
|
195
|
+
export function nearEqualsVector4(a, b, tolerance = 1e-6) {
|
|
196
|
+
return (Math.abs(a.x - b.x) < tolerance &&
|
|
197
|
+
Math.abs(a.y - b.y) < tolerance &&
|
|
198
|
+
Math.abs(a.z - b.z) < tolerance &&
|
|
199
|
+
Math.abs(a.w - b.w) < tolerance);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Sets the current Vector4Like object to its inverse. The inverse object is also
|
|
203
|
+
* considered the opposite of the original object. The value of the `x`, `y`, and `z`
|
|
204
|
+
* properties of the current Vector4Like object is changed to -x, -y, and -z.
|
|
205
|
+
**/
|
|
206
|
+
export function negateVector4(out, source) {
|
|
207
|
+
out.x = source.x * -1;
|
|
208
|
+
out.y = source.y * -1;
|
|
209
|
+
out.z = source.z * -1;
|
|
210
|
+
out.w = source.w * -1;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Converts a Vector4Like object to a unit vector by dividing all elements
|
|
214
|
+
* (x, y, z and w) by the length of the vector.
|
|
215
|
+
*
|
|
216
|
+
* Returns the original length.
|
|
217
|
+
**/
|
|
218
|
+
export function normalizeVector4(out, source) {
|
|
219
|
+
const l = getVector4Length(source);
|
|
220
|
+
if (l !== 0) {
|
|
221
|
+
out.x = source.x / l;
|
|
222
|
+
out.y = source.y / l;
|
|
223
|
+
out.z = source.z / l;
|
|
224
|
+
out.w = source.w / l;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
out.x = 0;
|
|
228
|
+
out.y = 0;
|
|
229
|
+
out.z = 0;
|
|
230
|
+
out.w = 0;
|
|
231
|
+
}
|
|
232
|
+
return l;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Offsets each component of the current Vector4Like object by a scalar per axis.
|
|
236
|
+
**/
|
|
237
|
+
export function offsetVector4(out, source, dx, dy, dz, dw) {
|
|
238
|
+
out.x = source.x + dx;
|
|
239
|
+
out.y = source.y + dy;
|
|
240
|
+
out.z = source.z + dz;
|
|
241
|
+
out.w = source.w + dw;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Divides the value of the `x`, `y`, and `z` properties of the current Vector4Like
|
|
245
|
+
* object by the value of its `w` property.
|
|
246
|
+
**/
|
|
247
|
+
export function projectVector4(out, source) {
|
|
248
|
+
out.x = source.x / source.w;
|
|
249
|
+
out.y = source.y / source.w;
|
|
250
|
+
out.z = source.z / source.w;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Reflects an incident vector about a unit normal. The result is the reflection of
|
|
254
|
+
* `incident` across the hyperplane whose normal is `normal`.
|
|
255
|
+
*
|
|
256
|
+
* Formula: out = incident - 2 * dot(incident, normal) * normal
|
|
257
|
+
*
|
|
258
|
+
* Safe when `out` aliases `incident` or `normal`.
|
|
259
|
+
*/
|
|
260
|
+
export function reflectVector4(out, incident, normal) {
|
|
261
|
+
const ix = incident.x, iy = incident.y, iz = incident.z, iw = incident.w;
|
|
262
|
+
const nx = normal.x, ny = normal.y, nz = normal.z, nw = normal.w;
|
|
263
|
+
const twoDot = 2 * (ix * nx + iy * ny + iz * nz + iw * nw);
|
|
264
|
+
out.x = ix - twoDot * nx;
|
|
265
|
+
out.y = iy - twoDot * ny;
|
|
266
|
+
out.z = iz - twoDot * nz;
|
|
267
|
+
out.w = iw - twoDot * nw;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Scales the current Vector4Like object by a scalar, a magnitude. The Vector4Like object's
|
|
271
|
+
* x, y, z and w elements are multiplied by the provided scalar number.
|
|
272
|
+
**/
|
|
273
|
+
export function scaleVector4(out, source, scalar) {
|
|
274
|
+
out.x = source.x * scalar;
|
|
275
|
+
out.y = source.y * scalar;
|
|
276
|
+
out.z = source.z * scalar;
|
|
277
|
+
out.w = source.w * scalar;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Sets the members of Vector4Like to the specified values
|
|
281
|
+
**/
|
|
282
|
+
export function setVector4(out, x, y, z, w) {
|
|
283
|
+
out.x = x;
|
|
284
|
+
out.y = y;
|
|
285
|
+
out.z = z;
|
|
286
|
+
out.w = w;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Reads a Vector4Like from a Float32Array at a byte offset.
|
|
290
|
+
*/
|
|
291
|
+
export function setVector4FromFloat32Array(out, offset, source) {
|
|
292
|
+
out.x = source[offset];
|
|
293
|
+
out.y = source[offset + 1];
|
|
294
|
+
out.z = source[offset + 2];
|
|
295
|
+
out.w = source[offset + 3];
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Copies the x, y, and z components of a Vector3Like into a Vector4Like, setting w to the
|
|
299
|
+
* given value (default 0). Use `w = 1` for a position, `w = 0` for a direction.
|
|
300
|
+
*
|
|
301
|
+
* Safe when `out` aliases any part of `source`.
|
|
302
|
+
*/
|
|
303
|
+
export function setVector4FromVector3(out, source, w = 0) {
|
|
304
|
+
const x = source.x, y = source.y, z = source.z;
|
|
305
|
+
out.x = x;
|
|
306
|
+
out.y = y;
|
|
307
|
+
out.z = z;
|
|
308
|
+
out.w = w;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Subtracts the value of the x, y, z and w elements of the current Vector4Like object
|
|
312
|
+
* from the values of the x, y, z and w elements of another Vector4Like object.
|
|
313
|
+
**/
|
|
314
|
+
export function subtractVector4(out, source, other) {
|
|
315
|
+
out.x = source.x - other.x;
|
|
316
|
+
out.y = source.y - other.y;
|
|
317
|
+
out.z = source.z - other.z;
|
|
318
|
+
out.w = source.w - other.w;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Writes a Vector4Like into a Float32Array at a byte offset.
|
|
322
|
+
*/
|
|
323
|
+
export function writeVector4ToFloat32Array(out, offset, source) {
|
|
324
|
+
out[offset] = source.x;
|
|
325
|
+
out[offset + 1] = source.y;
|
|
326
|
+
out[offset + 2] = source.z;
|
|
327
|
+
out[offset + 3] = source.w;
|
|
328
|
+
}
|
|
329
|
+
export const VECTOR4_W_UNIT = createVector4(0, 0, 0, 1);
|
|
330
|
+
export const VECTOR4_X_AXIS = createVector4(1, 0, 0, 0);
|
|
331
|
+
export const VECTOR4_Y_AXIS = createVector4(0, 1, 0, 0);
|
|
332
|
+
export const VECTOR4_Z_AXIS = createVector4(0, 0, 1, 0);
|
|
333
|
+
//# sourceMappingURL=vector4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector4.js","sourceRoot":"","sources":["../src/vector4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAgB,EAAE,CAAwB,EAAE,CAAwB;IAC7F,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAClB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED;;;;GAIG;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AAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Vector4 } from '@flighthq/types';
|
|
2
|
+
export declare function acquireEmptyVector4(): Vector4;
|
|
3
|
+
export declare function acquireVector4(): Vector4;
|
|
4
|
+
export declare function clearVector4Pool(): void;
|
|
5
|
+
export declare function releaseVector4(v: Vector4): void;
|
|
6
|
+
//# sourceMappingURL=vector4Pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector4Pool.d.ts","sourceRoot":"","sources":["../src/vector4Pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAI/C,wBAAgB,mBAAmB,IAAI,OAAO,CAO7C;AAED,wBAAgB,cAAc,IAAI,OAAO,CAUxC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAG/C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createVector4 } from './vector4';
|
|
2
|
+
export function acquireEmptyVector4() {
|
|
3
|
+
const v = acquireVector4();
|
|
4
|
+
v.x = 0;
|
|
5
|
+
v.y = 0;
|
|
6
|
+
v.z = 0;
|
|
7
|
+
v.w = 0;
|
|
8
|
+
return v;
|
|
9
|
+
}
|
|
10
|
+
export function acquireVector4() {
|
|
11
|
+
let v;
|
|
12
|
+
if (pool.length > 0) {
|
|
13
|
+
v = pool.pop();
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
v = createVector4();
|
|
17
|
+
}
|
|
18
|
+
return v;
|
|
19
|
+
}
|
|
20
|
+
export function clearVector4Pool() {
|
|
21
|
+
pool.length = 0;
|
|
22
|
+
}
|
|
23
|
+
export function releaseVector4(v) {
|
|
24
|
+
if (!v)
|
|
25
|
+
return;
|
|
26
|
+
pool.push(v);
|
|
27
|
+
}
|
|
28
|
+
const pool = [];
|
|
29
|
+
//# sourceMappingURL=vector4Pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector4Pool.js","sourceRoot":"","sources":["../src/vector4Pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,mBAAmB;IACjC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAU,CAAC;IAEf,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,CAAC,GAAG,IAAI,CAAC,GAAG,EAAa,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,CAAC,GAAG,aAAa,EAAE,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAU;IACvC,IAAI,CAAC,CAAC;QAAE,OAAO;IACf,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACf,CAAC;AAED,MAAM,IAAI,GAAc,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flighthq/geometry",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"src/**/*.test.ts",
|
|
16
|
+
"!dist/**/*.test.js",
|
|
17
|
+
"!dist/**/*.test.d.ts",
|
|
18
|
+
"!dist/**/*.test.js.map",
|
|
19
|
+
"!dist/**/*.test.d.ts.map"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -b",
|
|
23
|
+
"clean": "tsc -b --clean",
|
|
24
|
+
"test": "vitest run --config vitest.config.ts",
|
|
25
|
+
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
26
|
+
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
27
|
+
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@flighthq/entity": "0.1.0",
|
|
31
|
+
"@flighthq/types": "0.1.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"typescript": "^5.3.0"
|
|
35
|
+
},
|
|
36
|
+
"description": "2D/3D math primitives: vectors, matrices, rectangles, and object pools",
|
|
37
|
+
"sideEffects": false
|
|
38
|
+
}
|