-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.d.ts
237 lines (192 loc) · 4.48 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
export class Vec3 {
constructor(x: number, y: number, z: number);
x: number;
y: number;
z: number;
/**
* Returns true when it is a zero vector.
*/
isZero(): boolean;
/**
* Access component by index
*/
at(id: number): number;
/**
* Returns an array component x, z
*/
xz(): [number, number];
/**
* Returns an array component x, y
*/
xy(): [number, number];
/**
* Returns an array component y, z
*/
yz(): [number, number];
/**
* Returns a vector with swapped y and z
*/
xzy(): Vec3;
/**
* Set own values to given x y z
* If some components is given null, then those components won't change
*/
set(x: number, y: number, z: number): this;
/**
* Set own values to values given by other
*/
update(other: Vec3): this;
/**
* Return a new instance with copied values that are rounded
*/
rounded(): Vec3;
/**
* Round own values to nearest integer
*/
round(): this;
/**
* Return a new instance with copied values that are floored
*/
floored(): Vec3;
/**
* Floor own values
*/
floor(): this;
/**
* Return a new instance with copied values that are offset by dx dy and dz
*/
offset(dx: number, dy: number, dz: number): Vec3;
/**
* Translate own values by dx dy and dz
*/
translate(dx: number, dy: number, dz: number): this;
/**
* Add to own values by vector
*/
add(other: Vec3): this;
/**
* Subtract own values by vector
*/
subtract(other: Vec3): this;
/**
* Multiply own values by value from vector
*/
multiply(other: Vec3): this;
/**
* Divide own values by value from vector
*/
divide(other: Vec3): this;
/**
* Return a new instance with copied values that are added to by vector
*/
plus(other: Vec3): Vec3;
/**
* Return a new instance with copied values that are subtracted by vector
*/
minus(other: Vec3): Vec3;
/**
* Return a new instance with copied values that are scaled by number
*/
scaled(scalar: number): Vec3;
/**
* Return a new instance with copied values that are absolute
*/
abs(): Vec3;
/**
* Return the volume off the vector
*/
volume(): number;
/**
* Return a new instance with copied values that are modulated by value from a vector
*/
modulus(other: Vec3): Vec3;
/**
* Return the euclidean distance to another vector
*/
distanceTo(other: Vec3): number;
/**
* Return the squared euclidean distance to another vector
*/
distanceSquared(other: Vec3): number;
/**
* Check whether two vectors are equal
* Returns true if each components have at most `error` difference
*/
equals(other: Vec3, error?: number): boolean;
/**
* Converts own values to a string representation in the format `(x, y, z)`
*/
toString(): string;
/**
* Return a new instance with the same values
*/
clone(): Vec3;
/**
* Return a new instance with the min values by value compared to another vector
*/
min(other: Vec3): Vec3;
/**
* Return a new instance with the max values by value compared to another vector
*/
max(other: Vec3): Vec3;
/**
* Returns its own euclidean norm
*/
norm(): number;
/**
* Returns the dot product with another vector
*/
dot(other: Vec3): number;
/**
* Returns a new instance off the cross product to another vector
*/
cross(other: Vec3): Vec3;
/**
* Returns a new instance with copied values normed to the unit vector
*/
unit(): Vec3;
/**
* Normalize own values
*/
normalize(): Vec3;
/**
* Scale own values by a number
*/
scale(scalar: number): this;
/**
* Returns the xy distance to another vector
*/
xyDistanceTo(other: Vec3): number;
/**
* Returns the xz distance to another vector
*/
xzDistanceTo(other: Vec3): number;
/**
* Returns the yz distance to another vector
*/
yzDistanceTo(other: Vec3): number;
/**
* Returns the inner product to another vector
*/
innerProduct(other: Vec3): number;
/**
* Returns the manhattan distance to another vector
*/
manhattanDistanceTo(other: Vec3): number;
/**
* Returns an array with x y z in array form ie [x, y, z]
*/
toArray(): [number, number, number];
}
export default function v(
coordinates:
| null
| string
| [number | string, number | string, number | string]
| { x: number | string; y: number | string; z: number | string }
): Vec3;
export default function v(
x: number | string,
y: number | string,
z: number | string
): Vec3;