@oliversalzburg/js-utils 0.0.13 → 0.0.15
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/_site/assets/navigation.js +1 -1
- package/_site/assets/search.js +1 -1
- package/_site/classes/AbstractError.html +47 -8
- package/_site/classes/Canvas.html +66 -26
- package/_site/classes/CanvasSandbox.html +76 -0
- package/_site/classes/Euler.html +217 -0
- package/_site/classes/InternalError.html +48 -9
- package/_site/classes/InvalidArgumentError.html +47 -8
- package/_site/classes/InvalidOperationError.html +47 -8
- package/_site/classes/Matrix3.html +167 -0
- package/_site/classes/NotImplementedError.html +47 -8
- package/_site/classes/PermissionViolationError.html +47 -8
- package/_site/classes/Quaternion.html +211 -0
- package/_site/classes/Random.html +60 -13
- package/_site/classes/RenderLoop.html +62 -20
- package/_site/classes/ResourceConflictError.html +47 -8
- package/_site/classes/Transformation.html +52 -0
- package/_site/classes/UnexpectedNilError.html +44 -5
- package/_site/classes/UnknownError.html +47 -8
- package/_site/classes/Vector2.html +80 -37
- package/_site/classes/Vector3.html +201 -15
- package/_site/classes/Vector4.html +156 -0
- package/_site/favicon.ico +0 -0
- package/_site/functions/addVector2.html +43 -4
- package/_site/functions/addVector3.html +44 -0
- package/_site/functions/blend.html +41 -2
- package/_site/functions/blendAdditive.html +41 -2
- package/_site/functions/blendSubtractive.html +41 -2
- package/_site/functions/clamp.html +41 -2
- package/_site/functions/coalesceOnRejection.html +48 -0
- package/_site/functions/cosDeg.html +41 -2
- package/_site/functions/crossVector3.html +44 -0
- package/_site/functions/deg2rad.html +41 -2
- package/_site/functions/difference.html +41 -2
- package/_site/functions/distance.html +41 -2
- package/_site/functions/dotVector3.html +44 -0
- package/_site/functions/errorToJSON.html +41 -2
- package/_site/functions/errorToRecord.html +41 -2
- package/_site/functions/errorToSimpleSerializable.html +41 -2
- package/_site/functions/filterType.html +41 -2
- package/_site/functions/formatString.html +41 -2
- package/_site/functions/formatStringTemplate.html +41 -2
- package/_site/functions/fromRGB.html +41 -2
- package/_site/functions/fromRGBA.html +41 -2
- package/_site/functions/getA.html +41 -2
- package/_site/functions/getB.html +41 -2
- package/_site/functions/getDocumentElementTypeById.html +41 -2
- package/_site/functions/getG.html +41 -2
- package/_site/functions/getR.html +41 -2
- package/_site/functions/intersect.html +41 -2
- package/_site/functions/is.html +41 -2
- package/_site/functions/isError.html +41 -2
- package/_site/functions/isInteger.html +41 -2
- package/_site/functions/isNil.html +41 -2
- package/_site/functions/isqrt.html +41 -2
- package/_site/functions/multiplyVector2.html +43 -4
- package/_site/functions/multiplyVector3.html +44 -0
- package/_site/functions/mustExist.html +41 -2
- package/_site/functions/nextPalette.html +42 -2
- package/_site/functions/prepareAsyncContext.html +46 -0
- package/_site/functions/putPixel32.html +47 -8
- package/_site/functions/putPixel32Add.html +47 -8
- package/_site/functions/putPixel32Sub.html +47 -8
- package/_site/functions/putSubPixel32.html +41 -2
- package/_site/functions/rad2deg.html +41 -2
- package/_site/functions/randomRange.html +41 -2
- package/_site/functions/safeRGBComponent.html +41 -2
- package/_site/functions/seedFromString.html +41 -2
- package/_site/functions/shuffleArray.html +41 -2
- package/_site/functions/sinDeg.html +41 -2
- package/_site/functions/sleep.html +41 -2
- package/_site/functions/somecolor.html +41 -2
- package/_site/functions/subtractVector2.html +43 -4
- package/_site/functions/subtractVector3.html +44 -0
- package/_site/functions/toGrayScale.html +41 -2
- package/_site/functions/unknownToError.html +41 -2
- package/_site/index.html +41 -2
- package/_site/interfaces/CanvasOptions.html +42 -3
- package/_site/interfaces/CanvasSandboxApplication.html +60 -0
- package/_site/interfaces/CanvasSandboxExpectedOptions.html +48 -0
- package/_site/interfaces/RenderLoopOptions.html +43 -4
- package/_site/modules.html +59 -3
- package/_site/types/AnyAsyncFunction.html +41 -0
- package/_site/types/AnyConstructor.html +41 -2
- package/_site/types/AnyFunction.html +41 -2
- package/_site/types/ConstructorOf.html +41 -2
- package/_site/types/FunctionReturning.html +41 -2
- package/_site/types/Maybe.html +41 -2
- package/_site/types/Mixin.html +41 -2
- package/_site/types/Nil.html +41 -2
- package/_site/types/RenderLoopCallback.html +41 -2
- package/_site/types/SerializedError.html +41 -2
- package/_site/variables/MS_PER_FRAME_60FPS.html +42 -0
- package/_site/variables/PALETTES.html +41 -2
- package/_site/variables/TWO_PI.html +41 -2
- package/_site/variables/random-1.html +41 -2
- package/docs/assets/favicon.ico +0 -0
- package/lib/Async.d.ts +3 -0
- package/lib/Async.js +17 -0
- package/lib/Async.js.map +1 -0
- package/lib/async.d.ts +24 -0
- package/lib/async.js +37 -0
- package/lib/async.js.map +1 -0
- package/lib/core.d.ts +4 -0
- package/lib/core.js.map +1 -1
- package/lib/graphics/canvas copy.d.ts +170 -0
- package/lib/graphics/canvas copy.js +300 -0
- package/lib/graphics/canvas copy.js.map +1 -0
- package/lib/graphics/canvas-sandbox.d.ts +206 -0
- package/lib/graphics/canvas-sandbox.js +272 -0
- package/lib/graphics/canvas-sandbox.js.map +1 -0
- package/lib/graphics/canvas-worker.d.ts +50 -0
- package/lib/graphics/canvas-worker.js +78 -0
- package/lib/graphics/canvas-worker.js.map +1 -0
- package/lib/graphics/canvas.d.ts +14 -9
- package/lib/graphics/canvas.js +53 -19
- package/lib/graphics/canvas.js.map +1 -1
- package/lib/graphics/core.d.ts +2 -1
- package/lib/graphics/core.js +2 -0
- package/lib/graphics/core.js.map +1 -1
- package/lib/graphics/index.d.ts +1 -0
- package/lib/graphics/index.js +1 -0
- package/lib/graphics/index.js.map +1 -1
- package/lib/graphics/render-loop.d.ts +6 -5
- package/lib/graphics/render-loop.js +18 -9
- package/lib/graphics/render-loop.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/math/euler.d.ts +19 -0
- package/lib/math/euler.js +23 -0
- package/lib/math/euler.js.map +1 -0
- package/lib/math/index.d.ts +5 -1
- package/lib/math/index.js +5 -1
- package/lib/math/index.js.map +1 -1
- package/lib/math/matrix3.d.ts +218 -0
- package/lib/math/matrix3.js +509 -0
- package/lib/math/matrix3.js.map +1 -0
- package/lib/math/quaternion.d.ts +120 -0
- package/lib/math/quaternion.js +272 -0
- package/lib/math/quaternion.js.map +1 -0
- package/lib/math/transformation.d.ts +27 -0
- package/lib/math/transformation.js +32 -0
- package/lib/math/transformation.js.map +1 -0
- package/lib/math/vector2.d.ts +19 -13
- package/lib/math/vector2.js +12 -4
- package/lib/math/vector2.js.map +1 -1
- package/lib/math/vector3.d.ts +256 -3
- package/lib/math/vector3.js +440 -1
- package/lib/math/vector3.js.map +1 -1
- package/lib/math/vector4.d.ts +183 -0
- package/lib/math/vector4.js +303 -0
- package/lib/math/vector4.js.map +1 -0
- package/lib/random.d.ts +12 -0
- package/lib/random.js +16 -0
- package/lib/random.js.map +1 -1
- package/package.json +4 -3
package/lib/math/vector3.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Matrix3 } from "./matrix3";
|
|
2
|
+
import { Transformation } from "./transformation";
|
|
1
3
|
/**
|
|
2
4
|
* A vector with 3 components, labeled: `X`, `Y`, `Z`.
|
|
3
5
|
* @group Math
|
|
@@ -21,20 +23,195 @@ export declare class Vector3 {
|
|
|
21
23
|
* @param y The Y component.
|
|
22
24
|
* @param z The Z component.
|
|
23
25
|
*/
|
|
24
|
-
constructor(x
|
|
26
|
+
constructor(x?: number, y?: number, z?: number);
|
|
27
|
+
/**
|
|
28
|
+
* Creates a copy of another {@linkcode Vector3}.
|
|
29
|
+
* @param vector The vector to copy.
|
|
30
|
+
* @returns A new vector.
|
|
31
|
+
*/
|
|
32
|
+
static fromVector3(vector: Readonly<Vector3>): Vector3;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the vector to new coordinates.
|
|
35
|
+
* @param vector The coordinates to set the vector to.
|
|
36
|
+
* @returns This instance.
|
|
37
|
+
*/
|
|
38
|
+
set(vector: Readonly<Vector3>): this;
|
|
25
39
|
/**
|
|
26
40
|
* Sets the vector to new coordinates.
|
|
27
41
|
* @param x The new X component for the vector.
|
|
28
42
|
* @param y The new Y component for the vector.
|
|
29
43
|
* @param z The new Z component for the vector.
|
|
44
|
+
* @returns This instance.
|
|
45
|
+
*/
|
|
46
|
+
setXYZ(x: number, y: number, z: number): this;
|
|
47
|
+
/**
|
|
48
|
+
* Adds another vector to this vector.
|
|
49
|
+
* @param vector The vector to add to this vector.
|
|
50
|
+
* @returns This instance.
|
|
51
|
+
*/
|
|
52
|
+
add(vector: Readonly<Vector3>): this;
|
|
53
|
+
/**
|
|
54
|
+
* Adds another vector to this vector.
|
|
55
|
+
* @param x The value to add to the X component.
|
|
56
|
+
* @param y The value to add to the Y component.
|
|
57
|
+
* @param z The value to add to the Z component.
|
|
58
|
+
* @returns This instance.
|
|
59
|
+
*/
|
|
60
|
+
addXYZ(x: number, y: number, z: number): this;
|
|
61
|
+
/**
|
|
62
|
+
* Scales another vector and adds it to this vector.
|
|
63
|
+
* @param vector The vector to add to this vector.
|
|
64
|
+
* @param scale The scaling to apply to the input vector.
|
|
65
|
+
* @returns This instance.
|
|
66
|
+
*/
|
|
67
|
+
addMultiply(vector: Readonly<Vector3>, scale: number): this;
|
|
68
|
+
/**
|
|
69
|
+
* Scales another vector and adds it to this vector.
|
|
70
|
+
* @param x The value to add to the X component.
|
|
71
|
+
* @param y The value to add to the Y component.
|
|
72
|
+
* @param z The value to add to the Z component.
|
|
73
|
+
* @param scale The scaling to apply to the input vector.
|
|
74
|
+
* @returns This instance.
|
|
75
|
+
*/
|
|
76
|
+
addMultiplyXYZ(x: number, y: number, z: number, scale: number): this;
|
|
77
|
+
/**
|
|
78
|
+
* Subtracts another vector from this vector.
|
|
79
|
+
* @param vector The vector to subtract from this vector.
|
|
80
|
+
* @returns This instance.
|
|
81
|
+
*/
|
|
82
|
+
subtract(vector: Vector3): this;
|
|
83
|
+
/**
|
|
84
|
+
* Subtracts another vector from this vector.
|
|
85
|
+
* @param x The value to subtract from the X component.
|
|
86
|
+
* @param y The value to subtract from the Y component.
|
|
87
|
+
* @param z The value to subtract from the Z component.
|
|
88
|
+
* @returns This instance.
|
|
89
|
+
*/
|
|
90
|
+
subtractXYZ(x: number, y: number, z: number): this;
|
|
91
|
+
/**
|
|
92
|
+
* Multiplies this vector by another vector.
|
|
93
|
+
* @param vector The vector to multiply with this vector.
|
|
94
|
+
* @returns This instance.
|
|
95
|
+
*/
|
|
96
|
+
multiply(vector: Readonly<Vector3>): this;
|
|
97
|
+
/**
|
|
98
|
+
* Multiplies this vector by another vector.
|
|
99
|
+
* @param x The value to multiply with the X component.
|
|
100
|
+
* @param y The value to multiply with the Y component.
|
|
101
|
+
* @param z The value to multiply with the Z component.
|
|
102
|
+
* @returns This instance.
|
|
103
|
+
*/
|
|
104
|
+
multiplyXYZ(x: number, y: number, z: number): this;
|
|
105
|
+
/**
|
|
106
|
+
* Multiplies the vector by the given scale.
|
|
107
|
+
* @param scale The scaling to apply to the vector.
|
|
108
|
+
* @returns This instance.
|
|
109
|
+
*/
|
|
110
|
+
multiplyScale(scale: number): this;
|
|
111
|
+
/**
|
|
112
|
+
* Divides this vector by another vector.
|
|
113
|
+
* @param vector The vector to divide this vector with.
|
|
114
|
+
* @returns This instance.
|
|
115
|
+
*/
|
|
116
|
+
divide(vector: Readonly<Vector3>): this;
|
|
117
|
+
/**
|
|
118
|
+
* Divides this vector by another vector.
|
|
119
|
+
* @param x The value to divide the X component with.
|
|
120
|
+
* @param y The value to divide the Y component with.
|
|
121
|
+
* @param z The value to divide the Z component with.
|
|
122
|
+
* @returns This instance.
|
|
123
|
+
*/
|
|
124
|
+
divideXYZ(x: number, y: number, z: number): this;
|
|
125
|
+
/**
|
|
126
|
+
* Divides the vector by the given scale.
|
|
127
|
+
* @param scale The scaling to apply to the vector.
|
|
128
|
+
* @returns This instance.
|
|
129
|
+
*/
|
|
130
|
+
divideScale(scale: number): this;
|
|
131
|
+
/**
|
|
132
|
+
* Inverts the direction of the vector.
|
|
133
|
+
* @returns This instance.
|
|
134
|
+
*/
|
|
135
|
+
invertAdd(): this;
|
|
136
|
+
/**
|
|
137
|
+
* Inverts the vectors scale.
|
|
138
|
+
* @returns This instance.
|
|
139
|
+
*/
|
|
140
|
+
invertMultiply(): this;
|
|
141
|
+
/**
|
|
142
|
+
* Clamps the components of the vector at the given boundary.
|
|
143
|
+
* @param floor The lowest value to allow.
|
|
144
|
+
* @param ceil The largest value to allow.
|
|
145
|
+
* @returns This instance.
|
|
146
|
+
*/
|
|
147
|
+
clamp(floor: number, ceil: number): this;
|
|
148
|
+
/**
|
|
149
|
+
* Calculates the length of the vector.
|
|
150
|
+
* @returns The length of the vector.
|
|
151
|
+
*/
|
|
152
|
+
length(): number;
|
|
153
|
+
/**
|
|
154
|
+
* Normalizes the vector.
|
|
155
|
+
* @returns This instance.
|
|
156
|
+
*/
|
|
157
|
+
normalize(): this;
|
|
158
|
+
/**
|
|
159
|
+
* Compares two vectors.
|
|
160
|
+
* @param vector The vector to compare this vector to.
|
|
161
|
+
* @returns `true` if the vectors are idently, `false` otherwise.
|
|
30
162
|
*/
|
|
31
|
-
|
|
163
|
+
compare(vector: Readonly<Vector3>): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Linearly moves this vector towards a target vector.
|
|
166
|
+
* @param vector The target vector.
|
|
167
|
+
* @param t The location on the scale, from `0` to `1`.
|
|
168
|
+
* @returns This instance.
|
|
169
|
+
*/
|
|
170
|
+
lerp(vector: Readonly<Vector3>, t: number): this;
|
|
171
|
+
/**
|
|
172
|
+
* Rotates the vector by the given rotation matrix.
|
|
173
|
+
* @param matrix The rotation matrix to apply to the vector.
|
|
174
|
+
* @returns This instance.
|
|
175
|
+
*/
|
|
176
|
+
rotate(matrix: Readonly<Matrix3>): this;
|
|
177
|
+
/**
|
|
178
|
+
* Inversely rotates the vector by the given rotation matrix.
|
|
179
|
+
* @param matrix The rotation matrix to apply to the vector.
|
|
180
|
+
* @returns This instance.
|
|
181
|
+
*/
|
|
182
|
+
rotateInverse(matrix: Readonly<Matrix3>): this;
|
|
183
|
+
/**
|
|
184
|
+
* Rotates the vector by the given rotation matrix around the given center.
|
|
185
|
+
* @param center The center around which to rotate the vector.
|
|
186
|
+
* @param matrix The rotation matrix to apply to the vector.
|
|
187
|
+
* @returns This instance.
|
|
188
|
+
*/
|
|
189
|
+
rotateAround(center: Readonly<Vector3>, matrix: Readonly<Matrix3>): this;
|
|
190
|
+
/**
|
|
191
|
+
* Inversely rotates the vector by the given rotation matrix around the given center.
|
|
192
|
+
* @param center The center around which to rotate the vector.
|
|
193
|
+
* @param matrix The rotation matrix to apply to the vector.
|
|
194
|
+
* @returns This instance.
|
|
195
|
+
*/
|
|
196
|
+
rotateAroundInverse(center: Readonly<Vector3>, matrix: Readonly<Matrix3>): this;
|
|
197
|
+
/**
|
|
198
|
+
* Transform the vector with a {@linkcode Transformation}.
|
|
199
|
+
* @param transformation The transformation to apply.
|
|
200
|
+
* @returns This instance.
|
|
201
|
+
*/
|
|
202
|
+
transform(transformation: Readonly<Transformation>): this;
|
|
203
|
+
/**
|
|
204
|
+
* Inversely transform the vector with a {@linkcode Transformation}.
|
|
205
|
+
* @param transformation The transformation to apply.
|
|
206
|
+
* @returns This instance.
|
|
207
|
+
*/
|
|
208
|
+
transformInverse(transformation: Readonly<Transformation>): this;
|
|
32
209
|
/**
|
|
33
210
|
* Returns the dot product between two vectors.
|
|
34
211
|
* @param vector The other vector.
|
|
35
212
|
* @returns The dot product between the two vectors.
|
|
36
213
|
*/
|
|
37
|
-
dot(vector: Vector3): number;
|
|
214
|
+
dot(vector: Readonly<Vector3>): number;
|
|
38
215
|
/**
|
|
39
216
|
* Returns the dot product between two vectors.
|
|
40
217
|
* @param x The X component of the other vector.
|
|
@@ -43,4 +220,80 @@ export declare class Vector3 {
|
|
|
43
220
|
* @returns The dot product between the two vectors.
|
|
44
221
|
*/
|
|
45
222
|
dotXYZ(x: number, y: number, z: number): number;
|
|
223
|
+
/**
|
|
224
|
+
* Calculates the dot product of this vector and another vector, and then
|
|
225
|
+
* sets this vector to the result.
|
|
226
|
+
* @param vector The other vector.
|
|
227
|
+
* @returns This instance.
|
|
228
|
+
*/
|
|
229
|
+
cross(vector: Readonly<Vector3>): this;
|
|
230
|
+
/**
|
|
231
|
+
* Makes this vector perpendicular to the other 3 vectors.
|
|
232
|
+
* @param vector0 The first vector.
|
|
233
|
+
* @param vector1 The second vector.
|
|
234
|
+
* @param vector2 The third vector.
|
|
235
|
+
* @returns This instance.
|
|
236
|
+
*/
|
|
237
|
+
perpendicular(vector0: Readonly<Vector3>, vector1: Readonly<Vector3>, vector2: Readonly<Vector3>): this;
|
|
238
|
+
/**
|
|
239
|
+
* Reflects this vector against the given normal and sets this vector to
|
|
240
|
+
* the result.
|
|
241
|
+
* @param normal The normal against which to reflect.
|
|
242
|
+
* @returns This instance.
|
|
243
|
+
*/
|
|
244
|
+
reflect(normal: Readonly<Vector3>): this;
|
|
245
|
+
/**
|
|
246
|
+
* Calculates the reflection of this vector, based on the angle of incident
|
|
247
|
+
* into a material with the given refractive index, according to Snell's law.
|
|
248
|
+
* This vector is then set to the result.
|
|
249
|
+
* @param normal The normal against which to reflect.
|
|
250
|
+
* @param index The refractive index of the material.
|
|
251
|
+
* @returns This instance.
|
|
252
|
+
*/
|
|
253
|
+
fraction(normal: Readonly<Vector3>, index: number): this;
|
|
254
|
+
/**
|
|
255
|
+
* Return the components of this vector as an array.
|
|
256
|
+
* @returns The components of this vector as an array.
|
|
257
|
+
*/
|
|
258
|
+
asArray(): [number, number, number];
|
|
46
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Adds two vectors and returns a new vector with the result.
|
|
262
|
+
* @param a The first input vector.
|
|
263
|
+
* @param b The second input vector.
|
|
264
|
+
* @returns A new {@linkcode Vector3}.
|
|
265
|
+
* @group Math
|
|
266
|
+
*/
|
|
267
|
+
export declare const addVector3: (a: Readonly<Vector3>, b: Readonly<Vector3>) => Vector3;
|
|
268
|
+
/**
|
|
269
|
+
* Multiplies two vectors and returns a new vector with the result.
|
|
270
|
+
* @param a The first input vector.
|
|
271
|
+
* @param b The second input vector.
|
|
272
|
+
* @returns A new {@linkcode Vector3}.
|
|
273
|
+
* @group Math
|
|
274
|
+
*/
|
|
275
|
+
export declare const multiplyVector3: (a: Readonly<Vector3>, b: Readonly<Vector3>) => Vector3;
|
|
276
|
+
/**
|
|
277
|
+
* Subtracts two vectors and returns a new vector with the result.
|
|
278
|
+
* @param a The first input vector.
|
|
279
|
+
* @param b The second input vector.
|
|
280
|
+
* @returns A new {@linkcode Vector3}.
|
|
281
|
+
* @group Math
|
|
282
|
+
*/
|
|
283
|
+
export declare const subtractVector3: (a: Readonly<Vector3>, b: Readonly<Vector3>) => Vector3;
|
|
284
|
+
/**
|
|
285
|
+
* Calculates the cross product between two vectors and returns a new vector with the result.
|
|
286
|
+
* @param a The first input vector.
|
|
287
|
+
* @param b The second input vector.
|
|
288
|
+
* @returns A new vector, which is the cross product of the two input vectors.
|
|
289
|
+
* @group Math
|
|
290
|
+
*/
|
|
291
|
+
export declare const crossVector3: (a: Readonly<Vector3>, b: Readonly<Vector3>) => Vector3;
|
|
292
|
+
/**
|
|
293
|
+
* Calculates the dot product between two vectors.
|
|
294
|
+
* @param a The first input vector.
|
|
295
|
+
* @param b The second input vector.
|
|
296
|
+
* @returns The dot product between the two vectors.
|
|
297
|
+
* @group Math
|
|
298
|
+
*/
|
|
299
|
+
export declare const dotVector3: (a: Readonly<Vector3>, b: Readonly<Vector3>) => number;
|