@minecraft/math 1.5.1 → 2.0.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/minecraft-math.d.ts +419 -0
- package/dist/minecraft-math.js +415 -501
- package/dist/minecraft-math.js.map +3 -3
- package/lib/general/clamp.js +1 -5
- package/lib/general/clamp.js.map +1 -1
- package/lib/general/index.js +1 -17
- package/lib/general/index.js.map +1 -1
- package/lib/index.js +2 -18
- package/lib/index.js.map +1 -1
- package/lib/index.test.js +4 -6
- package/lib/index.test.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/vector3/coreHelpers.js +18 -23
- package/lib/vector3/coreHelpers.js.map +1 -1
- package/lib/vector3/coreHelpers.test.js +132 -134
- package/lib/vector3/coreHelpers.test.js.map +1 -1
- package/lib/vector3/index.js +2 -18
- package/lib/vector3/index.js.map +1 -1
- package/lib/vector3/vectorWrapper.js +27 -27
- package/lib/vector3/vectorWrapper.js.map +1 -1
- package/lib/vector3/vectorWrapper.test.js +125 -127
- package/lib/vector3/vectorWrapper.test.js.map +1 -1
- package/package.json +9 -5
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import type { Vector2 } from '@minecraft/server';
|
|
2
|
+
import type { Vector3 } from '@minecraft/server';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Clamps the passed in number to the passed in min and max values.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare function clampNumber(val: number, min: number, max: number): number;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Vector2 wrapper class which can be used as a Vector2 for APIs on \@minecraft/server which require a Vector2.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare class Vector2Builder implements Vector2 {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
constructor(vec: Vector2, arg?: never);
|
|
19
|
+
constructor(x: number, y: number);
|
|
20
|
+
toString(options?: {
|
|
21
|
+
decimals?: number;
|
|
22
|
+
delimiter?: string;
|
|
23
|
+
}): string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Utilities operating on Vector2 objects. All methods are static and do not modify the input objects.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare class Vector2Utils {
|
|
32
|
+
/**
|
|
33
|
+
* toString
|
|
34
|
+
*
|
|
35
|
+
* Create a string representation of a vector2
|
|
36
|
+
*/
|
|
37
|
+
static toString(v: Vector2, options?: {
|
|
38
|
+
decimals?: number;
|
|
39
|
+
delimiter?: string;
|
|
40
|
+
}): string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* back
|
|
45
|
+
*
|
|
46
|
+
* A unit vector representing the world BACK direction (0,0,-1)
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare const VECTOR3_BACK: Vector3;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* down
|
|
54
|
+
*
|
|
55
|
+
* A unit vector representing the world DOWN direction (0,-1,0)
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export declare const VECTOR3_DOWN: Vector3;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* east
|
|
63
|
+
*
|
|
64
|
+
* A unit vector representing the world EAST direction (-1,0,0)
|
|
65
|
+
* (same as RIGHT)
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export declare const VECTOR3_EAST: Vector3;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* forward
|
|
73
|
+
*
|
|
74
|
+
* A unit vector representing the world FORWARD direction (0,0,1)
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
export declare const VECTOR3_FORWARD: Vector3;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* left
|
|
82
|
+
*
|
|
83
|
+
* A unit vector representing the world LEFT direction (-1,0,0)
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export declare const VECTOR3_LEFT: Vector3;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* north
|
|
91
|
+
*
|
|
92
|
+
* A unit vector representing the world NORTH direction (-1,0,0)
|
|
93
|
+
* (same as FORWARD)
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export declare const VECTOR3_NORTH: Vector3;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* one
|
|
101
|
+
*
|
|
102
|
+
* A unit vector representing the value of 1 in all directions (1,1,1)
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export declare const VECTOR3_ONE: Vector3;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* right
|
|
110
|
+
*
|
|
111
|
+
* A unit vector representing the world RIGHT direction (1,0,0)
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
export declare const VECTOR3_RIGHT: Vector3;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* south
|
|
119
|
+
*
|
|
120
|
+
* A unit vector representing the world SOUTH direction (-1,0,0)
|
|
121
|
+
* (same as BACK)
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
export declare const VECTOR3_SOUTH: Vector3;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* up
|
|
129
|
+
*
|
|
130
|
+
* A unit vector representing the world UP direction (0,1,0)
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
export declare const VECTOR3_UP: Vector3;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* west
|
|
138
|
+
*
|
|
139
|
+
* A unit vector representing the world WEST direction (-1,0,0)
|
|
140
|
+
* (same as LEFT)
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare const VECTOR3_WEST: Vector3;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* zero
|
|
148
|
+
*
|
|
149
|
+
* A unit vector representing the value of 0 in all directions (0,0,0)
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
export declare const VECTOR3_ZERO: Vector3;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Vector3 wrapper class which can be used as a Vector3 for APIs on \@minecraft/server which require a Vector,
|
|
157
|
+
* but also contain additional helper methods. This is an alternative to using the core Vector 3 utility
|
|
158
|
+
* methods directly, for those who prefer a more object-oriented approach. This version of the class is mutable
|
|
159
|
+
* and changes state inline.
|
|
160
|
+
*
|
|
161
|
+
* For an immutable version of the build, use ImmutableVector3Builder.
|
|
162
|
+
*
|
|
163
|
+
* @public
|
|
164
|
+
*/
|
|
165
|
+
export declare class Vector3Builder implements Vector3 {
|
|
166
|
+
x: number;
|
|
167
|
+
y: number;
|
|
168
|
+
z: number;
|
|
169
|
+
constructor(vec: Vector3, arg?: never, arg2?: never);
|
|
170
|
+
constructor(x: number, y: number, z: number);
|
|
171
|
+
/**
|
|
172
|
+
* Assigns the values of the passed in vector to this vector. Returns itself.
|
|
173
|
+
*/
|
|
174
|
+
assign(vec: Vector3): this;
|
|
175
|
+
/**
|
|
176
|
+
* equals
|
|
177
|
+
*
|
|
178
|
+
* Check the equality of two vectors
|
|
179
|
+
*/
|
|
180
|
+
equals(v: Vector3): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* add
|
|
183
|
+
*
|
|
184
|
+
* Adds the vector v to this, returning itself.
|
|
185
|
+
*/
|
|
186
|
+
add(v: Vector3): this;
|
|
187
|
+
/**
|
|
188
|
+
* subtract
|
|
189
|
+
*
|
|
190
|
+
* Subtracts the vector v from this, returning itself.
|
|
191
|
+
*/
|
|
192
|
+
subtract(v: Vector3): this;
|
|
193
|
+
/** scale
|
|
194
|
+
*
|
|
195
|
+
* Scales this by the passed in value, returning itself.
|
|
196
|
+
*/
|
|
197
|
+
scale(val: number): this;
|
|
198
|
+
/**
|
|
199
|
+
* dot
|
|
200
|
+
*
|
|
201
|
+
* Computes the dot product of this and the passed in vector.
|
|
202
|
+
*/
|
|
203
|
+
dot(vec: Vector3): number;
|
|
204
|
+
/**
|
|
205
|
+
* cross
|
|
206
|
+
*
|
|
207
|
+
* Computes the cross product of this and the passed in vector, returning itself.
|
|
208
|
+
*/
|
|
209
|
+
cross(vec: Vector3): this;
|
|
210
|
+
/**
|
|
211
|
+
* magnitude
|
|
212
|
+
*
|
|
213
|
+
* The magnitude of the vector
|
|
214
|
+
*/
|
|
215
|
+
magnitude(): number;
|
|
216
|
+
/**
|
|
217
|
+
* distance
|
|
218
|
+
*
|
|
219
|
+
* Calculate the distance between two vectors
|
|
220
|
+
*/
|
|
221
|
+
distance(vec: Vector3): number;
|
|
222
|
+
/**
|
|
223
|
+
* normalize
|
|
224
|
+
*
|
|
225
|
+
* Normalizes this vector, returning itself.
|
|
226
|
+
*/
|
|
227
|
+
normalize(): this;
|
|
228
|
+
/**
|
|
229
|
+
* floor
|
|
230
|
+
*
|
|
231
|
+
* Floor the components of a vector to produce a new vector
|
|
232
|
+
*/
|
|
233
|
+
floor(): this;
|
|
234
|
+
/**
|
|
235
|
+
* toString
|
|
236
|
+
*
|
|
237
|
+
* Create a string representation of a vector
|
|
238
|
+
*/
|
|
239
|
+
toString(options?: {
|
|
240
|
+
decimals?: number;
|
|
241
|
+
delimiter?: string;
|
|
242
|
+
}): string;
|
|
243
|
+
/**
|
|
244
|
+
* clamp
|
|
245
|
+
*
|
|
246
|
+
* Clamps the components of a vector to limits to produce a new vector
|
|
247
|
+
*/
|
|
248
|
+
clamp(limits: {
|
|
249
|
+
min?: Partial<Vector3>;
|
|
250
|
+
max?: Partial<Vector3>;
|
|
251
|
+
}): this;
|
|
252
|
+
/**
|
|
253
|
+
* lerp
|
|
254
|
+
*
|
|
255
|
+
* Constructs a new vector using linear interpolation on each component from two vectors.
|
|
256
|
+
*/
|
|
257
|
+
lerp(vec: Vector3, t: number): this;
|
|
258
|
+
/**
|
|
259
|
+
* slerp
|
|
260
|
+
*
|
|
261
|
+
* Constructs a new vector using spherical linear interpolation on each component from two vectors.
|
|
262
|
+
*/
|
|
263
|
+
slerp(vec: Vector3, t: number): this;
|
|
264
|
+
/**
|
|
265
|
+
* multiply
|
|
266
|
+
*
|
|
267
|
+
* Element-wise multiplication of two vectors together.
|
|
268
|
+
* Not to be confused with {@link Vector3Builder.dot} product or {@link Vector3Builder.cross} product
|
|
269
|
+
*/
|
|
270
|
+
multiply(vec: Vector3): this;
|
|
271
|
+
/**
|
|
272
|
+
* rotateX
|
|
273
|
+
*
|
|
274
|
+
* Rotates the vector around the x axis counterclockwise (left hand rule)
|
|
275
|
+
* @param a - Angle in radians
|
|
276
|
+
*/
|
|
277
|
+
rotateX(a: number): this;
|
|
278
|
+
/**
|
|
279
|
+
* rotateY
|
|
280
|
+
*
|
|
281
|
+
* Rotates the vector around the y axis counterclockwise (left hand rule)
|
|
282
|
+
* @param a - Angle in radians
|
|
283
|
+
*/
|
|
284
|
+
rotateY(a: number): this;
|
|
285
|
+
/**
|
|
286
|
+
* rotateZ
|
|
287
|
+
*
|
|
288
|
+
* Rotates the vector around the z axis counterclockwise (left hand rule)
|
|
289
|
+
* @param a - Angle in radians
|
|
290
|
+
*/
|
|
291
|
+
rotateZ(a: number): this;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Utilities operating on Vector3 objects. All methods are static and do not modify the input objects.
|
|
296
|
+
*
|
|
297
|
+
* @public
|
|
298
|
+
*/
|
|
299
|
+
export declare class Vector3Utils {
|
|
300
|
+
/**
|
|
301
|
+
* equals
|
|
302
|
+
*
|
|
303
|
+
* Check the equality of two vectors
|
|
304
|
+
*/
|
|
305
|
+
static equals(v1: Vector3, v2: Vector3): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* add
|
|
308
|
+
*
|
|
309
|
+
* Add two vectors to produce a new vector
|
|
310
|
+
*/
|
|
311
|
+
static add(v1: Vector3, v2: Vector3): Vector3;
|
|
312
|
+
/**
|
|
313
|
+
* subtract
|
|
314
|
+
*
|
|
315
|
+
* Subtract two vectors to produce a new vector (v1-v2)
|
|
316
|
+
*/
|
|
317
|
+
static subtract(v1: Vector3, v2: Vector3): Vector3;
|
|
318
|
+
/** scale
|
|
319
|
+
*
|
|
320
|
+
* Multiple all entries in a vector by a single scalar value producing a new vector
|
|
321
|
+
*/
|
|
322
|
+
static scale(v1: Vector3, scale: number): Vector3;
|
|
323
|
+
/**
|
|
324
|
+
* dot
|
|
325
|
+
*
|
|
326
|
+
* Calculate the dot product of two vectors
|
|
327
|
+
*/
|
|
328
|
+
static dot(a: Vector3, b: Vector3): number;
|
|
329
|
+
/**
|
|
330
|
+
* cross
|
|
331
|
+
*
|
|
332
|
+
* Calculate the cross product of two vectors. Returns a new vector.
|
|
333
|
+
*/
|
|
334
|
+
static cross(a: Vector3, b: Vector3): Vector3;
|
|
335
|
+
/**
|
|
336
|
+
* magnitude
|
|
337
|
+
*
|
|
338
|
+
* The magnitude of a vector
|
|
339
|
+
*/
|
|
340
|
+
static magnitude(v: Vector3): number;
|
|
341
|
+
/**
|
|
342
|
+
* distance
|
|
343
|
+
*
|
|
344
|
+
* Calculate the distance between two vectors
|
|
345
|
+
*/
|
|
346
|
+
static distance(a: Vector3, b: Vector3): number;
|
|
347
|
+
/**
|
|
348
|
+
* normalize
|
|
349
|
+
*
|
|
350
|
+
* Takes a vector 3 and normalizes it to a unit vector
|
|
351
|
+
*/
|
|
352
|
+
static normalize(v: Vector3): Vector3;
|
|
353
|
+
/**
|
|
354
|
+
* floor
|
|
355
|
+
*
|
|
356
|
+
* Floor the components of a vector to produce a new vector
|
|
357
|
+
*/
|
|
358
|
+
static floor(v: Vector3): Vector3;
|
|
359
|
+
/**
|
|
360
|
+
* toString
|
|
361
|
+
*
|
|
362
|
+
* Create a string representation of a vector3
|
|
363
|
+
*/
|
|
364
|
+
static toString(v: Vector3, options?: {
|
|
365
|
+
decimals?: number;
|
|
366
|
+
delimiter?: string;
|
|
367
|
+
}): string;
|
|
368
|
+
/**
|
|
369
|
+
* clamp
|
|
370
|
+
*
|
|
371
|
+
* Clamps the components of a vector to limits to produce a new vector
|
|
372
|
+
*/
|
|
373
|
+
static clamp(v: Vector3, limits?: {
|
|
374
|
+
min?: Partial<Vector3>;
|
|
375
|
+
max?: Partial<Vector3>;
|
|
376
|
+
}): Vector3;
|
|
377
|
+
/**
|
|
378
|
+
* lerp
|
|
379
|
+
*
|
|
380
|
+
* Constructs a new vector using linear interpolation on each component from two vectors.
|
|
381
|
+
*/
|
|
382
|
+
static lerp(a: Vector3, b: Vector3, t: number): Vector3;
|
|
383
|
+
/**
|
|
384
|
+
* slerp
|
|
385
|
+
*
|
|
386
|
+
* Constructs a new vector using spherical linear interpolation on each component from two vectors.
|
|
387
|
+
*/
|
|
388
|
+
static slerp(a: Vector3, b: Vector3, t: number): Vector3;
|
|
389
|
+
/**
|
|
390
|
+
* multiply
|
|
391
|
+
*
|
|
392
|
+
* Element-wise multiplication of two vectors together.
|
|
393
|
+
* Not to be confused with {@link Vector3Utils.dot} product or {@link Vector3Utils.cross} product
|
|
394
|
+
*/
|
|
395
|
+
static multiply(a: Vector3, b: Vector3): Vector3;
|
|
396
|
+
/**
|
|
397
|
+
* rotateX
|
|
398
|
+
*
|
|
399
|
+
* Rotates the vector around the x axis counterclockwise (left hand rule)
|
|
400
|
+
* @param a - Angle in radians
|
|
401
|
+
*/
|
|
402
|
+
static rotateX(v: Vector3, a: number): Vector3;
|
|
403
|
+
/**
|
|
404
|
+
* rotateY
|
|
405
|
+
*
|
|
406
|
+
* Rotates the vector around the y axis counterclockwise (left hand rule)
|
|
407
|
+
* @param a - Angle in radians
|
|
408
|
+
*/
|
|
409
|
+
static rotateY(v: Vector3, a: number): Vector3;
|
|
410
|
+
/**
|
|
411
|
+
* rotateZ
|
|
412
|
+
*
|
|
413
|
+
* Rotates the vector around the z axis counterclockwise (left hand rule)
|
|
414
|
+
* @param a - Angle in radians
|
|
415
|
+
*/
|
|
416
|
+
static rotateZ(v: Vector3, a: number): Vector3;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export { }
|