@minecraft/math 1.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.
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.38.3"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,327 @@
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
+ * normalize
218
+ *
219
+ * Normalizes this vector, returning itself.
220
+ */
221
+ normalize(): this;
222
+ /**
223
+ * floor
224
+ *
225
+ * Floor the components of a vector to produce a new vector
226
+ */
227
+ floor(): this;
228
+ /**
229
+ * toString
230
+ *
231
+ * Create a string representation of a vector
232
+ */
233
+ toString(options?: {
234
+ decimals?: number;
235
+ delimiter?: string;
236
+ }): string;
237
+ /**
238
+ * clamp
239
+ *
240
+ * Clamps the components of a vector to limits to produce a new vector
241
+ */
242
+ clamp(limits: {
243
+ min?: Partial<Vector3>;
244
+ max?: Partial<Vector3>;
245
+ }): this;
246
+ }
247
+
248
+ /**
249
+ * Utilities operating on Vector3 objects. All methods are static and do not modify the input objects.
250
+ *
251
+ * @public
252
+ */
253
+ export declare class Vector3Utils {
254
+ /**
255
+ * equals
256
+ *
257
+ * Check the equality of two vectors
258
+ */
259
+ static equals(v1: Vector3, v2: Vector3): boolean;
260
+ /**
261
+ * add
262
+ *
263
+ * Add two vectors to produce a new vector
264
+ */
265
+ static add(v1: Vector3, v2: Vector3): Vector3;
266
+ /**
267
+ * subtract
268
+ *
269
+ * Subtract two vectors to produce a new vector (v1-v2)
270
+ */
271
+ static subtract(v1: Vector3, v2: Vector3): Vector3;
272
+ /** scale
273
+ *
274
+ * Multiple all entries in a vector by a single scalar value producing a new vector
275
+ */
276
+ static scale(v1: Vector3, scale: number): Vector3;
277
+ /**
278
+ * dot
279
+ *
280
+ * Calculate the dot product of two vectors
281
+ */
282
+ static dot(a: Vector3, b: Vector3): number;
283
+ /**
284
+ * cross
285
+ *
286
+ * Calculate the cross product of two vectors. Returns a new vector.
287
+ */
288
+ static cross(a: Vector3, b: Vector3): Vector3;
289
+ /**
290
+ * magnitude
291
+ *
292
+ * The magnitude of a vector
293
+ */
294
+ static magnitude(v: Vector3): number;
295
+ /**
296
+ * normalize
297
+ *
298
+ * Takes a vector 3 and normalizes it to a unit vector
299
+ */
300
+ static normalize(v: Vector3): Vector3;
301
+ /**
302
+ * floor
303
+ *
304
+ * Floor the components of a vector to produce a new vector
305
+ */
306
+ static floor(v: Vector3): Vector3;
307
+ /**
308
+ * toString
309
+ *
310
+ * Create a string representation of a vector3
311
+ */
312
+ static toString(v: Vector3, options?: {
313
+ decimals?: number;
314
+ delimiter?: string;
315
+ }): string;
316
+ /**
317
+ * clamp
318
+ *
319
+ * Clamps the components of a vector to limits to produce a new vector
320
+ */
321
+ static clamp(v: Vector3, limits?: {
322
+ min?: Partial<Vector3>;
323
+ max?: Partial<Vector3>;
324
+ }): Vector3;
325
+ }
326
+
327
+ export { }
@@ -0,0 +1,327 @@
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
+ * normalize
218
+ *
219
+ * Normalizes this vector, returning itself.
220
+ */
221
+ normalize(): this;
222
+ /**
223
+ * floor
224
+ *
225
+ * Floor the components of a vector to produce a new vector
226
+ */
227
+ floor(): this;
228
+ /**
229
+ * toString
230
+ *
231
+ * Create a string representation of a vector
232
+ */
233
+ toString(options?: {
234
+ decimals?: number;
235
+ delimiter?: string;
236
+ }): string;
237
+ /**
238
+ * clamp
239
+ *
240
+ * Clamps the components of a vector to limits to produce a new vector
241
+ */
242
+ clamp(limits: {
243
+ min?: Partial<Vector3>;
244
+ max?: Partial<Vector3>;
245
+ }): this;
246
+ }
247
+
248
+ /**
249
+ * Utilities operating on Vector3 objects. All methods are static and do not modify the input objects.
250
+ *
251
+ * @public
252
+ */
253
+ export declare class Vector3Utils {
254
+ /**
255
+ * equals
256
+ *
257
+ * Check the equality of two vectors
258
+ */
259
+ static equals(v1: Vector3, v2: Vector3): boolean;
260
+ /**
261
+ * add
262
+ *
263
+ * Add two vectors to produce a new vector
264
+ */
265
+ static add(v1: Vector3, v2: Vector3): Vector3;
266
+ /**
267
+ * subtract
268
+ *
269
+ * Subtract two vectors to produce a new vector (v1-v2)
270
+ */
271
+ static subtract(v1: Vector3, v2: Vector3): Vector3;
272
+ /** scale
273
+ *
274
+ * Multiple all entries in a vector by a single scalar value producing a new vector
275
+ */
276
+ static scale(v1: Vector3, scale: number): Vector3;
277
+ /**
278
+ * dot
279
+ *
280
+ * Calculate the dot product of two vectors
281
+ */
282
+ static dot(a: Vector3, b: Vector3): number;
283
+ /**
284
+ * cross
285
+ *
286
+ * Calculate the cross product of two vectors. Returns a new vector.
287
+ */
288
+ static cross(a: Vector3, b: Vector3): Vector3;
289
+ /**
290
+ * magnitude
291
+ *
292
+ * The magnitude of a vector
293
+ */
294
+ static magnitude(v: Vector3): number;
295
+ /**
296
+ * normalize
297
+ *
298
+ * Takes a vector 3 and normalizes it to a unit vector
299
+ */
300
+ static normalize(v: Vector3): Vector3;
301
+ /**
302
+ * floor
303
+ *
304
+ * Floor the components of a vector to produce a new vector
305
+ */
306
+ static floor(v: Vector3): Vector3;
307
+ /**
308
+ * toString
309
+ *
310
+ * Create a string representation of a vector3
311
+ */
312
+ static toString(v: Vector3, options?: {
313
+ decimals?: number;
314
+ delimiter?: string;
315
+ }): string;
316
+ /**
317
+ * clamp
318
+ *
319
+ * Clamps the components of a vector to limits to produce a new vector
320
+ */
321
+ static clamp(v: Vector3, limits?: {
322
+ min?: Partial<Vector3>;
323
+ max?: Partial<Vector3>;
324
+ }): Vector3;
325
+ }
326
+
327
+ export { }