@ntf/math 1.4.0 → 1.4.2
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/index.d.mts +788 -865
- package/dist/index.d.ts +788 -865
- package/dist/index.js +1 -3258
- package/dist/index.mjs +1 -3235
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -1,3235 +1 @@
|
|
|
1
|
-
// source/algebra/function.ts
|
|
2
|
-
var MathFunction = class {
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
// source/common/sign.ts
|
|
6
|
-
function signCharacter(num) {
|
|
7
|
-
if (num == 0)
|
|
8
|
-
return void 0;
|
|
9
|
-
if (num < 0)
|
|
10
|
-
return "-";
|
|
11
|
-
if (num > 0)
|
|
12
|
-
return "+";
|
|
13
|
-
return void 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// source/common/types.ts
|
|
17
|
-
function checkNumber(value) {
|
|
18
|
-
return value !== null && typeof value == "number" && !isNaN(value) && isFinite(value);
|
|
19
|
-
}
|
|
20
|
-
function getHexValue(string) {
|
|
21
|
-
let offset = 0;
|
|
22
|
-
if (string.startsWith("#") || string.startsWith("$"))
|
|
23
|
-
offset = 1;
|
|
24
|
-
if (string.startsWith("0x"))
|
|
25
|
-
offset = 2;
|
|
26
|
-
return string.substring(offset);
|
|
27
|
-
}
|
|
28
|
-
function checkHex(value) {
|
|
29
|
-
if (!checkString(value))
|
|
30
|
-
return false;
|
|
31
|
-
const hexValue = getHexValue(value).split("").map((char) => parseInt(char.toUpperCase(), 16));
|
|
32
|
-
return checkNumberArray(hexValue);
|
|
33
|
-
}
|
|
34
|
-
function checkString(value) {
|
|
35
|
-
return value !== null && typeof value == "string" && value.length > 0;
|
|
36
|
-
}
|
|
37
|
-
function checkArray(value, predicate, requiredLength) {
|
|
38
|
-
if (!Array.isArray(value)) return false;
|
|
39
|
-
if (typeof requiredLength == "number" && requiredLength !== value.length) return false;
|
|
40
|
-
for (const item of value)
|
|
41
|
-
if (typeof predicate == "function" && !predicate(item))
|
|
42
|
-
return false;
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
function checkNumberArray(value, requiredLength) {
|
|
46
|
-
return checkArray(value, checkNumber, requiredLength);
|
|
47
|
-
}
|
|
48
|
-
function checkStringArray(value, requiredLength) {
|
|
49
|
-
return checkArray(value, checkString, requiredLength);
|
|
50
|
-
}
|
|
51
|
-
function hasProperty(value, propertyName, type) {
|
|
52
|
-
return value !== null && typeof value == "object" && propertyName in value && typeof value[propertyName] == type;
|
|
53
|
-
}
|
|
54
|
-
var NodeJSCustomInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
55
|
-
|
|
56
|
-
// source/common/error.ts
|
|
57
|
-
var ResolveError = class extends Error {
|
|
58
|
-
/**
|
|
59
|
-
* Create a resolve exception
|
|
60
|
-
* @param target The target type name
|
|
61
|
-
* @param value A value
|
|
62
|
-
*/
|
|
63
|
-
constructor(target, value) {
|
|
64
|
-
super(`Can't resolve ${value} to ${target}`);
|
|
65
|
-
this.target = target;
|
|
66
|
-
this.value = value;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// source/utils.ts
|
|
71
|
-
function clamp(value, min, max) {
|
|
72
|
-
if (value <= min)
|
|
73
|
-
return min;
|
|
74
|
-
if (value >= max)
|
|
75
|
-
return max;
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
function logHypot(a, b) {
|
|
79
|
-
const a_abs = Math.abs(a);
|
|
80
|
-
const b_abs = Math.abs(b);
|
|
81
|
-
if (a == 0)
|
|
82
|
-
return Math.log(b_abs);
|
|
83
|
-
if (b == 0)
|
|
84
|
-
return Math.log(a_abs);
|
|
85
|
-
if (a_abs < 3e3 && b_abs < 3e3)
|
|
86
|
-
return 0.5 * Math.log(a * a + b * b);
|
|
87
|
-
const _a = a / 2, _b = b / 2;
|
|
88
|
-
return 0.5 * Math.log(_a * _a + _b * _b) + Math.LN2;
|
|
89
|
-
}
|
|
90
|
-
var EPSILON = 1e-16;
|
|
91
|
-
var lerp = (a, b, t) => ((typeof a == "number" ? 1 : 1n) - t) * a + t * b;
|
|
92
|
-
|
|
93
|
-
// source/vectors/vec2.ts
|
|
94
|
-
var Vec2 = class _Vec2 {
|
|
95
|
-
x;
|
|
96
|
-
y;
|
|
97
|
-
w;
|
|
98
|
-
static resolve(a) {
|
|
99
|
-
const value = this.cast(a);
|
|
100
|
-
if (typeof value != "undefined")
|
|
101
|
-
return value;
|
|
102
|
-
throw new ResolveError("Vec2", a);
|
|
103
|
-
}
|
|
104
|
-
static cast(a) {
|
|
105
|
-
if (a == null || typeof a == "undefined")
|
|
106
|
-
return void 0;
|
|
107
|
-
if (checkNumberArray(a, 2) || checkNumberArray(a, 3))
|
|
108
|
-
return new this(a[0], a[1], checkNumber(a[2]) ? a[2] : void 0);
|
|
109
|
-
if (hasProperty(a, "toVec2", "function"))
|
|
110
|
-
return this.cast(a.toVec2());
|
|
111
|
-
if (hasProperty(a, "x", "number") && hasProperty(a, "y", "number"))
|
|
112
|
-
return new this(a.x, a.y, hasProperty(a, "w", "number") ? a.w : void 0);
|
|
113
|
-
if (checkString(a)) {
|
|
114
|
-
const [sxy, sw] = a.split(";");
|
|
115
|
-
if (checkString(sxy)) {
|
|
116
|
-
const parts = sxy.split(",");
|
|
117
|
-
if (checkStringArray(parts, 2))
|
|
118
|
-
return new this(parseFloat(parts[0]), parseFloat(parts[1]), checkString(sw) ? parseFloat(sw) : void 0);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (checkNumber(a))
|
|
122
|
-
return new this(a, a);
|
|
123
|
-
return void 0;
|
|
124
|
-
}
|
|
125
|
-
static resolveArgs(args) {
|
|
126
|
-
if (checkNumberArray(args, 2))
|
|
127
|
-
return new this(args[0], args[1]);
|
|
128
|
-
return this.resolve(args[0]);
|
|
129
|
-
}
|
|
130
|
-
static is(a) {
|
|
131
|
-
return typeof this.cast(a) != "undefined";
|
|
132
|
-
}
|
|
133
|
-
static fromPoints(a, b) {
|
|
134
|
-
const veca = this.resolve(a);
|
|
135
|
-
const vecb = this.resolve(b);
|
|
136
|
-
return new this(vecb.x - veca.x, vecb.y - veca.y);
|
|
137
|
-
}
|
|
138
|
-
static clamp(value, min, max) {
|
|
139
|
-
const a = this.resolve(value), b = this.resolve(min), c = this.resolve(max);
|
|
140
|
-
return new this(
|
|
141
|
-
clamp(a.x, b.x, c.x),
|
|
142
|
-
clamp(a.y, b.y, c.y)
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
static get zero() {
|
|
146
|
-
return new this(0, 0);
|
|
147
|
-
}
|
|
148
|
-
static get one() {
|
|
149
|
-
return new this(1, 1);
|
|
150
|
-
}
|
|
151
|
-
constructor(x, y, w = 1) {
|
|
152
|
-
if (!checkNumber(x))
|
|
153
|
-
throw new TypeError("expected number for x");
|
|
154
|
-
if (!checkNumber(y))
|
|
155
|
-
throw new TypeError("expected number for y");
|
|
156
|
-
if (!checkNumber(w))
|
|
157
|
-
throw new TypeError("expected number for w");
|
|
158
|
-
this.x = x;
|
|
159
|
-
this.y = y;
|
|
160
|
-
this.w = w;
|
|
161
|
-
}
|
|
162
|
-
toArray(w = this.w !== 1) {
|
|
163
|
-
return w ? [this.x, this.y, this.w] : [this.x, this.y];
|
|
164
|
-
}
|
|
165
|
-
toJSON() {
|
|
166
|
-
return {
|
|
167
|
-
x: this.x,
|
|
168
|
-
y: this.y,
|
|
169
|
-
w: this.w
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
toString(w = this.w !== 1) {
|
|
173
|
-
return w ? `${this.x},${this.y};${this.w}` : `${this.x},${this.y}`;
|
|
174
|
-
}
|
|
175
|
-
get [Symbol.toStringTag]() {
|
|
176
|
-
return "Vec2";
|
|
177
|
-
}
|
|
178
|
-
[NodeJSCustomInspect]() {
|
|
179
|
-
return `Vec2 <${this.toString()}>`;
|
|
180
|
-
}
|
|
181
|
-
toSize() {
|
|
182
|
-
return [this.x, this.y];
|
|
183
|
-
}
|
|
184
|
-
toVec3(z = 0) {
|
|
185
|
-
return [this.x, this.y, z, this.w];
|
|
186
|
-
}
|
|
187
|
-
toRGB() {
|
|
188
|
-
const vec = this.normalize();
|
|
189
|
-
return [vec.x, vec.y, vec.w];
|
|
190
|
-
}
|
|
191
|
-
toRGBA() {
|
|
192
|
-
const vec = this.normalize();
|
|
193
|
-
return [vec.x, vec.y, vec.w, 1];
|
|
194
|
-
}
|
|
195
|
-
toHSL() {
|
|
196
|
-
const vec = this.normalize();
|
|
197
|
-
return [vec.x, vec.y, vec.w];
|
|
198
|
-
}
|
|
199
|
-
toHSLA() {
|
|
200
|
-
const vec = this.normalize();
|
|
201
|
-
return [vec.x, vec.y, vec.w, 1];
|
|
202
|
-
}
|
|
203
|
-
clone() {
|
|
204
|
-
return new _Vec2(this.x, this.y, this.w);
|
|
205
|
-
}
|
|
206
|
-
equals(...args) {
|
|
207
|
-
const a = _Vec2.resolveArgs(args);
|
|
208
|
-
return this.x == a.x && this.y == a.y;
|
|
209
|
-
}
|
|
210
|
-
setX(x) {
|
|
211
|
-
this.x = x;
|
|
212
|
-
return this;
|
|
213
|
-
}
|
|
214
|
-
setY(y) {
|
|
215
|
-
this.y = y;
|
|
216
|
-
return this;
|
|
217
|
-
}
|
|
218
|
-
setW(w) {
|
|
219
|
-
this.w = w;
|
|
220
|
-
return this;
|
|
221
|
-
}
|
|
222
|
-
set(...args) {
|
|
223
|
-
const vec = _Vec2.resolveArgs(args);
|
|
224
|
-
return this.setX(vec.x).setY(vec.y);
|
|
225
|
-
}
|
|
226
|
-
add(...args) {
|
|
227
|
-
const vec = _Vec2.resolveArgs(args);
|
|
228
|
-
return new _Vec2(
|
|
229
|
-
this.x + vec.x,
|
|
230
|
-
this.y + vec.y
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
offset(...args) {
|
|
234
|
-
const vec = _Vec2.resolveArgs(args);
|
|
235
|
-
this.x += vec.x;
|
|
236
|
-
this.y += vec.y;
|
|
237
|
-
return this;
|
|
238
|
-
}
|
|
239
|
-
subtract(...args) {
|
|
240
|
-
const vec = _Vec2.resolveArgs(args);
|
|
241
|
-
return new _Vec2(
|
|
242
|
-
this.x - vec.x,
|
|
243
|
-
this.y - vec.y
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
multiply(scalar) {
|
|
247
|
-
return new _Vec2(
|
|
248
|
-
this.x * scalar,
|
|
249
|
-
this.y * scalar
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
naiveMultiply(...args) {
|
|
253
|
-
const vec = _Vec2.resolveArgs(args);
|
|
254
|
-
return new _Vec2(
|
|
255
|
-
this.x * vec.x,
|
|
256
|
-
this.y * vec.y
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
divide(...args) {
|
|
260
|
-
if (checkNumberArray(args, 1))
|
|
261
|
-
return new _Vec2(
|
|
262
|
-
this.x / args[0],
|
|
263
|
-
this.y / args[0]
|
|
264
|
-
);
|
|
265
|
-
const vec = _Vec2.resolveArgs(args);
|
|
266
|
-
return new _Vec2(
|
|
267
|
-
this.x / vec.x,
|
|
268
|
-
this.y / vec.y
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
dot(...args) {
|
|
272
|
-
const vec = _Vec2.resolveArgs(args);
|
|
273
|
-
return this.x * vec.x + this.y * vec.y;
|
|
274
|
-
}
|
|
275
|
-
distance(...args) {
|
|
276
|
-
const vec = _Vec2.resolveArgs(args);
|
|
277
|
-
return Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2);
|
|
278
|
-
}
|
|
279
|
-
distanceSquare(...args) {
|
|
280
|
-
const vec = _Vec2.resolveArgs(args);
|
|
281
|
-
return Math.sqrt(Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2));
|
|
282
|
-
}
|
|
283
|
-
length() {
|
|
284
|
-
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
285
|
-
}
|
|
286
|
-
cartesianify() {
|
|
287
|
-
return new _Vec2(
|
|
288
|
-
this.x * Math.cos(this.y),
|
|
289
|
-
this.x * Math.sin(this.y)
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
polarify() {
|
|
293
|
-
return new _Vec2(
|
|
294
|
-
Math.sqrt(this.x * this.x + this.y * this.y),
|
|
295
|
-
Math.atan(this.y / this.x)
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
normalize() {
|
|
299
|
-
const length = this.length();
|
|
300
|
-
if (length == 0) return _Vec2.zero;
|
|
301
|
-
return new _Vec2(
|
|
302
|
-
this.x / length,
|
|
303
|
-
this.y / length,
|
|
304
|
-
this.w / length
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
invert() {
|
|
308
|
-
return this.multiply(-1);
|
|
309
|
-
}
|
|
310
|
-
round() {
|
|
311
|
-
return new _Vec2(Math.round(this.x), Math.round(this.y), Math.round(this.w));
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
// source/algebra/linear.ts
|
|
316
|
-
var LinearFunction = class extends MathFunction {
|
|
317
|
-
/**
|
|
318
|
-
* The factor of the linear function
|
|
319
|
-
*/
|
|
320
|
-
m;
|
|
321
|
-
/**
|
|
322
|
-
* The height of the linear function
|
|
323
|
-
*/
|
|
324
|
-
b;
|
|
325
|
-
/**
|
|
326
|
-
* Create a linear function from two points
|
|
327
|
-
* @param a A point
|
|
328
|
-
* @param b A point
|
|
329
|
-
* @returns A linear function from two points
|
|
330
|
-
*/
|
|
331
|
-
static fromPoints(a, b) {
|
|
332
|
-
const veca = Vec2.resolve(a);
|
|
333
|
-
const vecb = Vec2.resolve(b);
|
|
334
|
-
const m = (vecb.y - veca.y) / (vecb.x - veca.x);
|
|
335
|
-
const h = -m * veca.x + veca.y;
|
|
336
|
-
return new this(m, h);
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Create a linear function with a factor and height
|
|
340
|
-
* @param m The factor
|
|
341
|
-
* @param b The height
|
|
342
|
-
*/
|
|
343
|
-
constructor(m, b) {
|
|
344
|
-
super();
|
|
345
|
-
if (!checkNumber(m))
|
|
346
|
-
throw new TypeError("expected number for m");
|
|
347
|
-
if (!checkNumber(b))
|
|
348
|
-
throw new TypeError("expected number for b");
|
|
349
|
-
this.m = m;
|
|
350
|
-
this.b = b;
|
|
351
|
-
}
|
|
352
|
-
get(x) {
|
|
353
|
-
if (!checkNumber(x))
|
|
354
|
-
throw new TypeError("expected number for x");
|
|
355
|
-
return this.m;
|
|
356
|
-
}
|
|
357
|
-
roots() {
|
|
358
|
-
const x = -this.b / this.m;
|
|
359
|
-
if (!isNaN(x))
|
|
360
|
-
return [new Vec2(x, 0)];
|
|
361
|
-
return [];
|
|
362
|
-
}
|
|
363
|
-
toString() {
|
|
364
|
-
const bsign = signCharacter(this.b);
|
|
365
|
-
if (bsign)
|
|
366
|
-
return `f(x) = ${this.m} * x ${bsign} ${Math.abs(this.b)}`;
|
|
367
|
-
return `f(x) = ${this.m} * x`;
|
|
368
|
-
}
|
|
369
|
-
get [Symbol.toStringTag]() {
|
|
370
|
-
return "LinearFunction";
|
|
371
|
-
}
|
|
372
|
-
[NodeJSCustomInspect]() {
|
|
373
|
-
return `LinearFunction <${this.toString()}>`;
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
// source/algebra/quad.ts
|
|
378
|
-
var QuadFunction = class extends MathFunction {
|
|
379
|
-
a;
|
|
380
|
-
b;
|
|
381
|
-
c;
|
|
382
|
-
static get(a, b, c, x) {
|
|
383
|
-
return new this(a, b, c).get(x);
|
|
384
|
-
}
|
|
385
|
-
constructor(a, b, c) {
|
|
386
|
-
super();
|
|
387
|
-
if (!checkNumber(a))
|
|
388
|
-
throw new TypeError("expected number for a");
|
|
389
|
-
if (a == 0)
|
|
390
|
-
throw new TypeError("a cannot be 0");
|
|
391
|
-
if (!checkNumber(b))
|
|
392
|
-
throw new TypeError("expected number for b");
|
|
393
|
-
if (!checkNumber(c))
|
|
394
|
-
throw new TypeError("expected number for c");
|
|
395
|
-
this.a = a;
|
|
396
|
-
this.b = b;
|
|
397
|
-
this.c = c;
|
|
398
|
-
}
|
|
399
|
-
get(x) {
|
|
400
|
-
if (!checkNumber(x))
|
|
401
|
-
throw new TypeError("expected number for x");
|
|
402
|
-
return this.a * x * x + this.b * x + this.c;
|
|
403
|
-
}
|
|
404
|
-
roots() {
|
|
405
|
-
const roots = new Array();
|
|
406
|
-
const discriminant = this.b * this.b - 4 * this.a * this.c;
|
|
407
|
-
const n0 = (-this.b + Math.sqrt(discriminant)) / (2 * this.a);
|
|
408
|
-
const n1 = (-this.b + Math.sqrt(discriminant)) / (2 * this.a);
|
|
409
|
-
if (!isNaN(n0))
|
|
410
|
-
roots.push(new Vec2(n0, 0));
|
|
411
|
-
if (!isNaN(n1) && n0 != n1)
|
|
412
|
-
roots.push(new Vec2(n1, 0));
|
|
413
|
-
return roots;
|
|
414
|
-
}
|
|
415
|
-
toString(type = "standard") {
|
|
416
|
-
switch (type) {
|
|
417
|
-
default:
|
|
418
|
-
case "standard": {
|
|
419
|
-
const bsign = signCharacter(this.b);
|
|
420
|
-
const csign = signCharacter(this.c);
|
|
421
|
-
if (bsign && csign)
|
|
422
|
-
return `f(x) = ${this.a}x^2 ${bsign} ${Math.abs(this.b)}x ${csign} ${Math.abs(this.c)}`;
|
|
423
|
-
if (bsign)
|
|
424
|
-
return `f(x) = ${this.a}x^2 ${bsign} ${Math.abs(this.b)}x`;
|
|
425
|
-
return `f(x) = ${this.a}x^2`;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
get [Symbol.toStringTag]() {
|
|
430
|
-
return "QuadFunction";
|
|
431
|
-
}
|
|
432
|
-
[NodeJSCustomInspect]() {
|
|
433
|
-
return `QuadFunction <${this.toString()}>`;
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
// source/crypto/hash.ts
|
|
438
|
-
var DJB2_OFFSET = 5381n;
|
|
439
|
-
function djb2(value) {
|
|
440
|
-
const string = String(value);
|
|
441
|
-
let hash = DJB2_OFFSET;
|
|
442
|
-
for (let i = 0; i < string.length; i++) {
|
|
443
|
-
hash = (hash << 5n) + hash + BigInt(string.charCodeAt(i));
|
|
444
|
-
}
|
|
445
|
-
return hash;
|
|
446
|
-
}
|
|
447
|
-
var FNV1_OFFSET = 14695981039346656037n;
|
|
448
|
-
var FNV1_PRIME = 1099511628211n;
|
|
449
|
-
function fnv1(value) {
|
|
450
|
-
const string = String(value);
|
|
451
|
-
let hash = FNV1_OFFSET;
|
|
452
|
-
for (let i = 0; i < string.length; i++) {
|
|
453
|
-
hash *= FNV1_PRIME;
|
|
454
|
-
hash ^= BigInt(string.charCodeAt(i));
|
|
455
|
-
}
|
|
456
|
-
return hash;
|
|
457
|
-
}
|
|
458
|
-
function sdbm(value) {
|
|
459
|
-
const string = String(value);
|
|
460
|
-
let hash = 0n;
|
|
461
|
-
for (let i = 0; i < string.length; i++) {
|
|
462
|
-
hash = BigInt(string.charCodeAt(i)) + (hash << 6n) + (hash << 16n) - hash;
|
|
463
|
-
}
|
|
464
|
-
return hash;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// source/crypto/md2.ts
|
|
468
|
-
var STABLE = [
|
|
469
|
-
41,
|
|
470
|
-
46,
|
|
471
|
-
67,
|
|
472
|
-
201,
|
|
473
|
-
162,
|
|
474
|
-
216,
|
|
475
|
-
124,
|
|
476
|
-
1,
|
|
477
|
-
61,
|
|
478
|
-
54,
|
|
479
|
-
84,
|
|
480
|
-
161,
|
|
481
|
-
236,
|
|
482
|
-
240,
|
|
483
|
-
6,
|
|
484
|
-
19,
|
|
485
|
-
98,
|
|
486
|
-
167,
|
|
487
|
-
5,
|
|
488
|
-
243,
|
|
489
|
-
192,
|
|
490
|
-
199,
|
|
491
|
-
115,
|
|
492
|
-
140,
|
|
493
|
-
152,
|
|
494
|
-
147,
|
|
495
|
-
43,
|
|
496
|
-
217,
|
|
497
|
-
188,
|
|
498
|
-
76,
|
|
499
|
-
130,
|
|
500
|
-
202,
|
|
501
|
-
30,
|
|
502
|
-
155,
|
|
503
|
-
87,
|
|
504
|
-
60,
|
|
505
|
-
253,
|
|
506
|
-
212,
|
|
507
|
-
224,
|
|
508
|
-
22,
|
|
509
|
-
103,
|
|
510
|
-
66,
|
|
511
|
-
111,
|
|
512
|
-
24,
|
|
513
|
-
138,
|
|
514
|
-
23,
|
|
515
|
-
229,
|
|
516
|
-
18,
|
|
517
|
-
190,
|
|
518
|
-
78,
|
|
519
|
-
196,
|
|
520
|
-
214,
|
|
521
|
-
218,
|
|
522
|
-
158,
|
|
523
|
-
222,
|
|
524
|
-
73,
|
|
525
|
-
160,
|
|
526
|
-
251,
|
|
527
|
-
245,
|
|
528
|
-
142,
|
|
529
|
-
187,
|
|
530
|
-
47,
|
|
531
|
-
238,
|
|
532
|
-
122,
|
|
533
|
-
169,
|
|
534
|
-
104,
|
|
535
|
-
121,
|
|
536
|
-
145,
|
|
537
|
-
21,
|
|
538
|
-
178,
|
|
539
|
-
7,
|
|
540
|
-
63,
|
|
541
|
-
148,
|
|
542
|
-
194,
|
|
543
|
-
16,
|
|
544
|
-
137,
|
|
545
|
-
11,
|
|
546
|
-
34,
|
|
547
|
-
95,
|
|
548
|
-
33,
|
|
549
|
-
128,
|
|
550
|
-
127,
|
|
551
|
-
93,
|
|
552
|
-
154,
|
|
553
|
-
90,
|
|
554
|
-
144,
|
|
555
|
-
50,
|
|
556
|
-
39,
|
|
557
|
-
53,
|
|
558
|
-
62,
|
|
559
|
-
204,
|
|
560
|
-
231,
|
|
561
|
-
191,
|
|
562
|
-
247,
|
|
563
|
-
151,
|
|
564
|
-
3,
|
|
565
|
-
255,
|
|
566
|
-
25,
|
|
567
|
-
48,
|
|
568
|
-
179,
|
|
569
|
-
72,
|
|
570
|
-
165,
|
|
571
|
-
181,
|
|
572
|
-
209,
|
|
573
|
-
215,
|
|
574
|
-
94,
|
|
575
|
-
146,
|
|
576
|
-
42,
|
|
577
|
-
172,
|
|
578
|
-
86,
|
|
579
|
-
170,
|
|
580
|
-
198,
|
|
581
|
-
79,
|
|
582
|
-
184,
|
|
583
|
-
56,
|
|
584
|
-
210,
|
|
585
|
-
150,
|
|
586
|
-
164,
|
|
587
|
-
125,
|
|
588
|
-
182,
|
|
589
|
-
118,
|
|
590
|
-
252,
|
|
591
|
-
107,
|
|
592
|
-
226,
|
|
593
|
-
156,
|
|
594
|
-
116,
|
|
595
|
-
4,
|
|
596
|
-
241,
|
|
597
|
-
69,
|
|
598
|
-
157,
|
|
599
|
-
112,
|
|
600
|
-
89,
|
|
601
|
-
100,
|
|
602
|
-
113,
|
|
603
|
-
135,
|
|
604
|
-
32,
|
|
605
|
-
134,
|
|
606
|
-
91,
|
|
607
|
-
207,
|
|
608
|
-
101,
|
|
609
|
-
230,
|
|
610
|
-
45,
|
|
611
|
-
168,
|
|
612
|
-
2,
|
|
613
|
-
27,
|
|
614
|
-
96,
|
|
615
|
-
37,
|
|
616
|
-
173,
|
|
617
|
-
174,
|
|
618
|
-
176,
|
|
619
|
-
185,
|
|
620
|
-
246,
|
|
621
|
-
28,
|
|
622
|
-
70,
|
|
623
|
-
97,
|
|
624
|
-
105,
|
|
625
|
-
52,
|
|
626
|
-
64,
|
|
627
|
-
126,
|
|
628
|
-
15,
|
|
629
|
-
85,
|
|
630
|
-
71,
|
|
631
|
-
163,
|
|
632
|
-
35,
|
|
633
|
-
221,
|
|
634
|
-
81,
|
|
635
|
-
175,
|
|
636
|
-
58,
|
|
637
|
-
195,
|
|
638
|
-
92,
|
|
639
|
-
249,
|
|
640
|
-
206,
|
|
641
|
-
186,
|
|
642
|
-
197,
|
|
643
|
-
234,
|
|
644
|
-
38,
|
|
645
|
-
44,
|
|
646
|
-
83,
|
|
647
|
-
13,
|
|
648
|
-
110,
|
|
649
|
-
133,
|
|
650
|
-
40,
|
|
651
|
-
132,
|
|
652
|
-
9,
|
|
653
|
-
211,
|
|
654
|
-
223,
|
|
655
|
-
205,
|
|
656
|
-
244,
|
|
657
|
-
65,
|
|
658
|
-
129,
|
|
659
|
-
77,
|
|
660
|
-
82,
|
|
661
|
-
106,
|
|
662
|
-
220,
|
|
663
|
-
55,
|
|
664
|
-
200,
|
|
665
|
-
108,
|
|
666
|
-
193,
|
|
667
|
-
171,
|
|
668
|
-
250,
|
|
669
|
-
36,
|
|
670
|
-
225,
|
|
671
|
-
123,
|
|
672
|
-
8,
|
|
673
|
-
12,
|
|
674
|
-
189,
|
|
675
|
-
177,
|
|
676
|
-
74,
|
|
677
|
-
120,
|
|
678
|
-
136,
|
|
679
|
-
149,
|
|
680
|
-
139,
|
|
681
|
-
227,
|
|
682
|
-
99,
|
|
683
|
-
232,
|
|
684
|
-
109,
|
|
685
|
-
233,
|
|
686
|
-
203,
|
|
687
|
-
213,
|
|
688
|
-
254,
|
|
689
|
-
59,
|
|
690
|
-
0,
|
|
691
|
-
29,
|
|
692
|
-
57,
|
|
693
|
-
242,
|
|
694
|
-
239,
|
|
695
|
-
183,
|
|
696
|
-
14,
|
|
697
|
-
102,
|
|
698
|
-
88,
|
|
699
|
-
208,
|
|
700
|
-
228,
|
|
701
|
-
166,
|
|
702
|
-
119,
|
|
703
|
-
114,
|
|
704
|
-
248,
|
|
705
|
-
235,
|
|
706
|
-
117,
|
|
707
|
-
75,
|
|
708
|
-
10,
|
|
709
|
-
49,
|
|
710
|
-
68,
|
|
711
|
-
80,
|
|
712
|
-
180,
|
|
713
|
-
143,
|
|
714
|
-
237,
|
|
715
|
-
31,
|
|
716
|
-
26,
|
|
717
|
-
219,
|
|
718
|
-
153,
|
|
719
|
-
141,
|
|
720
|
-
51,
|
|
721
|
-
159,
|
|
722
|
-
17,
|
|
723
|
-
131,
|
|
724
|
-
20
|
|
725
|
-
];
|
|
726
|
-
var MD2 = class _MD2 {
|
|
727
|
-
static BLOCK_SIZE = 16;
|
|
728
|
-
_data = new Uint8Array(16);
|
|
729
|
-
_state = new Uint8Array(48);
|
|
730
|
-
_checksum = new Uint8Array(16);
|
|
731
|
-
_length = 0;
|
|
732
|
-
constructor() {
|
|
733
|
-
for (let i = 0; i < this._state.length; i++)
|
|
734
|
-
this._state[i] = 0;
|
|
735
|
-
for (let i = 0; i < this._checksum.length; i++)
|
|
736
|
-
this._checksum[i] = 0;
|
|
737
|
-
}
|
|
738
|
-
update(input) {
|
|
739
|
-
for (let i = 0; i < input.length; i++) {
|
|
740
|
-
this._data[this._length] = input[i];
|
|
741
|
-
this._length++;
|
|
742
|
-
if (this._length == _MD2.BLOCK_SIZE) {
|
|
743
|
-
this._transform(input);
|
|
744
|
-
this._length = 0;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
return this;
|
|
748
|
-
}
|
|
749
|
-
_transform(data) {
|
|
750
|
-
for (let i = 0; i < 16; ++i) {
|
|
751
|
-
this._state[i + 16] = this._data[i];
|
|
752
|
-
this._state[i + 32] = this._state[i + 16] ^ this._state[i];
|
|
753
|
-
}
|
|
754
|
-
let t = 0;
|
|
755
|
-
for (let i = 0; i < 18; ++i) {
|
|
756
|
-
for (let j = 0; j < 48; ++j) {
|
|
757
|
-
this._state[j] ^= STABLE[t];
|
|
758
|
-
t = this._state[j];
|
|
759
|
-
}
|
|
760
|
-
t = t + i & 255;
|
|
761
|
-
}
|
|
762
|
-
t = this._checksum[15];
|
|
763
|
-
for (let i = 0; i < 16; ++i) {
|
|
764
|
-
this._checksum[i] ^= STABLE[this._data[i] ^ t];
|
|
765
|
-
t = this._checksum[i];
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
digest() {
|
|
769
|
-
const toPad = _MD2.BLOCK_SIZE - this._length;
|
|
770
|
-
while (this._length < _MD2.BLOCK_SIZE)
|
|
771
|
-
this._data[this._length++] = toPad;
|
|
772
|
-
this._transform(this._data);
|
|
773
|
-
this._transform(this._checksum);
|
|
774
|
-
return this._state.slice();
|
|
775
|
-
}
|
|
776
|
-
toString() {
|
|
777
|
-
return "";
|
|
778
|
-
}
|
|
779
|
-
get [Symbol.toStringTag]() {
|
|
780
|
-
return "MD2";
|
|
781
|
-
}
|
|
782
|
-
[NodeJSCustomInspect]() {
|
|
783
|
-
return `MD2 <${this.toString()}>`;
|
|
784
|
-
}
|
|
785
|
-
};
|
|
786
|
-
|
|
787
|
-
// source/geometry/angle.ts
|
|
788
|
-
var MAX_ANGLE_DEGREE = 360;
|
|
789
|
-
var clampAngleDegree = (angle) => angle % MAX_ANGLE_DEGREE;
|
|
790
|
-
var clampAngleRadian = (angle) => clampAngleDegree(degreeToRadian(angle));
|
|
791
|
-
var radianToDegree = (angle) => angle * (180 / Math.PI);
|
|
792
|
-
var degreeToRadian = (angle) => angle * (Math.PI / 180);
|
|
793
|
-
|
|
794
|
-
// source/geometry/circle.ts
|
|
795
|
-
var Circle = class _Circle {
|
|
796
|
-
radius;
|
|
797
|
-
get perimeter() {
|
|
798
|
-
return this.radius * Math.PI * 2;
|
|
799
|
-
}
|
|
800
|
-
get area() {
|
|
801
|
-
return Math.PI * Math.pow(this.radius, 2);
|
|
802
|
-
}
|
|
803
|
-
position;
|
|
804
|
-
get x() {
|
|
805
|
-
return this.position.x;
|
|
806
|
-
}
|
|
807
|
-
set x(val) {
|
|
808
|
-
this.position.x = val;
|
|
809
|
-
}
|
|
810
|
-
get y() {
|
|
811
|
-
return this.position.y;
|
|
812
|
-
}
|
|
813
|
-
set y(val) {
|
|
814
|
-
this.position.y = val;
|
|
815
|
-
}
|
|
816
|
-
get w() {
|
|
817
|
-
return this.position.w;
|
|
818
|
-
}
|
|
819
|
-
set w(val) {
|
|
820
|
-
this.position.w = val;
|
|
821
|
-
}
|
|
822
|
-
static resolve(a) {
|
|
823
|
-
const value = this.cast(a);
|
|
824
|
-
if (typeof value != "undefined")
|
|
825
|
-
return value;
|
|
826
|
-
throw new ResolveError("Circle", a);
|
|
827
|
-
}
|
|
828
|
-
static resolveArgs(args) {
|
|
829
|
-
if (checkNumberArray(args, 3))
|
|
830
|
-
return new this([args[0], args[1]], args[2]);
|
|
831
|
-
if (args.length === 2)
|
|
832
|
-
return new this(args[0], args[1]);
|
|
833
|
-
return this.resolve(args[0]);
|
|
834
|
-
}
|
|
835
|
-
static cast(a) {
|
|
836
|
-
if (a == null || typeof a == "undefined")
|
|
837
|
-
return void 0;
|
|
838
|
-
if (checkNumberArray(a, 3))
|
|
839
|
-
return new this([a[0], a[1]], a[2]);
|
|
840
|
-
if (checkNumberArray(a, 4)) {
|
|
841
|
-
const c = new this([a[0], a[1]], a[3]);
|
|
842
|
-
c.w = a[2];
|
|
843
|
-
return c;
|
|
844
|
-
}
|
|
845
|
-
if (hasProperty(a, "toCircle", "function"))
|
|
846
|
-
return this.cast(a.toCircle());
|
|
847
|
-
if (hasProperty(a, "x", "number") && hasProperty(a, "y", "number") && hasProperty(a, "radius", "number"))
|
|
848
|
-
return new this(hasProperty(a, "w", "number") ? [a.x, a.y, a.w] : [a.x, a.y], a.radius);
|
|
849
|
-
if (checkString(a)) {
|
|
850
|
-
const [spos, sradius] = a.split("|");
|
|
851
|
-
const pos = Vec2.cast(spos);
|
|
852
|
-
if (typeof pos == "undefined")
|
|
853
|
-
return void 0;
|
|
854
|
-
const radius = parseFloat(sradius);
|
|
855
|
-
if (!isNaN(radius))
|
|
856
|
-
return new this(pos, radius);
|
|
857
|
-
}
|
|
858
|
-
return void 0;
|
|
859
|
-
}
|
|
860
|
-
static is(a) {
|
|
861
|
-
return typeof this.cast(a) != "undefined";
|
|
862
|
-
}
|
|
863
|
-
constructor(position, radius) {
|
|
864
|
-
this.position = Vec2.resolve(position);
|
|
865
|
-
if (!checkNumber(radius))
|
|
866
|
-
throw new TypeError("expected number for radius");
|
|
867
|
-
this.radius = radius;
|
|
868
|
-
}
|
|
869
|
-
toArray() {
|
|
870
|
-
return [...this.position.toArray(), this.radius];
|
|
871
|
-
}
|
|
872
|
-
toJSON() {
|
|
873
|
-
return {
|
|
874
|
-
...this.position.toJSON(),
|
|
875
|
-
radius: this.radius
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
toString() {
|
|
879
|
-
return `${this.position.toString()}|${this.radius}`;
|
|
880
|
-
}
|
|
881
|
-
get [Symbol.toStringTag]() {
|
|
882
|
-
return "Circle";
|
|
883
|
-
}
|
|
884
|
-
[NodeJSCustomInspect]() {
|
|
885
|
-
return `Circle <${this.toString()}>`;
|
|
886
|
-
}
|
|
887
|
-
clone() {
|
|
888
|
-
return new _Circle(this.position.clone(), this.radius);
|
|
889
|
-
}
|
|
890
|
-
toVec2() {
|
|
891
|
-
return [this.x, this.y, this.w];
|
|
892
|
-
}
|
|
893
|
-
equals(...args) {
|
|
894
|
-
const c = _Circle.resolveArgs(args);
|
|
895
|
-
return c.position.equals(c.position) && this.radius == c.radius;
|
|
896
|
-
}
|
|
897
|
-
inside(...args) {
|
|
898
|
-
const circle = _Circle.resolveArgs(args);
|
|
899
|
-
const distX = circle.x - this.x;
|
|
900
|
-
const distY = circle.y - this.y;
|
|
901
|
-
const dist = Math.sqrt(distX * distX + (distY + distY));
|
|
902
|
-
return dist <= this.radius + circle.radius;
|
|
903
|
-
}
|
|
904
|
-
insidePoint(...args) {
|
|
905
|
-
return this.position.distance(Vec2.resolveArgs(args)) <= this.radius;
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
|
|
909
|
-
// source/geometry/bbox.ts
|
|
910
|
-
var BoundingBox = class _BoundingBox {
|
|
911
|
-
left;
|
|
912
|
-
right;
|
|
913
|
-
top;
|
|
914
|
-
bottom;
|
|
915
|
-
get width() {
|
|
916
|
-
return this.right - this.left;
|
|
917
|
-
}
|
|
918
|
-
set width(val) {
|
|
919
|
-
this.right = this.left + val;
|
|
920
|
-
}
|
|
921
|
-
get height() {
|
|
922
|
-
return this.bottom - this.top;
|
|
923
|
-
}
|
|
924
|
-
set height(val) {
|
|
925
|
-
this.bottom = this.top + val;
|
|
926
|
-
}
|
|
927
|
-
get x() {
|
|
928
|
-
return this.left;
|
|
929
|
-
}
|
|
930
|
-
set x(x) {
|
|
931
|
-
this.left = x;
|
|
932
|
-
}
|
|
933
|
-
get y() {
|
|
934
|
-
return this.top;
|
|
935
|
-
}
|
|
936
|
-
set y(y) {
|
|
937
|
-
this.top = y;
|
|
938
|
-
}
|
|
939
|
-
w = 1;
|
|
940
|
-
static resolve(a) {
|
|
941
|
-
const value = this.cast(a);
|
|
942
|
-
if (typeof value != "undefined")
|
|
943
|
-
return value;
|
|
944
|
-
throw new ResolveError("BoundingBox", a);
|
|
945
|
-
}
|
|
946
|
-
static resolveArgs(args) {
|
|
947
|
-
if (checkNumberArray(args, 4))
|
|
948
|
-
return new this(args[0], args[1], args[2], args[3]);
|
|
949
|
-
return this.resolve(args[0]);
|
|
950
|
-
}
|
|
951
|
-
static cast(a) {
|
|
952
|
-
if (a == null || typeof a == "undefined")
|
|
953
|
-
return void 0;
|
|
954
|
-
if (checkNumberArray(a, 4))
|
|
955
|
-
return new this(a[0], a[1], a[2], a[3]);
|
|
956
|
-
if (hasProperty(a, "toBoundingBox", "function"))
|
|
957
|
-
return this.cast(a.toBoundingBox());
|
|
958
|
-
if (hasProperty(a, "left", "number") && hasProperty(a, "right", "number") && hasProperty(a, "top", "number") && hasProperty(a, "bottom", "number"))
|
|
959
|
-
return new this(a.left, a.right, a.top, a.bottom);
|
|
960
|
-
if (checkString(a)) {
|
|
961
|
-
const parts = a.split(",");
|
|
962
|
-
if (checkStringArray(parts, 4))
|
|
963
|
-
return this.cast(parts.map((v) => parseFloat(v)));
|
|
964
|
-
}
|
|
965
|
-
return void 0;
|
|
966
|
-
}
|
|
967
|
-
static is(a) {
|
|
968
|
-
return typeof this.cast(a) != "undefined";
|
|
969
|
-
}
|
|
970
|
-
constructor(left, right, top, bottom) {
|
|
971
|
-
if (!checkNumber(left))
|
|
972
|
-
throw new TypeError("expected number for left");
|
|
973
|
-
if (!checkNumber(right))
|
|
974
|
-
throw new TypeError("expected number for right");
|
|
975
|
-
if (!checkNumber(top))
|
|
976
|
-
throw new TypeError("expected number for top");
|
|
977
|
-
if (!checkNumber(bottom))
|
|
978
|
-
throw new TypeError("expected number for bottom");
|
|
979
|
-
this.left = left;
|
|
980
|
-
this.right = right;
|
|
981
|
-
this.top = top;
|
|
982
|
-
this.bottom = bottom;
|
|
983
|
-
}
|
|
984
|
-
toArray() {
|
|
985
|
-
return [this.left, this.right, this.top, this.bottom];
|
|
986
|
-
}
|
|
987
|
-
toString() {
|
|
988
|
-
return `${this.left},${this.right},${this.top},${this.bottom}`;
|
|
989
|
-
}
|
|
990
|
-
get [Symbol.toStringTag]() {
|
|
991
|
-
return "BoundingBox";
|
|
992
|
-
}
|
|
993
|
-
[NodeJSCustomInspect]() {
|
|
994
|
-
return `BoundingBox <${this.toString()}>`;
|
|
995
|
-
}
|
|
996
|
-
toJSON() {
|
|
997
|
-
return {
|
|
998
|
-
left: this.left,
|
|
999
|
-
top: this.top,
|
|
1000
|
-
right: this.right,
|
|
1001
|
-
bottom: this.bottom
|
|
1002
|
-
};
|
|
1003
|
-
}
|
|
1004
|
-
clone() {
|
|
1005
|
-
return new _BoundingBox(this.left, this.right, this.top, this.bottom);
|
|
1006
|
-
}
|
|
1007
|
-
equals(...args) {
|
|
1008
|
-
const b = _BoundingBox.resolveArgs(args);
|
|
1009
|
-
return this.left === b.left && this.right === b.right && this.top === b.top && this.bottom === b.bottom;
|
|
1010
|
-
}
|
|
1011
|
-
toSize() {
|
|
1012
|
-
return [this.width, this.height];
|
|
1013
|
-
}
|
|
1014
|
-
toVec2() {
|
|
1015
|
-
return [this.left, this.top];
|
|
1016
|
-
}
|
|
1017
|
-
toRectangle() {
|
|
1018
|
-
return [this.left, this.top, this.width, this.height];
|
|
1019
|
-
}
|
|
1020
|
-
inside(...args) {
|
|
1021
|
-
const bbox = _BoundingBox.resolve(args);
|
|
1022
|
-
return this.right >= bbox.left && bbox.right >= this.left && this.bottom >= bbox.top && bbox.bottom >= this.top;
|
|
1023
|
-
}
|
|
1024
|
-
insidePoint(...args) {
|
|
1025
|
-
const point = Vec2.resolveArgs(args);
|
|
1026
|
-
return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y;
|
|
1027
|
-
}
|
|
1028
|
-
insideCircle(...args) {
|
|
1029
|
-
const circle = Circle.resolveArgs(args);
|
|
1030
|
-
const center = Vec2.resolve(circle).add(circle.radius);
|
|
1031
|
-
const bboxhe = new Vec2(this.width / 2, this.height / 2);
|
|
1032
|
-
const bboxcenter = new Vec2(this.left + bboxhe.x, this.top + bboxhe.y);
|
|
1033
|
-
let diff = center.subtract(bboxcenter);
|
|
1034
|
-
const clamped = Vec2.clamp(diff, bboxhe.invert(), bboxhe);
|
|
1035
|
-
const closest = bboxcenter.add(clamped);
|
|
1036
|
-
diff = closest.subtract(center);
|
|
1037
|
-
return diff.length() < circle.radius;
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
|
-
// source/geometry/size.ts
|
|
1042
|
-
var Size = class _Size {
|
|
1043
|
-
width;
|
|
1044
|
-
height;
|
|
1045
|
-
get aspectRatio() {
|
|
1046
|
-
return this.height / this.width;
|
|
1047
|
-
}
|
|
1048
|
-
get area() {
|
|
1049
|
-
return this.width * this.height;
|
|
1050
|
-
}
|
|
1051
|
-
get perimeter() {
|
|
1052
|
-
return this.width + this.width + this.height + this.height;
|
|
1053
|
-
}
|
|
1054
|
-
static resolve(a) {
|
|
1055
|
-
const value = this.cast(a);
|
|
1056
|
-
if (typeof value != "undefined")
|
|
1057
|
-
return value;
|
|
1058
|
-
throw new ResolveError("Square", a);
|
|
1059
|
-
}
|
|
1060
|
-
static resolveArgs(args) {
|
|
1061
|
-
if (checkNumberArray(args, 2))
|
|
1062
|
-
return new this(args[0], args[1]);
|
|
1063
|
-
return this.resolve(args[0]);
|
|
1064
|
-
}
|
|
1065
|
-
static cast(a) {
|
|
1066
|
-
if (a == null || typeof a == "undefined")
|
|
1067
|
-
return void 0;
|
|
1068
|
-
if (checkNumberArray(a, 2))
|
|
1069
|
-
return new this(a[0], a[1]);
|
|
1070
|
-
if (hasProperty(a, "toSize", "function"))
|
|
1071
|
-
return this.cast(a.toSize());
|
|
1072
|
-
if (hasProperty(a, "width", "number") && hasProperty(a, "height", "number"))
|
|
1073
|
-
return new this(a.width, a.height);
|
|
1074
|
-
if (checkString(a)) {
|
|
1075
|
-
const parts = a.split("x").map((v) => parseFloat(v));
|
|
1076
|
-
if (checkNumberArray(parts, 2))
|
|
1077
|
-
return this.cast(parts);
|
|
1078
|
-
}
|
|
1079
|
-
if (checkNumber(a))
|
|
1080
|
-
return new this(a, a);
|
|
1081
|
-
return void 0;
|
|
1082
|
-
}
|
|
1083
|
-
static is(a) {
|
|
1084
|
-
return typeof this.cast(a) != "undefined";
|
|
1085
|
-
}
|
|
1086
|
-
constructor(width, height) {
|
|
1087
|
-
if (!checkNumber(width))
|
|
1088
|
-
throw new TypeError("expected number for width");
|
|
1089
|
-
if (!checkNumber(height))
|
|
1090
|
-
throw new TypeError("expected number for height");
|
|
1091
|
-
this.width = width;
|
|
1092
|
-
this.height = height;
|
|
1093
|
-
}
|
|
1094
|
-
toArray() {
|
|
1095
|
-
return [this.width, this.height];
|
|
1096
|
-
}
|
|
1097
|
-
toString() {
|
|
1098
|
-
return `${this.width}x${this.height}`;
|
|
1099
|
-
}
|
|
1100
|
-
get [Symbol.toStringTag]() {
|
|
1101
|
-
return "Size";
|
|
1102
|
-
}
|
|
1103
|
-
[NodeJSCustomInspect]() {
|
|
1104
|
-
return `Size <${this.toString()}>`;
|
|
1105
|
-
}
|
|
1106
|
-
toJSON() {
|
|
1107
|
-
return {
|
|
1108
|
-
width: this.width,
|
|
1109
|
-
height: this.height
|
|
1110
|
-
};
|
|
1111
|
-
}
|
|
1112
|
-
clone() {
|
|
1113
|
-
return new _Size(this.width, this.height);
|
|
1114
|
-
}
|
|
1115
|
-
equals(...args) {
|
|
1116
|
-
const s = _Size.resolveArgs(args);
|
|
1117
|
-
return this.width == s.width && this.height == s.height;
|
|
1118
|
-
}
|
|
1119
|
-
toVec2() {
|
|
1120
|
-
return [this.width, this.height];
|
|
1121
|
-
}
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
|
-
// source/geometry/rectangle.ts
|
|
1125
|
-
var Rectangle = class _Rectangle {
|
|
1126
|
-
position;
|
|
1127
|
-
size;
|
|
1128
|
-
get area() {
|
|
1129
|
-
return this.width * this.height;
|
|
1130
|
-
}
|
|
1131
|
-
get perimeter() {
|
|
1132
|
-
return this.width + this.width + this.height + this.height;
|
|
1133
|
-
}
|
|
1134
|
-
get x() {
|
|
1135
|
-
return this.position.x;
|
|
1136
|
-
}
|
|
1137
|
-
set x(val) {
|
|
1138
|
-
this.position.x = val;
|
|
1139
|
-
}
|
|
1140
|
-
get y() {
|
|
1141
|
-
return this.position.y;
|
|
1142
|
-
}
|
|
1143
|
-
set y(val) {
|
|
1144
|
-
this.position.y = val;
|
|
1145
|
-
}
|
|
1146
|
-
get w() {
|
|
1147
|
-
return this.position.w;
|
|
1148
|
-
}
|
|
1149
|
-
set w(val) {
|
|
1150
|
-
this.position.w = val;
|
|
1151
|
-
}
|
|
1152
|
-
get width() {
|
|
1153
|
-
return this.size.width;
|
|
1154
|
-
}
|
|
1155
|
-
set width(val) {
|
|
1156
|
-
this.size.width = val;
|
|
1157
|
-
}
|
|
1158
|
-
get height() {
|
|
1159
|
-
return this.size.height;
|
|
1160
|
-
}
|
|
1161
|
-
set height(val) {
|
|
1162
|
-
this.size.height = val;
|
|
1163
|
-
}
|
|
1164
|
-
static resolve(a) {
|
|
1165
|
-
const value = this.cast(a);
|
|
1166
|
-
if (typeof value != "undefined")
|
|
1167
|
-
return value;
|
|
1168
|
-
throw new ResolveError("Rectangle", a);
|
|
1169
|
-
}
|
|
1170
|
-
static resolveArgs(args) {
|
|
1171
|
-
if (checkNumberArray(args, 4))
|
|
1172
|
-
return new this([args[0], args[1]], [args[2], args[3]]);
|
|
1173
|
-
return this.resolve(args[0]);
|
|
1174
|
-
}
|
|
1175
|
-
static cast(a) {
|
|
1176
|
-
if (a == null || typeof a == "undefined")
|
|
1177
|
-
return void 0;
|
|
1178
|
-
if (checkNumberArray(a, 4))
|
|
1179
|
-
return new this([a[0], a[1]], [a[2], a[3]]);
|
|
1180
|
-
if (checkNumberArray(a, 5)) {
|
|
1181
|
-
const rect = new this([a[0], a[1]], [a[3], a[4]]);
|
|
1182
|
-
rect.w = a[2];
|
|
1183
|
-
return rect;
|
|
1184
|
-
}
|
|
1185
|
-
if (checkString(a)) {
|
|
1186
|
-
const [spos, ssize] = a.split("|");
|
|
1187
|
-
const pos = Vec2.cast(spos);
|
|
1188
|
-
const size = Size.cast(ssize);
|
|
1189
|
-
if (typeof pos == "undefined" || typeof size == "undefined")
|
|
1190
|
-
return void 0;
|
|
1191
|
-
const rect = new this([pos.x, pos.y], [size.width, size.height]);
|
|
1192
|
-
rect.w = pos.w;
|
|
1193
|
-
return rect;
|
|
1194
|
-
}
|
|
1195
|
-
if (hasProperty(a, "toRectangle", "function"))
|
|
1196
|
-
return this.cast(a.toRectangle());
|
|
1197
|
-
if (hasProperty(a, "x", "number") && hasProperty(a, "y", "number") && hasProperty(a, "width", "number") && hasProperty(a, "height", "number")) {
|
|
1198
|
-
const rect = new this([a.x, a.y], [a.width, a.height]);
|
|
1199
|
-
if (hasProperty(a, "w", "number"))
|
|
1200
|
-
rect.w = a.w;
|
|
1201
|
-
return rect;
|
|
1202
|
-
}
|
|
1203
|
-
return void 0;
|
|
1204
|
-
}
|
|
1205
|
-
static is(a) {
|
|
1206
|
-
return typeof this.cast(a) != "undefined";
|
|
1207
|
-
}
|
|
1208
|
-
constructor(pos, size) {
|
|
1209
|
-
this.position = Vec2.resolve(pos);
|
|
1210
|
-
this.size = Size.resolve(size);
|
|
1211
|
-
}
|
|
1212
|
-
toArray(w = this.w !== 1) {
|
|
1213
|
-
return [...this.position.toArray(w), ...this.size.toArray()];
|
|
1214
|
-
}
|
|
1215
|
-
toString(w = this.w !== 1) {
|
|
1216
|
-
return `${this.position.toString(w)}|${this.size.toString()}`;
|
|
1217
|
-
}
|
|
1218
|
-
get [Symbol.toStringTag]() {
|
|
1219
|
-
return "Rectangle";
|
|
1220
|
-
}
|
|
1221
|
-
[NodeJSCustomInspect]() {
|
|
1222
|
-
return `Rectangle <${this.toString()}>`;
|
|
1223
|
-
}
|
|
1224
|
-
toJSON() {
|
|
1225
|
-
return { ...this.position.toJSON(), ...this.size.toJSON() };
|
|
1226
|
-
}
|
|
1227
|
-
toBoundingBox() {
|
|
1228
|
-
return [this.x, this.x + this.width, this.y, this.y + this.height];
|
|
1229
|
-
}
|
|
1230
|
-
toVec2() {
|
|
1231
|
-
return [this.x, this.y, this.w];
|
|
1232
|
-
}
|
|
1233
|
-
toSize() {
|
|
1234
|
-
return [this.width, this.height];
|
|
1235
|
-
}
|
|
1236
|
-
clone() {
|
|
1237
|
-
return new _Rectangle(this.position.clone(), this.size.clone());
|
|
1238
|
-
}
|
|
1239
|
-
equals(...args) {
|
|
1240
|
-
const rect = _Rectangle.resolveArgs(args);
|
|
1241
|
-
return this.position.equals(rect.position) && this.size.equals(rect.size);
|
|
1242
|
-
}
|
|
1243
|
-
};
|
|
1244
|
-
|
|
1245
|
-
// source/common/string.ts
|
|
1246
|
-
function stringify(value) {
|
|
1247
|
-
return value != null && typeof value == "object" && "toString" in value && typeof value.toString == "function" ? value.toString() : String(value);
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
// source/vectors/vec3.ts
|
|
1251
|
-
var Vec3 = class _Vec3 {
|
|
1252
|
-
x;
|
|
1253
|
-
y;
|
|
1254
|
-
z;
|
|
1255
|
-
w;
|
|
1256
|
-
static resolve(a) {
|
|
1257
|
-
const value = this.cast(a);
|
|
1258
|
-
if (typeof value != "undefined")
|
|
1259
|
-
return value;
|
|
1260
|
-
throw new ResolveError("Vec3", a);
|
|
1261
|
-
}
|
|
1262
|
-
static cast(a) {
|
|
1263
|
-
if (a == null || typeof a == "undefined")
|
|
1264
|
-
return void 0;
|
|
1265
|
-
if (checkNumberArray(a, 3) || checkNumberArray(a, 4))
|
|
1266
|
-
return new this(a[0], a[1], a[2], checkNumber(a[3]) ? a[3] : void 0);
|
|
1267
|
-
if (hasProperty(a, "x", "number") && hasProperty(a, "y", "number") && hasProperty(a, "z", "number"))
|
|
1268
|
-
return new this(a.x, a.y, a.z, hasProperty(a, "w", "number") ? a.w : void 0);
|
|
1269
|
-
if (checkString(a)) {
|
|
1270
|
-
const [sxyz, sw] = a.split(";");
|
|
1271
|
-
if (checkString(sxyz)) {
|
|
1272
|
-
const parts = sxyz.split(",");
|
|
1273
|
-
if (checkStringArray(parts, 3))
|
|
1274
|
-
return new this(parseFloat(parts[0]), parseFloat(parts[1]), parseFloat(parts[2]), checkString(sw) ? parseFloat(sw) : void 0);
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
if (checkNumber(a))
|
|
1278
|
-
return new this(a, a, a);
|
|
1279
|
-
return void 0;
|
|
1280
|
-
}
|
|
1281
|
-
static resolveArgs(args) {
|
|
1282
|
-
if (checkNumberArray(args, 3))
|
|
1283
|
-
return new this(args[0], args[1], args[2]);
|
|
1284
|
-
return this.resolve(args[0]);
|
|
1285
|
-
}
|
|
1286
|
-
static is(a) {
|
|
1287
|
-
return typeof this.cast(a) != "undefined";
|
|
1288
|
-
}
|
|
1289
|
-
static fromPoints(a, b) {
|
|
1290
|
-
const veca = this.resolve(a);
|
|
1291
|
-
const vecb = this.resolve(b);
|
|
1292
|
-
return new this(vecb.x - veca.x, vecb.y - veca.y, vecb.z - veca.z);
|
|
1293
|
-
}
|
|
1294
|
-
static clamp(value, min, max) {
|
|
1295
|
-
const a = this.resolve(value), b = this.resolve(min), c = this.resolve(max);
|
|
1296
|
-
return new this(
|
|
1297
|
-
clamp(a.x, b.x, c.x),
|
|
1298
|
-
clamp(a.y, b.y, c.y),
|
|
1299
|
-
clamp(a.z, b.z, c.z)
|
|
1300
|
-
);
|
|
1301
|
-
}
|
|
1302
|
-
static intersectPlane(planeP, planeN, lineStart, lineEnd, t) {
|
|
1303
|
-
planeN = this.resolve(planeN).normalize();
|
|
1304
|
-
const plane_d = -this.resolve(planeN).dot(planeP);
|
|
1305
|
-
const ad = this.resolve(lineStart).dot(planeN);
|
|
1306
|
-
const bd = this.resolve(lineEnd).dot(planeN);
|
|
1307
|
-
t = (-plane_d - ad) / (bd - ad);
|
|
1308
|
-
const lineStartToEnd = this.resolve(lineEnd).subtract(lineStart);
|
|
1309
|
-
const linetoIntersect = lineStartToEnd.multiply(t);
|
|
1310
|
-
return _Vec3.resolve(lineStart).add(linetoIntersect);
|
|
1311
|
-
}
|
|
1312
|
-
static get zero() {
|
|
1313
|
-
return new this(0, 0, 0);
|
|
1314
|
-
}
|
|
1315
|
-
static get one() {
|
|
1316
|
-
return new this(1, 1, 1);
|
|
1317
|
-
}
|
|
1318
|
-
constructor(x, y, z, w = 1) {
|
|
1319
|
-
if (!checkNumber(x))
|
|
1320
|
-
throw new TypeError("expected number for x");
|
|
1321
|
-
if (!checkNumber(y))
|
|
1322
|
-
throw new TypeError("expected number for y");
|
|
1323
|
-
if (!checkNumber(z))
|
|
1324
|
-
throw new TypeError("expected number for z");
|
|
1325
|
-
if (!checkNumber(w))
|
|
1326
|
-
throw new TypeError("expected number for w");
|
|
1327
|
-
this.x = x;
|
|
1328
|
-
this.y = y;
|
|
1329
|
-
this.z = z;
|
|
1330
|
-
this.w = w;
|
|
1331
|
-
}
|
|
1332
|
-
toArray(w = this.w !== 1) {
|
|
1333
|
-
return w ? [this.x, this.y, this.z, this.w] : [this.x, this.y, this.z];
|
|
1334
|
-
}
|
|
1335
|
-
toJSON() {
|
|
1336
|
-
return {
|
|
1337
|
-
x: this.x,
|
|
1338
|
-
y: this.y,
|
|
1339
|
-
z: this.z,
|
|
1340
|
-
w: this.w
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
toString(w = this.w !== 1) {
|
|
1344
|
-
return w ? `${this.x},${this.y},${this.z};${this.w}` : `${this.x},${this.y},${this.z}`;
|
|
1345
|
-
}
|
|
1346
|
-
get [Symbol.toStringTag]() {
|
|
1347
|
-
return "Vec3";
|
|
1348
|
-
}
|
|
1349
|
-
[NodeJSCustomInspect]() {
|
|
1350
|
-
return `Vec3 <${this.toString()}>`;
|
|
1351
|
-
}
|
|
1352
|
-
toVec2() {
|
|
1353
|
-
return [this.x, this.y, this.w];
|
|
1354
|
-
}
|
|
1355
|
-
toRGB() {
|
|
1356
|
-
const vec = this.normalize();
|
|
1357
|
-
return [vec.x, vec.y, vec.z];
|
|
1358
|
-
}
|
|
1359
|
-
toRGBA() {
|
|
1360
|
-
const vec = this.normalize();
|
|
1361
|
-
return [vec.x, vec.y, vec.z, vec.w];
|
|
1362
|
-
}
|
|
1363
|
-
toHSL() {
|
|
1364
|
-
const vec = this.normalize();
|
|
1365
|
-
return [vec.x, vec.y, vec.z];
|
|
1366
|
-
}
|
|
1367
|
-
toHSLA() {
|
|
1368
|
-
const vec = this.normalize();
|
|
1369
|
-
return [vec.x, vec.y, vec.z, vec.w];
|
|
1370
|
-
}
|
|
1371
|
-
toQuaternion() {
|
|
1372
|
-
return [this.w, this.x, this.y, this.z];
|
|
1373
|
-
}
|
|
1374
|
-
clone() {
|
|
1375
|
-
return new _Vec3(this.x, this.y, this.z, this.w);
|
|
1376
|
-
}
|
|
1377
|
-
equals(...args) {
|
|
1378
|
-
const a = _Vec3.resolveArgs(args);
|
|
1379
|
-
return this.x == a.x && this.y == a.y && this.z == a.z;
|
|
1380
|
-
}
|
|
1381
|
-
setX(x) {
|
|
1382
|
-
this.x = x;
|
|
1383
|
-
return this;
|
|
1384
|
-
}
|
|
1385
|
-
setY(y) {
|
|
1386
|
-
this.y = y;
|
|
1387
|
-
return this;
|
|
1388
|
-
}
|
|
1389
|
-
setZ(z) {
|
|
1390
|
-
this.z = z;
|
|
1391
|
-
return this;
|
|
1392
|
-
}
|
|
1393
|
-
set(...args) {
|
|
1394
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1395
|
-
return this.setX(vec.x).setY(vec.y).setZ(vec.z);
|
|
1396
|
-
}
|
|
1397
|
-
add(...args) {
|
|
1398
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1399
|
-
return new _Vec3(
|
|
1400
|
-
this.x + vec.x,
|
|
1401
|
-
this.y + vec.y,
|
|
1402
|
-
this.z + vec.z
|
|
1403
|
-
);
|
|
1404
|
-
}
|
|
1405
|
-
offset(...args) {
|
|
1406
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1407
|
-
this.x += vec.x;
|
|
1408
|
-
this.y += vec.y;
|
|
1409
|
-
this.z += vec.z;
|
|
1410
|
-
return this;
|
|
1411
|
-
}
|
|
1412
|
-
subtract(...args) {
|
|
1413
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1414
|
-
return new _Vec3(
|
|
1415
|
-
this.x - vec.x,
|
|
1416
|
-
this.y - vec.y,
|
|
1417
|
-
this.z - vec.z
|
|
1418
|
-
);
|
|
1419
|
-
}
|
|
1420
|
-
multiply(scalar) {
|
|
1421
|
-
return new _Vec3(
|
|
1422
|
-
this.x * scalar,
|
|
1423
|
-
this.y * scalar,
|
|
1424
|
-
this.z * scalar
|
|
1425
|
-
);
|
|
1426
|
-
}
|
|
1427
|
-
naiveMultiply(...args) {
|
|
1428
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1429
|
-
return new _Vec3(
|
|
1430
|
-
this.x * vec.x,
|
|
1431
|
-
this.y * vec.y,
|
|
1432
|
-
this.z * vec.z
|
|
1433
|
-
);
|
|
1434
|
-
}
|
|
1435
|
-
divide(...args) {
|
|
1436
|
-
if (checkNumberArray(args, 1))
|
|
1437
|
-
return new _Vec3(
|
|
1438
|
-
this.x / args[0],
|
|
1439
|
-
this.y / args[0],
|
|
1440
|
-
this.z / args[0]
|
|
1441
|
-
);
|
|
1442
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1443
|
-
return new _Vec3(
|
|
1444
|
-
this.x / vec.x,
|
|
1445
|
-
this.y / vec.y,
|
|
1446
|
-
this.z / vec.z
|
|
1447
|
-
);
|
|
1448
|
-
}
|
|
1449
|
-
dot(...args) {
|
|
1450
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1451
|
-
return this.x * vec.x + this.y * vec.y + this.z * vec.z;
|
|
1452
|
-
}
|
|
1453
|
-
cross(...args) {
|
|
1454
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1455
|
-
return new _Vec3(
|
|
1456
|
-
this.y * vec.z - this.z * vec.y,
|
|
1457
|
-
this.z * vec.x - this.x * vec.z,
|
|
1458
|
-
this.x * vec.y - this.y * vec.x
|
|
1459
|
-
);
|
|
1460
|
-
}
|
|
1461
|
-
distance(...args) {
|
|
1462
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1463
|
-
return Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2) + Math.pow(vec.z - this.z, 2);
|
|
1464
|
-
}
|
|
1465
|
-
distanceSquare(...args) {
|
|
1466
|
-
const vec = _Vec3.resolveArgs(args);
|
|
1467
|
-
return Math.sqrt(Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2) + Math.pow(vec.z - this.z, 2));
|
|
1468
|
-
}
|
|
1469
|
-
length() {
|
|
1470
|
-
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
|
1471
|
-
}
|
|
1472
|
-
normalize() {
|
|
1473
|
-
const length = this.length();
|
|
1474
|
-
if (length == 0) return _Vec3.zero;
|
|
1475
|
-
return new _Vec3(
|
|
1476
|
-
this.x / length,
|
|
1477
|
-
this.y / length,
|
|
1478
|
-
this.z / length,
|
|
1479
|
-
this.w / length
|
|
1480
|
-
);
|
|
1481
|
-
}
|
|
1482
|
-
invert() {
|
|
1483
|
-
return this.multiply(-1);
|
|
1484
|
-
}
|
|
1485
|
-
round() {
|
|
1486
|
-
return new _Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z), Math.round(this.w));
|
|
1487
|
-
}
|
|
1488
|
-
};
|
|
1489
|
-
|
|
1490
|
-
// source/geometry/triangle.ts
|
|
1491
|
-
var Triangle = class {
|
|
1492
|
-
constructor(A, B, C) {
|
|
1493
|
-
this.A = A;
|
|
1494
|
-
this.B = B;
|
|
1495
|
-
this.C = C;
|
|
1496
|
-
}
|
|
1497
|
-
get alpha() {
|
|
1498
|
-
return Math.acos((this.b * this.b + this.c * this.c - this.a * this.a) / (2 * this.b * this.c));
|
|
1499
|
-
}
|
|
1500
|
-
get beta() {
|
|
1501
|
-
return Math.acos((this.c * this.c + this.a * this.a - this.b * this.b) / (2 * this.c * this.a));
|
|
1502
|
-
}
|
|
1503
|
-
get gamma() {
|
|
1504
|
-
return Math.acos((this.a * this.a + this.b * this.b - this.c * this.c) / (2 * this.a * this.b));
|
|
1505
|
-
}
|
|
1506
|
-
get perimeter() {
|
|
1507
|
-
return this.a + this.b + this.c;
|
|
1508
|
-
}
|
|
1509
|
-
get semiperimeter() {
|
|
1510
|
-
return this.perimeter / 2;
|
|
1511
|
-
}
|
|
1512
|
-
get area() {
|
|
1513
|
-
return Math.sqrt(this.semiperimeter * (this.semiperimeter - this.a) * (this.semiperimeter - this.b) * (this.semiperimeter - this.c));
|
|
1514
|
-
}
|
|
1515
|
-
get base() {
|
|
1516
|
-
return 2 * (this.area / (this.a * Math.sin(this.gamma)));
|
|
1517
|
-
}
|
|
1518
|
-
get height() {
|
|
1519
|
-
return 2 * (this.area / this.base);
|
|
1520
|
-
}
|
|
1521
|
-
toString() {
|
|
1522
|
-
return `${stringify(this.A)}|${stringify(this.B)}|${stringify(this.C)}`;
|
|
1523
|
-
}
|
|
1524
|
-
get [Symbol.toStringTag]() {
|
|
1525
|
-
return "Triangle";
|
|
1526
|
-
}
|
|
1527
|
-
[NodeJSCustomInspect]() {
|
|
1528
|
-
return `Triangle <${this.toString()}>`;
|
|
1529
|
-
}
|
|
1530
|
-
};
|
|
1531
|
-
var Triangle2D = class extends Triangle {
|
|
1532
|
-
get a() {
|
|
1533
|
-
return Vec2.fromPoints(this.B, this.C).length();
|
|
1534
|
-
}
|
|
1535
|
-
get b() {
|
|
1536
|
-
return Vec2.fromPoints(this.A, this.C).length();
|
|
1537
|
-
}
|
|
1538
|
-
get c() {
|
|
1539
|
-
return Vec2.fromPoints(this.A, this.B).length();
|
|
1540
|
-
}
|
|
1541
|
-
};
|
|
1542
|
-
var Triangle3D = class extends Triangle {
|
|
1543
|
-
get a() {
|
|
1544
|
-
return Vec3.fromPoints(this.B, this.C).length();
|
|
1545
|
-
}
|
|
1546
|
-
get b() {
|
|
1547
|
-
return Vec3.fromPoints(this.A, this.C).length();
|
|
1548
|
-
}
|
|
1549
|
-
get c() {
|
|
1550
|
-
return Vec3.fromPoints(this.A, this.B).length();
|
|
1551
|
-
}
|
|
1552
|
-
};
|
|
1553
|
-
|
|
1554
|
-
// source/matrices/mat3.ts
|
|
1555
|
-
var Mat3 = class _Mat3 {
|
|
1556
|
-
_raw;
|
|
1557
|
-
get m00() {
|
|
1558
|
-
return this._raw[0];
|
|
1559
|
-
}
|
|
1560
|
-
set m00(val) {
|
|
1561
|
-
this._raw[0] = val;
|
|
1562
|
-
}
|
|
1563
|
-
get m01() {
|
|
1564
|
-
return this._raw[1];
|
|
1565
|
-
}
|
|
1566
|
-
set m01(val) {
|
|
1567
|
-
this._raw[1] = val;
|
|
1568
|
-
}
|
|
1569
|
-
get m02() {
|
|
1570
|
-
return this._raw[2];
|
|
1571
|
-
}
|
|
1572
|
-
set m02(val) {
|
|
1573
|
-
this._raw[2] = val;
|
|
1574
|
-
}
|
|
1575
|
-
get m10() {
|
|
1576
|
-
return this._raw[3];
|
|
1577
|
-
}
|
|
1578
|
-
set m10(val) {
|
|
1579
|
-
this._raw[3] = val;
|
|
1580
|
-
}
|
|
1581
|
-
get m11() {
|
|
1582
|
-
return this._raw[4];
|
|
1583
|
-
}
|
|
1584
|
-
set m11(val) {
|
|
1585
|
-
this._raw[4] = val;
|
|
1586
|
-
}
|
|
1587
|
-
get m12() {
|
|
1588
|
-
return this._raw[5];
|
|
1589
|
-
}
|
|
1590
|
-
set m12(val) {
|
|
1591
|
-
this._raw[5] = val;
|
|
1592
|
-
}
|
|
1593
|
-
get m20() {
|
|
1594
|
-
return this._raw[6];
|
|
1595
|
-
}
|
|
1596
|
-
set m20(val) {
|
|
1597
|
-
this._raw[6] = val;
|
|
1598
|
-
}
|
|
1599
|
-
get m21() {
|
|
1600
|
-
return this._raw[7];
|
|
1601
|
-
}
|
|
1602
|
-
set m21(val) {
|
|
1603
|
-
this._raw[7] = val;
|
|
1604
|
-
}
|
|
1605
|
-
get m22() {
|
|
1606
|
-
return this._raw[8];
|
|
1607
|
-
}
|
|
1608
|
-
set m22(val) {
|
|
1609
|
-
this._raw[8] = val;
|
|
1610
|
-
}
|
|
1611
|
-
static resolve(a) {
|
|
1612
|
-
const value = this.cast(a);
|
|
1613
|
-
if (typeof value != "undefined")
|
|
1614
|
-
return value;
|
|
1615
|
-
throw new ResolveError("Mat3", a);
|
|
1616
|
-
}
|
|
1617
|
-
static resolveArgs(args) {
|
|
1618
|
-
if (checkNumberArray(args, 9))
|
|
1619
|
-
return new this(args);
|
|
1620
|
-
return this.resolve(args[0]);
|
|
1621
|
-
}
|
|
1622
|
-
static cast(a) {
|
|
1623
|
-
if (a == null || typeof a == "undefined")
|
|
1624
|
-
return void 0;
|
|
1625
|
-
if (checkNumberArray(a, 9)) {
|
|
1626
|
-
return new this(a);
|
|
1627
|
-
}
|
|
1628
|
-
if (checkArray(a, void 0, 3)) {
|
|
1629
|
-
const row0 = a[0], row1 = a[1], row2 = a[2];
|
|
1630
|
-
if (checkNumberArray(row0, 3) && checkNumberArray(row1, 3) && checkNumberArray(row2, 3))
|
|
1631
|
-
return new this([
|
|
1632
|
-
row0[0],
|
|
1633
|
-
row0[1],
|
|
1634
|
-
row0[2],
|
|
1635
|
-
row1[0],
|
|
1636
|
-
row1[1],
|
|
1637
|
-
row1[2],
|
|
1638
|
-
row2[0],
|
|
1639
|
-
row2[1],
|
|
1640
|
-
row2[2]
|
|
1641
|
-
]);
|
|
1642
|
-
}
|
|
1643
|
-
if (checkString(a)) {
|
|
1644
|
-
const parts = a.split(",");
|
|
1645
|
-
if (checkStringArray(parts, 9))
|
|
1646
|
-
return this.cast(parts.map((i) => parseFloat(i)));
|
|
1647
|
-
}
|
|
1648
|
-
if (hasProperty(a, "toMat3", "function"))
|
|
1649
|
-
return this.cast(a.toMat3());
|
|
1650
|
-
if (hasProperty(a, "m00", "number") && hasProperty(a, "m01", "number") && hasProperty(a, "m02", "number") && hasProperty(a, "m10", "number") && hasProperty(a, "m11", "number") && hasProperty(a, "m12", "number") && hasProperty(a, "m20", "number") && hasProperty(a, "m21", "number") && hasProperty(a, "m22", "number"))
|
|
1651
|
-
return new this([
|
|
1652
|
-
a.m00,
|
|
1653
|
-
a.m01,
|
|
1654
|
-
a.m02,
|
|
1655
|
-
a.m10,
|
|
1656
|
-
a.m11,
|
|
1657
|
-
a.m12,
|
|
1658
|
-
a.m20,
|
|
1659
|
-
a.m21,
|
|
1660
|
-
a.m22
|
|
1661
|
-
]);
|
|
1662
|
-
if (checkNumber(a)) {
|
|
1663
|
-
return new this([a, a, a, a, a, a, a, a, a]);
|
|
1664
|
-
}
|
|
1665
|
-
return void 0;
|
|
1666
|
-
}
|
|
1667
|
-
static is(a) {
|
|
1668
|
-
return typeof this.cast(a) != "undefined";
|
|
1669
|
-
}
|
|
1670
|
-
static projection(width, height) {
|
|
1671
|
-
return new this([
|
|
1672
|
-
2 / width,
|
|
1673
|
-
0,
|
|
1674
|
-
0,
|
|
1675
|
-
0,
|
|
1676
|
-
-2 / height,
|
|
1677
|
-
0,
|
|
1678
|
-
-1,
|
|
1679
|
-
1,
|
|
1680
|
-
1
|
|
1681
|
-
]);
|
|
1682
|
-
}
|
|
1683
|
-
constructor(init = [1, 0, 0, 0, 1, 0, 0, 0, 1]) {
|
|
1684
|
-
if (!checkNumberArray(init, 9))
|
|
1685
|
-
throw new TypeError("expected a number array with 9 elements");
|
|
1686
|
-
this._raw = init;
|
|
1687
|
-
}
|
|
1688
|
-
toArray() {
|
|
1689
|
-
return [
|
|
1690
|
-
this.m00,
|
|
1691
|
-
this.m01,
|
|
1692
|
-
this.m02,
|
|
1693
|
-
this.m10,
|
|
1694
|
-
this.m11,
|
|
1695
|
-
this.m12,
|
|
1696
|
-
this.m20,
|
|
1697
|
-
this.m21,
|
|
1698
|
-
this.m22
|
|
1699
|
-
];
|
|
1700
|
-
}
|
|
1701
|
-
toNestetArray() {
|
|
1702
|
-
return [
|
|
1703
|
-
[this.m00, this.m01, this.m02],
|
|
1704
|
-
[this.m10, this.m11, this.m12],
|
|
1705
|
-
[this.m20, this.m21, this.m22]
|
|
1706
|
-
];
|
|
1707
|
-
}
|
|
1708
|
-
toJSON() {
|
|
1709
|
-
return {
|
|
1710
|
-
m00: this.m00,
|
|
1711
|
-
m01: this.m01,
|
|
1712
|
-
m02: this.m02,
|
|
1713
|
-
m10: this.m10,
|
|
1714
|
-
m11: this.m11,
|
|
1715
|
-
m12: this.m12,
|
|
1716
|
-
m20: this.m20,
|
|
1717
|
-
m21: this.m21,
|
|
1718
|
-
m22: this.m22
|
|
1719
|
-
};
|
|
1720
|
-
}
|
|
1721
|
-
toString() {
|
|
1722
|
-
return `${this.m00},${this.m01},${this.m02},${this.m10},${this.m11},${this.m12},${this.m20},${this.m21},${this.m22}`;
|
|
1723
|
-
}
|
|
1724
|
-
get [Symbol.toStringTag]() {
|
|
1725
|
-
return "Mat3";
|
|
1726
|
-
}
|
|
1727
|
-
[NodeJSCustomInspect]() {
|
|
1728
|
-
return `Mat3 <${this.toString()}>`;
|
|
1729
|
-
}
|
|
1730
|
-
clone() {
|
|
1731
|
-
return new _Mat3([
|
|
1732
|
-
this.m00,
|
|
1733
|
-
this.m01,
|
|
1734
|
-
this.m02,
|
|
1735
|
-
this.m10,
|
|
1736
|
-
this.m11,
|
|
1737
|
-
this.m12,
|
|
1738
|
-
this.m20,
|
|
1739
|
-
this.m21,
|
|
1740
|
-
this.m22
|
|
1741
|
-
]);
|
|
1742
|
-
}
|
|
1743
|
-
equals(...args) {
|
|
1744
|
-
const m = _Mat3.resolveArgs(args);
|
|
1745
|
-
for (let index = 0; index < this._raw.length; index++)
|
|
1746
|
-
if (this._raw[index] != m._raw[index])
|
|
1747
|
-
return false;
|
|
1748
|
-
return true;
|
|
1749
|
-
}
|
|
1750
|
-
add(...args) {
|
|
1751
|
-
const b = _Mat3.resolveArgs(args);
|
|
1752
|
-
const m = new _Mat3();
|
|
1753
|
-
for (let index = 0; index < this._raw.length; index++)
|
|
1754
|
-
m._raw[index] = this._raw[index] + b._raw[index];
|
|
1755
|
-
return m;
|
|
1756
|
-
}
|
|
1757
|
-
subtract(...args) {
|
|
1758
|
-
const b = _Mat3.resolveArgs(args);
|
|
1759
|
-
const m = new _Mat3();
|
|
1760
|
-
for (let index = 0; index < this._raw.length; index++)
|
|
1761
|
-
m._raw[index] = this._raw[index] - b._raw[index];
|
|
1762
|
-
return m;
|
|
1763
|
-
}
|
|
1764
|
-
multiply(...args) {
|
|
1765
|
-
if (checkNumberArray(args, 1))
|
|
1766
|
-
return new _Mat3([
|
|
1767
|
-
this.m00 * args[0],
|
|
1768
|
-
this.m01 * args[0],
|
|
1769
|
-
this.m02 * args[0],
|
|
1770
|
-
this.m10 * args[0],
|
|
1771
|
-
this.m11 * args[0],
|
|
1772
|
-
this.m12 * args[0],
|
|
1773
|
-
this.m20 * args[0],
|
|
1774
|
-
this.m21 * args[0],
|
|
1775
|
-
this.m22 * args[0]
|
|
1776
|
-
]);
|
|
1777
|
-
const b = _Mat3.resolveArgs(args);
|
|
1778
|
-
return new _Mat3([
|
|
1779
|
-
b.m00 * this.m00 + b.m01 * this.m10 + b.m02 * this.m20,
|
|
1780
|
-
b.m00 * this.m01 + b.m01 * this.m11 + b.m02 * this.m21,
|
|
1781
|
-
b.m00 * this.m02 + b.m01 * this.m12 + b.m02 * this.m22,
|
|
1782
|
-
b.m10 * this.m00 + b.m11 * this.m10 + b.m12 * this.m20,
|
|
1783
|
-
b.m10 * this.m01 + b.m11 * this.m11 + b.m12 * this.m21,
|
|
1784
|
-
b.m10 * this.m02 + b.m11 * this.m12 + b.m12 * this.m22,
|
|
1785
|
-
b.m20 * this.m00 + b.m21 * this.m10 + b.m22 * this.m20,
|
|
1786
|
-
b.m20 * this.m01 + b.m21 * this.m11 + b.m22 * this.m21,
|
|
1787
|
-
b.m20 * this.m02 + b.m21 * this.m12 + b.m22 * this.m22
|
|
1788
|
-
]);
|
|
1789
|
-
}
|
|
1790
|
-
translate(...args) {
|
|
1791
|
-
const vec = Vec2.resolveArgs(args);
|
|
1792
|
-
return this.multiply([
|
|
1793
|
-
1,
|
|
1794
|
-
0,
|
|
1795
|
-
0,
|
|
1796
|
-
0,
|
|
1797
|
-
1,
|
|
1798
|
-
0,
|
|
1799
|
-
vec.x,
|
|
1800
|
-
vec.y,
|
|
1801
|
-
1
|
|
1802
|
-
]);
|
|
1803
|
-
}
|
|
1804
|
-
rotate(angle) {
|
|
1805
|
-
const c = Math.cos(angle);
|
|
1806
|
-
const s = Math.sin(angle);
|
|
1807
|
-
return this.multiply([
|
|
1808
|
-
c,
|
|
1809
|
-
-s,
|
|
1810
|
-
0,
|
|
1811
|
-
s,
|
|
1812
|
-
c,
|
|
1813
|
-
0,
|
|
1814
|
-
0,
|
|
1815
|
-
0,
|
|
1816
|
-
1
|
|
1817
|
-
]);
|
|
1818
|
-
}
|
|
1819
|
-
scale(...args) {
|
|
1820
|
-
const vec = Vec2.resolve(args);
|
|
1821
|
-
return this.multiply([
|
|
1822
|
-
vec.x,
|
|
1823
|
-
0,
|
|
1824
|
-
0,
|
|
1825
|
-
0,
|
|
1826
|
-
vec.y,
|
|
1827
|
-
0,
|
|
1828
|
-
0,
|
|
1829
|
-
0,
|
|
1830
|
-
1
|
|
1831
|
-
]);
|
|
1832
|
-
}
|
|
1833
|
-
determinant() {
|
|
1834
|
-
return this.m00 * this.m11 * this.m22 - this.m21 * this.m12 - this.m01 * this.m10 * this.m22 - this.m12 * this.m20 + this.m02 * this.m10 * this.m21 - this.m11 * this.m20;
|
|
1835
|
-
}
|
|
1836
|
-
inverse() {
|
|
1837
|
-
const det = this.determinant();
|
|
1838
|
-
return new _Mat3([
|
|
1839
|
-
(this.m11 * this.m22 - this.m21 * this.m12) * det,
|
|
1840
|
-
(this.m02 * this.m21 - this.m01 * this.m22) * det,
|
|
1841
|
-
(this.m01 * this.m12 - this.m02 * this.m11) * det,
|
|
1842
|
-
(this.m12 * this.m20 - this.m10 * this.m22) * det,
|
|
1843
|
-
(this.m00 * this.m22 - this.m02 * this.m20) * det,
|
|
1844
|
-
(this.m10 * this.m02 - this.m00 * this.m12) * det,
|
|
1845
|
-
(this.m10 * this.m21 - this.m20 * this.m11) * det,
|
|
1846
|
-
(this.m20 * this.m01 - this.m00 * this.m21) * det,
|
|
1847
|
-
(this.m00 * this.m11 - this.m10 * this.m01) * det
|
|
1848
|
-
]);
|
|
1849
|
-
}
|
|
1850
|
-
toMat4() {
|
|
1851
|
-
return [
|
|
1852
|
-
this.m00,
|
|
1853
|
-
this.m01,
|
|
1854
|
-
this.m02,
|
|
1855
|
-
0,
|
|
1856
|
-
this.m10,
|
|
1857
|
-
this.m11,
|
|
1858
|
-
this.m12,
|
|
1859
|
-
0,
|
|
1860
|
-
this.m20,
|
|
1861
|
-
this.m20,
|
|
1862
|
-
this.m22,
|
|
1863
|
-
0,
|
|
1864
|
-
0,
|
|
1865
|
-
0,
|
|
1866
|
-
0,
|
|
1867
|
-
1
|
|
1868
|
-
];
|
|
1869
|
-
}
|
|
1870
|
-
};
|
|
1871
|
-
|
|
1872
|
-
// source/matrices/mat4.ts
|
|
1873
|
-
var Mat4 = class _Mat4 {
|
|
1874
|
-
_raw;
|
|
1875
|
-
get m00() {
|
|
1876
|
-
return this._raw[0];
|
|
1877
|
-
}
|
|
1878
|
-
set m00(val) {
|
|
1879
|
-
this._raw[0] = val;
|
|
1880
|
-
}
|
|
1881
|
-
get m01() {
|
|
1882
|
-
return this._raw[1];
|
|
1883
|
-
}
|
|
1884
|
-
set m01(val) {
|
|
1885
|
-
this._raw[1] = val;
|
|
1886
|
-
}
|
|
1887
|
-
get m02() {
|
|
1888
|
-
return this._raw[2];
|
|
1889
|
-
}
|
|
1890
|
-
set m02(val) {
|
|
1891
|
-
this._raw[2] = val;
|
|
1892
|
-
}
|
|
1893
|
-
get m03() {
|
|
1894
|
-
return this._raw[3];
|
|
1895
|
-
}
|
|
1896
|
-
set m03(val) {
|
|
1897
|
-
this._raw[3] = val;
|
|
1898
|
-
}
|
|
1899
|
-
get m10() {
|
|
1900
|
-
return this._raw[4];
|
|
1901
|
-
}
|
|
1902
|
-
set m10(val) {
|
|
1903
|
-
this._raw[4] = val;
|
|
1904
|
-
}
|
|
1905
|
-
get m11() {
|
|
1906
|
-
return this._raw[5];
|
|
1907
|
-
}
|
|
1908
|
-
set m11(val) {
|
|
1909
|
-
this._raw[5] = val;
|
|
1910
|
-
}
|
|
1911
|
-
get m12() {
|
|
1912
|
-
return this._raw[6];
|
|
1913
|
-
}
|
|
1914
|
-
set m12(val) {
|
|
1915
|
-
this._raw[6] = val;
|
|
1916
|
-
}
|
|
1917
|
-
get m13() {
|
|
1918
|
-
return this._raw[7];
|
|
1919
|
-
}
|
|
1920
|
-
set m13(val) {
|
|
1921
|
-
this._raw[7] = val;
|
|
1922
|
-
}
|
|
1923
|
-
get m20() {
|
|
1924
|
-
return this._raw[8];
|
|
1925
|
-
}
|
|
1926
|
-
set m20(val) {
|
|
1927
|
-
this._raw[8] = val;
|
|
1928
|
-
}
|
|
1929
|
-
get m21() {
|
|
1930
|
-
return this._raw[9];
|
|
1931
|
-
}
|
|
1932
|
-
set m21(val) {
|
|
1933
|
-
this._raw[9] = val;
|
|
1934
|
-
}
|
|
1935
|
-
get m22() {
|
|
1936
|
-
return this._raw[10];
|
|
1937
|
-
}
|
|
1938
|
-
set m22(val) {
|
|
1939
|
-
this._raw[10] = val;
|
|
1940
|
-
}
|
|
1941
|
-
get m23() {
|
|
1942
|
-
return this._raw[11];
|
|
1943
|
-
}
|
|
1944
|
-
set m23(val) {
|
|
1945
|
-
this._raw[11] = val;
|
|
1946
|
-
}
|
|
1947
|
-
get m30() {
|
|
1948
|
-
return this._raw[12];
|
|
1949
|
-
}
|
|
1950
|
-
set m30(val) {
|
|
1951
|
-
this._raw[12] = val;
|
|
1952
|
-
}
|
|
1953
|
-
get m31() {
|
|
1954
|
-
return this._raw[13];
|
|
1955
|
-
}
|
|
1956
|
-
set m31(val) {
|
|
1957
|
-
this._raw[13] = val;
|
|
1958
|
-
}
|
|
1959
|
-
get m32() {
|
|
1960
|
-
return this._raw[14];
|
|
1961
|
-
}
|
|
1962
|
-
set m32(val) {
|
|
1963
|
-
this._raw[14] = val;
|
|
1964
|
-
}
|
|
1965
|
-
get m33() {
|
|
1966
|
-
return this._raw[15];
|
|
1967
|
-
}
|
|
1968
|
-
set m33(val) {
|
|
1969
|
-
this._raw[15] = val;
|
|
1970
|
-
}
|
|
1971
|
-
static resolve(a) {
|
|
1972
|
-
const value = this.cast(a);
|
|
1973
|
-
if (typeof value != "undefined")
|
|
1974
|
-
return value;
|
|
1975
|
-
throw new ResolveError("Mat4", a);
|
|
1976
|
-
}
|
|
1977
|
-
static resolveArgs(args) {
|
|
1978
|
-
if (checkNumberArray(args, 16))
|
|
1979
|
-
return new this(args);
|
|
1980
|
-
return this.resolve(args[0]);
|
|
1981
|
-
}
|
|
1982
|
-
static cast(a) {
|
|
1983
|
-
if (a == null || typeof a == "undefined")
|
|
1984
|
-
return void 0;
|
|
1985
|
-
if (checkNumberArray(a, 16)) {
|
|
1986
|
-
return new this(a);
|
|
1987
|
-
}
|
|
1988
|
-
if (checkArray(a, void 0, 4)) {
|
|
1989
|
-
const row0 = a[0], row1 = a[1], row2 = a[2], row3 = a[3];
|
|
1990
|
-
if (checkNumberArray(row0, 4) && checkNumberArray(row1, 4) && checkNumberArray(row2, 4) && checkNumberArray(row3, 4))
|
|
1991
|
-
return new this([
|
|
1992
|
-
row0[0],
|
|
1993
|
-
row0[1],
|
|
1994
|
-
row0[2],
|
|
1995
|
-
row0[3],
|
|
1996
|
-
row1[0],
|
|
1997
|
-
row1[1],
|
|
1998
|
-
row1[2],
|
|
1999
|
-
row1[3],
|
|
2000
|
-
row2[0],
|
|
2001
|
-
row2[1],
|
|
2002
|
-
row2[2],
|
|
2003
|
-
row2[3],
|
|
2004
|
-
row3[0],
|
|
2005
|
-
row3[1],
|
|
2006
|
-
row3[2],
|
|
2007
|
-
row3[3]
|
|
2008
|
-
]);
|
|
2009
|
-
}
|
|
2010
|
-
if (checkString(a)) {
|
|
2011
|
-
const parts = a.split(",");
|
|
2012
|
-
if (checkStringArray(parts, 16))
|
|
2013
|
-
return this.cast(parts.map((i) => parseFloat(i)));
|
|
2014
|
-
}
|
|
2015
|
-
if (hasProperty(a, "toMat4", "function"))
|
|
2016
|
-
return this.cast(a.toMat4());
|
|
2017
|
-
if (hasProperty(a, "m00", "number") && hasProperty(a, "m01", "number") && hasProperty(a, "m02", "number") && hasProperty(a, "m03", "number") && hasProperty(a, "m10", "number") && hasProperty(a, "m11", "number") && hasProperty(a, "m12", "number") && hasProperty(a, "m13", "number") && hasProperty(a, "m20", "number") && hasProperty(a, "m21", "number") && hasProperty(a, "m22", "number") && hasProperty(a, "m23", "number") && hasProperty(a, "m30", "number") && hasProperty(a, "m31", "number") && hasProperty(a, "m32", "number") && hasProperty(a, "m33", "number"))
|
|
2018
|
-
return new this([
|
|
2019
|
-
a.m00,
|
|
2020
|
-
a.m01,
|
|
2021
|
-
a.m02,
|
|
2022
|
-
a.m03,
|
|
2023
|
-
a.m10,
|
|
2024
|
-
a.m11,
|
|
2025
|
-
a.m12,
|
|
2026
|
-
a.m13,
|
|
2027
|
-
a.m20,
|
|
2028
|
-
a.m21,
|
|
2029
|
-
a.m22,
|
|
2030
|
-
a.m23,
|
|
2031
|
-
a.m30,
|
|
2032
|
-
a.m31,
|
|
2033
|
-
a.m32,
|
|
2034
|
-
a.m33
|
|
2035
|
-
]);
|
|
2036
|
-
if (checkNumber(a)) {
|
|
2037
|
-
return new this([a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a]);
|
|
2038
|
-
}
|
|
2039
|
-
return void 0;
|
|
2040
|
-
}
|
|
2041
|
-
static is(a) {
|
|
2042
|
-
return typeof this.cast(a) != "undefined";
|
|
2043
|
-
}
|
|
2044
|
-
static orthographic(...args) {
|
|
2045
|
-
const bbox = checkNumberArray(args, 6) ? new BoundingBox(args[0], args[1], args[2], args[3]) : BoundingBox.resolve(args[0]);
|
|
2046
|
-
const near = checkNumberArray(args, 6) ? args[4] : args[1];
|
|
2047
|
-
const far = checkNumberArray(args, 6) ? args[5] : args[2];
|
|
2048
|
-
return new this([
|
|
2049
|
-
2 / (bbox.right - bbox.left),
|
|
2050
|
-
0,
|
|
2051
|
-
0,
|
|
2052
|
-
0,
|
|
2053
|
-
0,
|
|
2054
|
-
2 / (bbox.top - bbox.bottom),
|
|
2055
|
-
0,
|
|
2056
|
-
0,
|
|
2057
|
-
0,
|
|
2058
|
-
0,
|
|
2059
|
-
2 / (near - far),
|
|
2060
|
-
0,
|
|
2061
|
-
(bbox.left + bbox.right) / (bbox.left - bbox.right),
|
|
2062
|
-
(bbox.bottom + bbox.top) / (bbox.bottom - bbox.top),
|
|
2063
|
-
(near + far) / (near - far),
|
|
2064
|
-
1
|
|
2065
|
-
]);
|
|
2066
|
-
}
|
|
2067
|
-
static perspective(fov, aspect, near, far) {
|
|
2068
|
-
const f = Math.tan(Math.PI * 0.5 - 0.5 * fov);
|
|
2069
|
-
const rangeInv = 1 / (near - far);
|
|
2070
|
-
return new this([
|
|
2071
|
-
f / aspect,
|
|
2072
|
-
0,
|
|
2073
|
-
0,
|
|
2074
|
-
0,
|
|
2075
|
-
0,
|
|
2076
|
-
f,
|
|
2077
|
-
0,
|
|
2078
|
-
0,
|
|
2079
|
-
0,
|
|
2080
|
-
0,
|
|
2081
|
-
(near + far) * rangeInv,
|
|
2082
|
-
-1,
|
|
2083
|
-
0,
|
|
2084
|
-
0,
|
|
2085
|
-
near * far * rangeInv * 2,
|
|
2086
|
-
0
|
|
2087
|
-
]);
|
|
2088
|
-
}
|
|
2089
|
-
static pointAt(position, target, up) {
|
|
2090
|
-
const newForward = Vec3.resolve(target).subtract(position).normalize();
|
|
2091
|
-
const a = newForward.multiply(Vec3.resolve(up).dot(newForward));
|
|
2092
|
-
const newUp = Vec3.resolve(up).subtract(a).normalize();
|
|
2093
|
-
const newRight = newUp.cross(newForward);
|
|
2094
|
-
const pos = Vec3.resolve(position);
|
|
2095
|
-
return new this([
|
|
2096
|
-
newRight.x,
|
|
2097
|
-
newRight.y,
|
|
2098
|
-
newRight.z,
|
|
2099
|
-
0,
|
|
2100
|
-
newUp.x,
|
|
2101
|
-
newUp.y,
|
|
2102
|
-
newUp.z,
|
|
2103
|
-
0,
|
|
2104
|
-
newForward.x,
|
|
2105
|
-
newForward.y,
|
|
2106
|
-
newForward.z,
|
|
2107
|
-
0,
|
|
2108
|
-
pos.x,
|
|
2109
|
-
pos.y,
|
|
2110
|
-
pos.z,
|
|
2111
|
-
1
|
|
2112
|
-
]);
|
|
2113
|
-
}
|
|
2114
|
-
constructor(init = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) {
|
|
2115
|
-
if (!checkNumberArray(init, 16))
|
|
2116
|
-
throw new TypeError("expected a number array with 16 elements");
|
|
2117
|
-
this._raw = init;
|
|
2118
|
-
}
|
|
2119
|
-
toArray() {
|
|
2120
|
-
return [
|
|
2121
|
-
this.m00,
|
|
2122
|
-
this.m01,
|
|
2123
|
-
this.m02,
|
|
2124
|
-
this.m03,
|
|
2125
|
-
this.m10,
|
|
2126
|
-
this.m11,
|
|
2127
|
-
this.m12,
|
|
2128
|
-
this.m13,
|
|
2129
|
-
this.m20,
|
|
2130
|
-
this.m21,
|
|
2131
|
-
this.m22,
|
|
2132
|
-
this.m23,
|
|
2133
|
-
this.m30,
|
|
2134
|
-
this.m31,
|
|
2135
|
-
this.m32,
|
|
2136
|
-
this.m33
|
|
2137
|
-
];
|
|
2138
|
-
}
|
|
2139
|
-
toNestetArray() {
|
|
2140
|
-
return [
|
|
2141
|
-
[this.m00, this.m01, this.m02, this.m03],
|
|
2142
|
-
[this.m10, this.m11, this.m12, this.m13],
|
|
2143
|
-
[this.m20, this.m21, this.m22, this.m23],
|
|
2144
|
-
[this.m30, this.m31, this.m32, this.m33]
|
|
2145
|
-
];
|
|
2146
|
-
}
|
|
2147
|
-
toJSON() {
|
|
2148
|
-
return {
|
|
2149
|
-
m00: this.m00,
|
|
2150
|
-
m01: this.m01,
|
|
2151
|
-
m02: this.m02,
|
|
2152
|
-
m03: this.m03,
|
|
2153
|
-
m10: this.m10,
|
|
2154
|
-
m11: this.m11,
|
|
2155
|
-
m12: this.m12,
|
|
2156
|
-
m13: this.m13,
|
|
2157
|
-
m20: this.m20,
|
|
2158
|
-
m21: this.m21,
|
|
2159
|
-
m22: this.m22,
|
|
2160
|
-
m23: this.m23,
|
|
2161
|
-
m30: this.m20,
|
|
2162
|
-
m31: this.m21,
|
|
2163
|
-
m32: this.m22,
|
|
2164
|
-
m33: this.m23
|
|
2165
|
-
};
|
|
2166
|
-
}
|
|
2167
|
-
toString() {
|
|
2168
|
-
return `${this.m00},${this.m01},${this.m02},${this.m03},${this.m10},${this.m11},${this.m12},${this.m13},${this.m20},${this.m21},${this.m22},${this.m23},${this.m30},${this.m31},${this.m32},${this.m33}`;
|
|
2169
|
-
}
|
|
2170
|
-
get [Symbol.toStringTag]() {
|
|
2171
|
-
return "Mat4";
|
|
2172
|
-
}
|
|
2173
|
-
[NodeJSCustomInspect]() {
|
|
2174
|
-
return `Mat4 <${this.toString()}>`;
|
|
2175
|
-
}
|
|
2176
|
-
clone() {
|
|
2177
|
-
return new _Mat4([
|
|
2178
|
-
this.m00,
|
|
2179
|
-
this.m01,
|
|
2180
|
-
this.m02,
|
|
2181
|
-
this.m03,
|
|
2182
|
-
this.m10,
|
|
2183
|
-
this.m11,
|
|
2184
|
-
this.m12,
|
|
2185
|
-
this.m13,
|
|
2186
|
-
this.m20,
|
|
2187
|
-
this.m21,
|
|
2188
|
-
this.m22,
|
|
2189
|
-
this.m23,
|
|
2190
|
-
this.m30,
|
|
2191
|
-
this.m31,
|
|
2192
|
-
this.m32,
|
|
2193
|
-
this.m33
|
|
2194
|
-
]);
|
|
2195
|
-
}
|
|
2196
|
-
equals(...args) {
|
|
2197
|
-
const m = _Mat4.resolveArgs(args);
|
|
2198
|
-
for (let index = 0; index < this._raw.length; index++)
|
|
2199
|
-
if (this._raw[index] != m._raw[index])
|
|
2200
|
-
return false;
|
|
2201
|
-
return true;
|
|
2202
|
-
}
|
|
2203
|
-
add(...args) {
|
|
2204
|
-
const b = _Mat4.resolveArgs(args);
|
|
2205
|
-
const m = new _Mat4();
|
|
2206
|
-
for (let index = 0; index < this._raw.length; index++)
|
|
2207
|
-
m._raw[index] = this._raw[index] + b._raw[index];
|
|
2208
|
-
return m;
|
|
2209
|
-
}
|
|
2210
|
-
subtract(...args) {
|
|
2211
|
-
const b = _Mat4.resolveArgs(args);
|
|
2212
|
-
const m = new _Mat4();
|
|
2213
|
-
for (let index = 0; index < this._raw.length; index++)
|
|
2214
|
-
m._raw[index] = this._raw[index] - b._raw[index];
|
|
2215
|
-
return m;
|
|
2216
|
-
}
|
|
2217
|
-
multiply(...args) {
|
|
2218
|
-
if (checkNumberArray(args, 1)) {
|
|
2219
|
-
const scalar = args[0];
|
|
2220
|
-
return new _Mat4([
|
|
2221
|
-
this.m00 * scalar,
|
|
2222
|
-
this.m01 * scalar,
|
|
2223
|
-
this.m02 * scalar,
|
|
2224
|
-
this.m03 * scalar,
|
|
2225
|
-
this.m10 * scalar,
|
|
2226
|
-
this.m11 * scalar,
|
|
2227
|
-
this.m12 * scalar,
|
|
2228
|
-
this.m13 * scalar,
|
|
2229
|
-
this.m20 * scalar,
|
|
2230
|
-
this.m21 * scalar,
|
|
2231
|
-
this.m22 * scalar,
|
|
2232
|
-
this.m23 * scalar,
|
|
2233
|
-
this.m30 * scalar,
|
|
2234
|
-
this.m31 * scalar,
|
|
2235
|
-
this.m32 * scalar,
|
|
2236
|
-
this.m33 * scalar
|
|
2237
|
-
]);
|
|
2238
|
-
}
|
|
2239
|
-
const vec = Vec3.cast(args[0]);
|
|
2240
|
-
if (vec !== void 0) {
|
|
2241
|
-
const result = new Vec3(
|
|
2242
|
-
vec.x * this.m00 + vec.y * this.m10 + vec.z * this.m20 + this.m30,
|
|
2243
|
-
vec.x * this.m01 + vec.y * this.m11 + vec.z * this.m21 + this.m31,
|
|
2244
|
-
vec.x * this.m02 + vec.y * this.m12 + vec.z * this.m22 + this.m32,
|
|
2245
|
-
vec.x * this.m03 + vec.y * this.m13 + vec.z * this.m23 + this.m33
|
|
2246
|
-
);
|
|
2247
|
-
if (result.w != 0)
|
|
2248
|
-
return result.divide(result.w);
|
|
2249
|
-
return result;
|
|
2250
|
-
}
|
|
2251
|
-
const mat = _Mat4.resolveArgs(args);
|
|
2252
|
-
return new _Mat4([
|
|
2253
|
-
mat.m00 * this.m00 + mat.m01 * this.m10 + mat.m02 * this.m20 + mat.m03 * this.m30,
|
|
2254
|
-
mat.m00 * this.m01 + mat.m01 * this.m11 + mat.m02 * this.m21 + mat.m03 * this.m31,
|
|
2255
|
-
mat.m00 * this.m02 + mat.m01 * this.m12 + mat.m02 * this.m22 + mat.m03 * this.m32,
|
|
2256
|
-
mat.m00 * this.m03 + mat.m01 * this.m13 + mat.m02 * this.m23 + mat.m03 * this.m33,
|
|
2257
|
-
mat.m10 * this.m00 + mat.m11 * this.m10 + mat.m12 * this.m20 + mat.m13 * this.m30,
|
|
2258
|
-
mat.m10 * this.m01 + mat.m11 * this.m11 + mat.m12 * this.m21 + mat.m13 * this.m31,
|
|
2259
|
-
mat.m10 * this.m02 + mat.m11 * this.m12 + mat.m12 * this.m22 + mat.m13 * this.m32,
|
|
2260
|
-
mat.m10 * this.m03 + mat.m11 * this.m13 + mat.m12 * this.m23 + mat.m13 * this.m33,
|
|
2261
|
-
mat.m20 * this.m00 + mat.m21 * this.m10 + mat.m22 * this.m20 + mat.m23 * this.m30,
|
|
2262
|
-
mat.m20 * this.m01 + mat.m21 * this.m11 + mat.m22 * this.m21 + mat.m23 * this.m31,
|
|
2263
|
-
mat.m20 * this.m02 + mat.m21 * this.m12 + mat.m22 * this.m22 + mat.m23 * this.m32,
|
|
2264
|
-
mat.m20 * this.m03 + mat.m21 * this.m13 + mat.m22 * this.m23 + mat.m23 * this.m33,
|
|
2265
|
-
mat.m30 * this.m00 + mat.m31 * this.m10 + mat.m32 * this.m20 + mat.m33 * this.m30,
|
|
2266
|
-
mat.m30 * this.m01 + mat.m31 * this.m11 + mat.m32 * this.m21 + mat.m33 * this.m31,
|
|
2267
|
-
mat.m30 * this.m02 + mat.m31 * this.m12 + mat.m32 * this.m22 + mat.m33 * this.m32,
|
|
2268
|
-
mat.m30 * this.m03 + mat.m31 * this.m13 + mat.m32 * this.m23 + mat.m33 * this.m33
|
|
2269
|
-
]);
|
|
2270
|
-
}
|
|
2271
|
-
translate(...args) {
|
|
2272
|
-
const vec = Vec3.resolveArgs(args);
|
|
2273
|
-
return this.multiply([
|
|
2274
|
-
1,
|
|
2275
|
-
0,
|
|
2276
|
-
0,
|
|
2277
|
-
0,
|
|
2278
|
-
0,
|
|
2279
|
-
1,
|
|
2280
|
-
0,
|
|
2281
|
-
0,
|
|
2282
|
-
0,
|
|
2283
|
-
0,
|
|
2284
|
-
1,
|
|
2285
|
-
0,
|
|
2286
|
-
vec.x,
|
|
2287
|
-
vec.y,
|
|
2288
|
-
vec.z,
|
|
2289
|
-
1
|
|
2290
|
-
]);
|
|
2291
|
-
}
|
|
2292
|
-
rotateX(angle) {
|
|
2293
|
-
const c = Math.cos(angle);
|
|
2294
|
-
const s = Math.sin(angle);
|
|
2295
|
-
return this.multiply([
|
|
2296
|
-
1,
|
|
2297
|
-
0,
|
|
2298
|
-
0,
|
|
2299
|
-
0,
|
|
2300
|
-
0,
|
|
2301
|
-
c,
|
|
2302
|
-
s,
|
|
2303
|
-
0,
|
|
2304
|
-
0,
|
|
2305
|
-
-s,
|
|
2306
|
-
c,
|
|
2307
|
-
0,
|
|
2308
|
-
0,
|
|
2309
|
-
0,
|
|
2310
|
-
0,
|
|
2311
|
-
1
|
|
2312
|
-
]);
|
|
2313
|
-
}
|
|
2314
|
-
rotateY(angle) {
|
|
2315
|
-
const c = Math.cos(angle);
|
|
2316
|
-
const s = Math.sin(angle);
|
|
2317
|
-
return this.multiply([
|
|
2318
|
-
c,
|
|
2319
|
-
0,
|
|
2320
|
-
-s,
|
|
2321
|
-
0,
|
|
2322
|
-
0,
|
|
2323
|
-
1,
|
|
2324
|
-
0,
|
|
2325
|
-
0,
|
|
2326
|
-
s,
|
|
2327
|
-
0,
|
|
2328
|
-
c,
|
|
2329
|
-
0,
|
|
2330
|
-
0,
|
|
2331
|
-
0,
|
|
2332
|
-
0,
|
|
2333
|
-
1
|
|
2334
|
-
]);
|
|
2335
|
-
}
|
|
2336
|
-
rotateZ(angle) {
|
|
2337
|
-
const c = Math.cos(angle);
|
|
2338
|
-
const s = Math.sin(angle);
|
|
2339
|
-
return this.multiply([
|
|
2340
|
-
c,
|
|
2341
|
-
s,
|
|
2342
|
-
0,
|
|
2343
|
-
0,
|
|
2344
|
-
-s,
|
|
2345
|
-
c,
|
|
2346
|
-
0,
|
|
2347
|
-
0,
|
|
2348
|
-
0,
|
|
2349
|
-
0,
|
|
2350
|
-
1,
|
|
2351
|
-
0,
|
|
2352
|
-
0,
|
|
2353
|
-
0,
|
|
2354
|
-
0,
|
|
2355
|
-
1
|
|
2356
|
-
]);
|
|
2357
|
-
}
|
|
2358
|
-
rotate(...args) {
|
|
2359
|
-
const vec = Vec3.resolveArgs(args);
|
|
2360
|
-
return this.rotateX(vec.x).rotateY(vec.y).rotateZ(vec.z);
|
|
2361
|
-
}
|
|
2362
|
-
scale(...args) {
|
|
2363
|
-
const vec = Vec3.resolveArgs(args);
|
|
2364
|
-
return this.multiply([
|
|
2365
|
-
vec.x,
|
|
2366
|
-
0,
|
|
2367
|
-
0,
|
|
2368
|
-
0,
|
|
2369
|
-
0,
|
|
2370
|
-
vec.y,
|
|
2371
|
-
0,
|
|
2372
|
-
0,
|
|
2373
|
-
0,
|
|
2374
|
-
0,
|
|
2375
|
-
vec.z,
|
|
2376
|
-
0,
|
|
2377
|
-
0,
|
|
2378
|
-
0,
|
|
2379
|
-
0,
|
|
2380
|
-
1
|
|
2381
|
-
]);
|
|
2382
|
-
}
|
|
2383
|
-
inverse() {
|
|
2384
|
-
return new _Mat4([
|
|
2385
|
-
this.m00,
|
|
2386
|
-
this.m10,
|
|
2387
|
-
this.m20,
|
|
2388
|
-
0,
|
|
2389
|
-
this.m01,
|
|
2390
|
-
this.m11,
|
|
2391
|
-
this.m21,
|
|
2392
|
-
0,
|
|
2393
|
-
this.m02,
|
|
2394
|
-
this.m12,
|
|
2395
|
-
this.m22,
|
|
2396
|
-
0,
|
|
2397
|
-
-(this.m30 * this.m00 + this.m31 * this.m10 + this.m32 * this.m20),
|
|
2398
|
-
-(this.m30 * this.m01 + this.m31 * this.m11 + this.m32 * this.m21),
|
|
2399
|
-
-(this.m30 * this.m02 + this.m31 * this.m12 + this.m32 * this.m22),
|
|
2400
|
-
1
|
|
2401
|
-
]);
|
|
2402
|
-
}
|
|
2403
|
-
toMat3() {
|
|
2404
|
-
return [
|
|
2405
|
-
this.m00,
|
|
2406
|
-
this.m01,
|
|
2407
|
-
this.m03,
|
|
2408
|
-
this.m10,
|
|
2409
|
-
this.m11,
|
|
2410
|
-
this.m13,
|
|
2411
|
-
this.m30,
|
|
2412
|
-
this.m31,
|
|
2413
|
-
this.m33
|
|
2414
|
-
];
|
|
2415
|
-
}
|
|
2416
|
-
};
|
|
2417
|
-
|
|
2418
|
-
// source/color.ts
|
|
2419
|
-
function __hex_to_array__(hex) {
|
|
2420
|
-
if (!checkHex(hex))
|
|
2421
|
-
return void 0;
|
|
2422
|
-
const part = getHexValue(hex);
|
|
2423
|
-
const red = parseInt(part.substring(0, 2), 16) / 255;
|
|
2424
|
-
const green = parseInt(part.substring(2, 4), 16) / 255;
|
|
2425
|
-
const blue = parseInt(part.substring(4, 6), 16) / 255;
|
|
2426
|
-
const alpha = part.length == 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1;
|
|
2427
|
-
return [red, green, blue, alpha];
|
|
2428
|
-
}
|
|
2429
|
-
function __number_to_rgb__(number) {
|
|
2430
|
-
const blue = number & 255;
|
|
2431
|
-
const green = (number & 65280) >>> 8;
|
|
2432
|
-
const red = (number & 16711680) >>> 16;
|
|
2433
|
-
return [red / 255, green / 255, blue / 255];
|
|
2434
|
-
}
|
|
2435
|
-
function __number_to_rgba__(number) {
|
|
2436
|
-
const alpha = number & 255;
|
|
2437
|
-
const blue = (number & 65280) >>> 8;
|
|
2438
|
-
const green = (number & 16711680) >>> 16;
|
|
2439
|
-
const red = (number & 4278190080) >>> 24;
|
|
2440
|
-
return [red / 255, green / 255, blue / 255, alpha / 255];
|
|
2441
|
-
}
|
|
2442
|
-
var __to_byte__ = (scale) => clamp(scale * 255 | 0, 0, 255);
|
|
2443
|
-
var RGBA = class _RGBA {
|
|
2444
|
-
_red;
|
|
2445
|
-
get red() {
|
|
2446
|
-
return this._red;
|
|
2447
|
-
}
|
|
2448
|
-
set red(val) {
|
|
2449
|
-
this._red = clamp(val, 0, 1);
|
|
2450
|
-
}
|
|
2451
|
-
_green;
|
|
2452
|
-
get green() {
|
|
2453
|
-
return this._green;
|
|
2454
|
-
}
|
|
2455
|
-
set green(val) {
|
|
2456
|
-
this._green = clamp(val, 0, 1);
|
|
2457
|
-
}
|
|
2458
|
-
_blue;
|
|
2459
|
-
get blue() {
|
|
2460
|
-
return this._blue;
|
|
2461
|
-
}
|
|
2462
|
-
set blue(val) {
|
|
2463
|
-
this._blue = clamp(val, 0, 1);
|
|
2464
|
-
}
|
|
2465
|
-
_alpha;
|
|
2466
|
-
get alpha() {
|
|
2467
|
-
return this._alpha;
|
|
2468
|
-
}
|
|
2469
|
-
set alpha(val) {
|
|
2470
|
-
this._alpha = clamp(val, 0, 1);
|
|
2471
|
-
}
|
|
2472
|
-
static resolve(a) {
|
|
2473
|
-
const value = this.cast(a);
|
|
2474
|
-
if (typeof value != "undefined")
|
|
2475
|
-
return value;
|
|
2476
|
-
throw new ResolveError("RGBAColor", a);
|
|
2477
|
-
}
|
|
2478
|
-
static resolveArgs(args) {
|
|
2479
|
-
if (checkNumberArray(args, 3) || checkNumberArray(args, 4))
|
|
2480
|
-
return new this(args[0], args[1], args[2], args[3]);
|
|
2481
|
-
return this.resolve(args[0]);
|
|
2482
|
-
}
|
|
2483
|
-
static cast(a) {
|
|
2484
|
-
if (a == null || typeof a == "undefined")
|
|
2485
|
-
return void 0;
|
|
2486
|
-
if (checkNumberArray(a, 3) || checkNumberArray(a, 4))
|
|
2487
|
-
return new this(a[0], a[1], a[2], a[3]);
|
|
2488
|
-
if (hasProperty(a, "toRGB", "function"))
|
|
2489
|
-
return this.cast(a.toRGB());
|
|
2490
|
-
if (hasProperty(a, "toRGBA", "function"))
|
|
2491
|
-
return this.cast(a.toRGBA());
|
|
2492
|
-
if (hasProperty(a, "red", "number") && hasProperty(a, "green", "number") && hasProperty(a, "blue", "number"))
|
|
2493
|
-
return new this(a.red, a.green, a.blue, hasProperty(a, "alpha", "number") ? a.alpha : void 0);
|
|
2494
|
-
if (checkNumber(a)) {
|
|
2495
|
-
const hex = a.toString(16);
|
|
2496
|
-
const convert = hex.length <= 6 ? __number_to_rgb__ : __number_to_rgba__;
|
|
2497
|
-
return this.cast(convert(a));
|
|
2498
|
-
}
|
|
2499
|
-
if (checkString(a)) {
|
|
2500
|
-
if (a.startsWith("rgb")) {
|
|
2501
|
-
const hasAlpha = a.startsWith("rgba");
|
|
2502
|
-
const offset = hasAlpha ? 5 : 4;
|
|
2503
|
-
const parts = a.substring(offset, a.indexOf(")", offset)).split(",");
|
|
2504
|
-
if (checkStringArray(parts, hasAlpha ? 4 : 3))
|
|
2505
|
-
return this.cast(parts.map((v) => parseInt(v) / 255));
|
|
2506
|
-
}
|
|
2507
|
-
return this.cast(__hex_to_array__(a));
|
|
2508
|
-
}
|
|
2509
|
-
return void 0;
|
|
2510
|
-
}
|
|
2511
|
-
static is(a) {
|
|
2512
|
-
return typeof this.cast(a) != "undefined";
|
|
2513
|
-
}
|
|
2514
|
-
constructor(red, green, blue, alpha = 1) {
|
|
2515
|
-
this._red = clamp(red, 0, 1);
|
|
2516
|
-
this._green = clamp(green, 0, 1);
|
|
2517
|
-
this._blue = clamp(blue, 0, 1);
|
|
2518
|
-
this._alpha = clamp(alpha, 0, 1);
|
|
2519
|
-
}
|
|
2520
|
-
toArray(withAlpha = this._alpha !== 1) {
|
|
2521
|
-
return withAlpha ? [this.red, this.green, this.blue, this.alpha] : [this.red, this.green, this.blue];
|
|
2522
|
-
}
|
|
2523
|
-
toJSON(withAlpha = this._alpha !== 1) {
|
|
2524
|
-
return withAlpha ? {
|
|
2525
|
-
red: this.red,
|
|
2526
|
-
green: this.green,
|
|
2527
|
-
blue: this.blue,
|
|
2528
|
-
alpha: this.alpha
|
|
2529
|
-
} : {
|
|
2530
|
-
red: this.red,
|
|
2531
|
-
green: this.green,
|
|
2532
|
-
blue: this.blue
|
|
2533
|
-
};
|
|
2534
|
-
}
|
|
2535
|
-
toString(withAlpha = this._alpha !== 1) {
|
|
2536
|
-
return withAlpha ? `rgba(${__to_byte__(this.red)},${__to_byte__(this.green)},${__to_byte__(this.blue)},${this.alpha})` : `rgb(${__to_byte__(this.red)},${__to_byte__(this.green)},${__to_byte__(this.blue)})`;
|
|
2537
|
-
}
|
|
2538
|
-
get [Symbol.toStringTag]() {
|
|
2539
|
-
return "RGBA";
|
|
2540
|
-
}
|
|
2541
|
-
[NodeJSCustomInspect]() {
|
|
2542
|
-
return `RGBA <${this.toString()}>`;
|
|
2543
|
-
}
|
|
2544
|
-
toVec2() {
|
|
2545
|
-
return [this.red, this.green, this.blue];
|
|
2546
|
-
}
|
|
2547
|
-
toVec3() {
|
|
2548
|
-
return [this.red, this.green, this.blue, this.alpha];
|
|
2549
|
-
}
|
|
2550
|
-
toHSL(withAlpha = this._alpha !== 1) {
|
|
2551
|
-
const red = this.red, green = this.green, blue = this.blue;
|
|
2552
|
-
const min = Math.min(red, green, blue), max = Math.max(red, green, blue);
|
|
2553
|
-
const luminace = (min + max) / 2;
|
|
2554
|
-
if (min == max)
|
|
2555
|
-
return new HSLA(0, 0, luminace, withAlpha ? this.alpha : void 0);
|
|
2556
|
-
const d = max - min;
|
|
2557
|
-
const saturation = luminace > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
2558
|
-
if (max == red)
|
|
2559
|
-
return new HSLA(((green - blue) / d + (green < blue ? 6 : 0)) / 6, saturation, luminace, withAlpha ? this.alpha : void 0);
|
|
2560
|
-
if (max == green)
|
|
2561
|
-
return new HSLA(((blue - red) / d + 2) / 6, saturation, luminace, withAlpha ? this.alpha : void 0);
|
|
2562
|
-
if (max == blue)
|
|
2563
|
-
return new HSLA(((red - green) / d + 4) / 6, saturation, luminace, withAlpha ? this.alpha : void 0);
|
|
2564
|
-
return new HSLA(0, saturation, luminace, withAlpha ? this.alpha : void 0);
|
|
2565
|
-
}
|
|
2566
|
-
toHSLA() {
|
|
2567
|
-
return this.toHSL(true);
|
|
2568
|
-
}
|
|
2569
|
-
invert(withAlpha = this._alpha !== 1) {
|
|
2570
|
-
return new _RGBA(
|
|
2571
|
-
1 - this.red,
|
|
2572
|
-
1 - this.green,
|
|
2573
|
-
1 - this.blue,
|
|
2574
|
-
withAlpha ? 1 - this.alpha : this.alpha
|
|
2575
|
-
);
|
|
2576
|
-
}
|
|
2577
|
-
};
|
|
2578
|
-
var HSLA = class _HSLA {
|
|
2579
|
-
_hue;
|
|
2580
|
-
get hue() {
|
|
2581
|
-
return this._hue;
|
|
2582
|
-
}
|
|
2583
|
-
set hue(val) {
|
|
2584
|
-
this._hue = clamp(val, 0, 1);
|
|
2585
|
-
}
|
|
2586
|
-
_saturation;
|
|
2587
|
-
get saturation() {
|
|
2588
|
-
return this._saturation;
|
|
2589
|
-
}
|
|
2590
|
-
set saturation(val) {
|
|
2591
|
-
this._saturation = clamp(val, 0, 1);
|
|
2592
|
-
}
|
|
2593
|
-
_luminace;
|
|
2594
|
-
get luminace() {
|
|
2595
|
-
return this._luminace;
|
|
2596
|
-
}
|
|
2597
|
-
set luminace(val) {
|
|
2598
|
-
this._luminace = clamp(val, 0, 1);
|
|
2599
|
-
}
|
|
2600
|
-
_alpha;
|
|
2601
|
-
get alpha() {
|
|
2602
|
-
return this._alpha;
|
|
2603
|
-
}
|
|
2604
|
-
set alpha(val) {
|
|
2605
|
-
this._alpha = clamp(val, 0, 1);
|
|
2606
|
-
}
|
|
2607
|
-
static resolve(a) {
|
|
2608
|
-
const value = this.cast(a);
|
|
2609
|
-
if (typeof value != "undefined")
|
|
2610
|
-
return value;
|
|
2611
|
-
throw new ResolveError("HSLColor", a);
|
|
2612
|
-
}
|
|
2613
|
-
static resolveArgs(args) {
|
|
2614
|
-
if (checkNumberArray(args, 3) || checkNumberArray(args, 4))
|
|
2615
|
-
return new this(args[0], args[1], args[2], args[3]);
|
|
2616
|
-
return this.resolve(args[0]);
|
|
2617
|
-
}
|
|
2618
|
-
static cast(a) {
|
|
2619
|
-
if (a == null || typeof a == "undefined")
|
|
2620
|
-
return void 0;
|
|
2621
|
-
if (checkNumberArray(a, 3) || checkNumberArray(a, 4))
|
|
2622
|
-
return new this(a[0], a[1], a[2], a[3]);
|
|
2623
|
-
if (hasProperty(a, "toHSL", "function"))
|
|
2624
|
-
return this.cast(a.toHSL());
|
|
2625
|
-
if (hasProperty(a, "toHSLA", "function"))
|
|
2626
|
-
return this.cast(a.toHSLA());
|
|
2627
|
-
if (hasProperty(a, "hue", "number") && hasProperty(a, "saturation", "number") && hasProperty(a, "luminace", "number"))
|
|
2628
|
-
return new this(a.hue, a.saturation, a.luminace, hasProperty(a, "alpha", "number") ? a.alpha : void 0);
|
|
2629
|
-
if (checkNumber(a)) {
|
|
2630
|
-
const hex = a.toString(16);
|
|
2631
|
-
const convert = hex.length <= 6 ? __number_to_rgb__ : __number_to_rgba__;
|
|
2632
|
-
return this.cast(convert(a));
|
|
2633
|
-
}
|
|
2634
|
-
if (checkString(a)) {
|
|
2635
|
-
if (a.startsWith("hsl")) {
|
|
2636
|
-
const hasAlpha = a.startsWith("hsla");
|
|
2637
|
-
const offset = hasAlpha ? 5 : 4;
|
|
2638
|
-
const parts = a.substring(offset, a.indexOf(")", offset)).split(",");
|
|
2639
|
-
if (checkStringArray(parts, hasAlpha ? 4 : 3))
|
|
2640
|
-
return this.cast(parts.map((v) => parseInt(v) / 255));
|
|
2641
|
-
}
|
|
2642
|
-
return this.cast(__hex_to_array__(a));
|
|
2643
|
-
}
|
|
2644
|
-
return void 0;
|
|
2645
|
-
}
|
|
2646
|
-
static is(a) {
|
|
2647
|
-
return typeof this.cast(a) != "undefined";
|
|
2648
|
-
}
|
|
2649
|
-
constructor(hue, saturation, luminace, alpha = 1) {
|
|
2650
|
-
if (!checkNumber(hue))
|
|
2651
|
-
throw new TypeError("expected number for hue");
|
|
2652
|
-
if (!checkNumber(saturation))
|
|
2653
|
-
throw new TypeError("expected number for saturation");
|
|
2654
|
-
if (!checkNumber(luminace))
|
|
2655
|
-
throw new TypeError("expected number for luminace");
|
|
2656
|
-
if (!checkNumber(alpha))
|
|
2657
|
-
throw new TypeError("expected number for alpha");
|
|
2658
|
-
this._hue = clamp(hue, 0, 1);
|
|
2659
|
-
this._saturation = clamp(saturation, 0, 1);
|
|
2660
|
-
this._luminace = clamp(luminace, 0, 1);
|
|
2661
|
-
this._alpha = clamp(alpha, 0, 1);
|
|
2662
|
-
}
|
|
2663
|
-
toArray(withAlpha = this._alpha !== 1) {
|
|
2664
|
-
return withAlpha ? [this.hue, this.saturation, this.luminace, this.alpha] : [this.hue, this.saturation, this.luminace];
|
|
2665
|
-
}
|
|
2666
|
-
toJSON(withAlpha = this._alpha !== 1) {
|
|
2667
|
-
return withAlpha ? {
|
|
2668
|
-
hue: this.hue,
|
|
2669
|
-
saturation: this.saturation,
|
|
2670
|
-
luminace: this.luminace,
|
|
2671
|
-
alpha: this.alpha
|
|
2672
|
-
} : {
|
|
2673
|
-
hue: this.hue,
|
|
2674
|
-
saturation: this.saturation,
|
|
2675
|
-
luminace: this.luminace
|
|
2676
|
-
};
|
|
2677
|
-
}
|
|
2678
|
-
toString(withAlpha = this._alpha !== 1) {
|
|
2679
|
-
return withAlpha ? `hsla(${__to_byte__(this.hue)},${__to_byte__(this.saturation)},${__to_byte__(this.luminace)},${this.alpha})` : `hsl(${__to_byte__(this.hue)},${__to_byte__(this.saturation)},${__to_byte__(this.luminace)})`;
|
|
2680
|
-
}
|
|
2681
|
-
get [Symbol.toStringTag]() {
|
|
2682
|
-
return "HSLA";
|
|
2683
|
-
}
|
|
2684
|
-
[NodeJSCustomInspect]() {
|
|
2685
|
-
return `HSLA <${this.toString()}>`;
|
|
2686
|
-
}
|
|
2687
|
-
toRGB(withAlpha = this._alpha !== 1) {
|
|
2688
|
-
if (this.saturation == 0)
|
|
2689
|
-
return new RGBA(this.luminace * 255, this.luminace * 255, this.luminace * 255, withAlpha ? this.alpha : void 0);
|
|
2690
|
-
const q = this.luminace < 0.5 ? this.luminace * (1 + this.saturation) : this.luminace + this.saturation - this.luminace * this.saturation;
|
|
2691
|
-
const p = 2 * this.luminace - q;
|
|
2692
|
-
function __hue_2_rgb__(t) {
|
|
2693
|
-
let _t = t;
|
|
2694
|
-
if (_t < 0)
|
|
2695
|
-
_t++;
|
|
2696
|
-
if (_t > 1)
|
|
2697
|
-
_t--;
|
|
2698
|
-
if (_t < 1 / 6)
|
|
2699
|
-
return p + (q - p) * 6 * _t;
|
|
2700
|
-
if (_t < 1 / 2)
|
|
2701
|
-
return q;
|
|
2702
|
-
if (_t < 2 / 3)
|
|
2703
|
-
return p + (q - p) * (2 / 3 - _t) * 6;
|
|
2704
|
-
return p;
|
|
2705
|
-
}
|
|
2706
|
-
return new RGBA(__hue_2_rgb__(this.hue + 1 / 3) * 255, __hue_2_rgb__(this.hue) * 255, __hue_2_rgb__(this.hue - 1 / 3) * 255, withAlpha ? this.alpha : void 0);
|
|
2707
|
-
}
|
|
2708
|
-
toRGBA() {
|
|
2709
|
-
return this.toRGB(true);
|
|
2710
|
-
}
|
|
2711
|
-
toVec2() {
|
|
2712
|
-
return [this.hue, this.saturation, this.luminace];
|
|
2713
|
-
}
|
|
2714
|
-
toVec3() {
|
|
2715
|
-
return [this.hue, this.saturation, this.luminace, this.alpha];
|
|
2716
|
-
}
|
|
2717
|
-
invert(withAlpha = this._alpha !== 1) {
|
|
2718
|
-
return new _HSLA(
|
|
2719
|
-
1 - this.hue,
|
|
2720
|
-
1 - this.saturation,
|
|
2721
|
-
1 - this.luminace,
|
|
2722
|
-
withAlpha ? 1 - this.alpha : this.alpha
|
|
2723
|
-
);
|
|
2724
|
-
}
|
|
2725
|
-
};
|
|
2726
|
-
var AnyColor;
|
|
2727
|
-
((AnyColor2) => {
|
|
2728
|
-
function cast(a, preferHSL = false) {
|
|
2729
|
-
const results = [];
|
|
2730
|
-
try {
|
|
2731
|
-
const rgba = RGBA.resolve(a);
|
|
2732
|
-
results.push(rgba);
|
|
2733
|
-
} catch (e) {
|
|
2734
|
-
}
|
|
2735
|
-
try {
|
|
2736
|
-
const hsla = HSLA.resolve(a);
|
|
2737
|
-
results.push(hsla);
|
|
2738
|
-
} catch (e) {
|
|
2739
|
-
}
|
|
2740
|
-
let offset = preferHSL ? 1 : 0;
|
|
2741
|
-
const firstItem = results[offset];
|
|
2742
|
-
if (firstItem)
|
|
2743
|
-
return firstItem;
|
|
2744
|
-
const secondItem = results[offset + 1];
|
|
2745
|
-
if (secondItem)
|
|
2746
|
-
return secondItem;
|
|
2747
|
-
return void 0;
|
|
2748
|
-
}
|
|
2749
|
-
AnyColor2.cast = cast;
|
|
2750
|
-
function resolve(a, preferHSL = false) {
|
|
2751
|
-
const value = cast(a, preferHSL);
|
|
2752
|
-
if (typeof value != "undefined")
|
|
2753
|
-
return value;
|
|
2754
|
-
throw new ResolveError("Color", a);
|
|
2755
|
-
}
|
|
2756
|
-
AnyColor2.resolve = resolve;
|
|
2757
|
-
function resolveArgs(args, preferHSL = false) {
|
|
2758
|
-
if (checkNumberArray(args, 3) || checkNumberArray(args, 4))
|
|
2759
|
-
return resolve(args, preferHSL);
|
|
2760
|
-
return resolve(args[0], preferHSL);
|
|
2761
|
-
}
|
|
2762
|
-
AnyColor2.resolveArgs = resolveArgs;
|
|
2763
|
-
})(AnyColor || (AnyColor = {}));
|
|
2764
|
-
|
|
2765
|
-
// source/quaternion.ts
|
|
2766
|
-
var Quaternion = class _Quaternion {
|
|
2767
|
-
w;
|
|
2768
|
-
x;
|
|
2769
|
-
y;
|
|
2770
|
-
z;
|
|
2771
|
-
static is(a) {
|
|
2772
|
-
return typeof this.cast(a) != "undefined";
|
|
2773
|
-
}
|
|
2774
|
-
static resolve(a) {
|
|
2775
|
-
const value = this.cast(a);
|
|
2776
|
-
if (typeof value != "undefined")
|
|
2777
|
-
return value;
|
|
2778
|
-
throw new ResolveError("Quaternion", a);
|
|
2779
|
-
}
|
|
2780
|
-
static resolveArgs(args) {
|
|
2781
|
-
if (checkNumberArray(args, 4))
|
|
2782
|
-
return new this(args[0], args[1], args[2], args[3]);
|
|
2783
|
-
return this.resolve(args[0]);
|
|
2784
|
-
}
|
|
2785
|
-
static cast(a) {
|
|
2786
|
-
if (a == null || typeof a == "undefined")
|
|
2787
|
-
return void 0;
|
|
2788
|
-
if (checkNumberArray(a, 4))
|
|
2789
|
-
return new this(a[0], a[1], a[2], a[3]);
|
|
2790
|
-
if (hasProperty(a, "toQuaternion", "function"))
|
|
2791
|
-
return this.cast(a.toQuaternion());
|
|
2792
|
-
if (hasProperty(a, "w", "number") && hasProperty(a, "x", "number") && hasProperty(a, "y", "number") && hasProperty(a, "z", "number"))
|
|
2793
|
-
return new this(a.w, a.x, a.y, a.z);
|
|
2794
|
-
if (checkString(a)) {
|
|
2795
|
-
const parts = a.replaceAll(" ", "").split("+");
|
|
2796
|
-
if (checkStringArray(parts, 4)) {
|
|
2797
|
-
const [sw, sxi, syj, szk] = parts;
|
|
2798
|
-
if (sxi.endsWith("i") && syj.endsWith("j") && szk.endsWith("k"))
|
|
2799
|
-
return this.cast([
|
|
2800
|
-
parseFloat(sw),
|
|
2801
|
-
parseFloat(sxi.substring(0, sxi.length - 1)),
|
|
2802
|
-
parseFloat(syj.substring(0, syj.length - 1)),
|
|
2803
|
-
parseFloat(szk.substring(0, szk.length - 1))
|
|
2804
|
-
]);
|
|
2805
|
-
}
|
|
2806
|
-
}
|
|
2807
|
-
return void 0;
|
|
2808
|
-
}
|
|
2809
|
-
static fromAxisAngle(...args) {
|
|
2810
|
-
const axis = checkNumberArray(args, 4) ? new Vec3(args[0], args[1], args[2]) : Vec3.resolve(args[0]);
|
|
2811
|
-
const angle = checkNumberArray(args, 4) ? args[3] : args[1];
|
|
2812
|
-
const vec = Vec3.resolve(axis);
|
|
2813
|
-
const hangle = angle * 0.5;
|
|
2814
|
-
const sin2 = Math.sin(hangle);
|
|
2815
|
-
const cos2 = Math.cos(hangle);
|
|
2816
|
-
const length = sin2 / Math.sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z);
|
|
2817
|
-
return new this(cos2, vec.x * length, vec.y * length, vec.z * length);
|
|
2818
|
-
}
|
|
2819
|
-
static fromEuler(...args) {
|
|
2820
|
-
const vec = Vec3.resolveArgs(args);
|
|
2821
|
-
const x2 = vec.x * 0.5, y2 = vec.y * 0.5, z2 = vec.z * 0.5;
|
|
2822
|
-
const cx = Math.cos(x2), cy = Math.cos(y2), cz = Math.cos(z2);
|
|
2823
|
-
const sx = Math.sin(x2), sy = Math.sin(y2), sz = Math.sin(z2);
|
|
2824
|
-
return new _Quaternion(
|
|
2825
|
-
cx * cy * cz - sx * sy * sz,
|
|
2826
|
-
sx * cy * cz - sy * sz * cx,
|
|
2827
|
-
sy * cx * cz - sx * sz * cy,
|
|
2828
|
-
sx * sy * cz + sz * cx * cy
|
|
2829
|
-
);
|
|
2830
|
-
}
|
|
2831
|
-
static get zero() {
|
|
2832
|
-
return new _Quaternion(0, 0, 0, 0);
|
|
2833
|
-
}
|
|
2834
|
-
constructor(w, x, y, z) {
|
|
2835
|
-
if (!checkNumber(w))
|
|
2836
|
-
throw new TypeError("expected number for w");
|
|
2837
|
-
if (!checkNumber(x))
|
|
2838
|
-
throw new TypeError("expected number for x");
|
|
2839
|
-
if (!checkNumber(y))
|
|
2840
|
-
throw new TypeError("expected number for x");
|
|
2841
|
-
if (!checkNumber(z))
|
|
2842
|
-
throw new TypeError("expected number for w");
|
|
2843
|
-
this.w = w;
|
|
2844
|
-
this.x = x;
|
|
2845
|
-
this.y = y;
|
|
2846
|
-
this.z = z;
|
|
2847
|
-
}
|
|
2848
|
-
toArray() {
|
|
2849
|
-
return [this.w, this.x, this.y, this.z];
|
|
2850
|
-
}
|
|
2851
|
-
toString() {
|
|
2852
|
-
return `${this.w} + ${this.x}i + ${this.y}j + ${this.z}k`;
|
|
2853
|
-
}
|
|
2854
|
-
get [Symbol.toStringTag]() {
|
|
2855
|
-
return "Quaternion";
|
|
2856
|
-
}
|
|
2857
|
-
[NodeJSCustomInspect]() {
|
|
2858
|
-
return `Quaternion <${this.toString()}>`;
|
|
2859
|
-
}
|
|
2860
|
-
toJSON() {
|
|
2861
|
-
return {
|
|
2862
|
-
w: this.w,
|
|
2863
|
-
x: this.x,
|
|
2864
|
-
y: this.y,
|
|
2865
|
-
z: this.z
|
|
2866
|
-
};
|
|
2867
|
-
}
|
|
2868
|
-
clone() {
|
|
2869
|
-
return new _Quaternion(this.w, this.x, this.y, this.z);
|
|
2870
|
-
}
|
|
2871
|
-
add(...args) {
|
|
2872
|
-
const quat = _Quaternion.resolveArgs(args);
|
|
2873
|
-
return new _Quaternion(
|
|
2874
|
-
this.w + quat.w,
|
|
2875
|
-
this.x + quat.x,
|
|
2876
|
-
this.y + quat.y,
|
|
2877
|
-
this.z + quat.z
|
|
2878
|
-
);
|
|
2879
|
-
}
|
|
2880
|
-
offset(...args) {
|
|
2881
|
-
const quat = _Quaternion.resolveArgs(args);
|
|
2882
|
-
this.w += quat.w;
|
|
2883
|
-
this.x += quat.x;
|
|
2884
|
-
this.y += quat.y;
|
|
2885
|
-
this.z += quat.z;
|
|
2886
|
-
return this;
|
|
2887
|
-
}
|
|
2888
|
-
subtract(...args) {
|
|
2889
|
-
const quat = _Quaternion.resolveArgs(args);
|
|
2890
|
-
return new _Quaternion(
|
|
2891
|
-
this.w - quat.w,
|
|
2892
|
-
this.x - quat.x,
|
|
2893
|
-
this.y - quat.y,
|
|
2894
|
-
this.z - quat.z
|
|
2895
|
-
);
|
|
2896
|
-
}
|
|
2897
|
-
negative() {
|
|
2898
|
-
return new _Quaternion(-this.w, -this.x, -this.y, -this.z);
|
|
2899
|
-
}
|
|
2900
|
-
length(sqrt = true) {
|
|
2901
|
-
const value = this.w * this.w + this.x * this.x + this.y * this.y + this.z * this.z;
|
|
2902
|
-
return sqrt ? Math.sqrt(value) : value;
|
|
2903
|
-
}
|
|
2904
|
-
normalize() {
|
|
2905
|
-
let length = this.length();
|
|
2906
|
-
if (length < EPSILON)
|
|
2907
|
-
return _Quaternion.zero;
|
|
2908
|
-
length = 1 / length;
|
|
2909
|
-
return new _Quaternion(this.w * length, this.x * length, this.y * length, this.z * length);
|
|
2910
|
-
}
|
|
2911
|
-
multiply(...args) {
|
|
2912
|
-
const quat = _Quaternion.resolveArgs(args);
|
|
2913
|
-
return new _Quaternion(
|
|
2914
|
-
this.w * quat.w - this.x * quat.x - this.y * quat.y - this.z * quat.z,
|
|
2915
|
-
this.w * quat.x + this.x * quat.w + this.y * quat.z - this.z * quat.y,
|
|
2916
|
-
this.w * quat.y + this.y * quat.w + this.z * quat.x - this.x * quat.z,
|
|
2917
|
-
this.w * quat.z + this.z * quat.w + this.x * quat.y - this.y * quat.x
|
|
2918
|
-
);
|
|
2919
|
-
}
|
|
2920
|
-
multiplyVector(...args) {
|
|
2921
|
-
const vec = Vec3.resolveArgs(args);
|
|
2922
|
-
const ix = this.w * vec.x + this.y * vec.y - this.z * vec.y;
|
|
2923
|
-
const iy = this.w * vec.y + this.z * vec.x - this.x * vec.z;
|
|
2924
|
-
const iz = this.w * vec.z + this.x * vec.y - this.y * vec.x;
|
|
2925
|
-
const iw = -this.w * vec.x - this.y * vec.y - this.z * vec.z;
|
|
2926
|
-
return new Vec3(
|
|
2927
|
-
ix * this.w + iw * -this.x + iy * -this.z - iz * -this.y,
|
|
2928
|
-
iy * this.w + iw * -this.y + iz * -this.x - ix * -this.z,
|
|
2929
|
-
iz * this.w + iw * -this.z + ix * -this.y - iy * -this.x
|
|
2930
|
-
);
|
|
2931
|
-
}
|
|
2932
|
-
scale(scalar) {
|
|
2933
|
-
return new _Quaternion(this.w * scalar, this.x * scalar, this.y * scalar, this.z * scalar);
|
|
2934
|
-
}
|
|
2935
|
-
dot(...args) {
|
|
2936
|
-
const quat = _Quaternion.resolveArgs(args);
|
|
2937
|
-
return this.w * quat.w + this.x * quat.x + this.y * quat.y + this.z * quat.z;
|
|
2938
|
-
}
|
|
2939
|
-
inverse() {
|
|
2940
|
-
let length = this.length(false);
|
|
2941
|
-
if (length == 0)
|
|
2942
|
-
return _Quaternion.zero;
|
|
2943
|
-
length = 1 / length;
|
|
2944
|
-
return new _Quaternion(this.w * length, -this.x * length, -this.y * length, -this.z * length);
|
|
2945
|
-
}
|
|
2946
|
-
divide(...args) {
|
|
2947
|
-
const quat = _Quaternion.resolveArgs(args);
|
|
2948
|
-
let length = quat.length(false);
|
|
2949
|
-
if (length == 0) return _Quaternion.zero;
|
|
2950
|
-
length = 1 / length;
|
|
2951
|
-
return new _Quaternion(
|
|
2952
|
-
(this.w * quat.w + this.x * quat.x + this.y * quat.y + this.z * quat.z) * length,
|
|
2953
|
-
(this.x * quat.w - this.w * quat.x - this.y * quat.z + this.z * quat.y) * length,
|
|
2954
|
-
(this.y * quat.w - this.w * quat.y - this.z * quat.x + this.x * quat.z) * length,
|
|
2955
|
-
(this.z * quat.w - this.w * quat.z - this.x * quat.y + this.y * quat.x) * length
|
|
2956
|
-
);
|
|
2957
|
-
}
|
|
2958
|
-
conjugate() {
|
|
2959
|
-
return new _Quaternion(this.w, -this.x, -this.y, -this.z);
|
|
2960
|
-
}
|
|
2961
|
-
exp() {
|
|
2962
|
-
const length = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
|
2963
|
-
const exp = Math.exp(this.w);
|
|
2964
|
-
const scale = exp * Math.sin(length) / length;
|
|
2965
|
-
if (length == 0)
|
|
2966
|
-
return new _Quaternion(exp, 0, 0, 0);
|
|
2967
|
-
return new _Quaternion(
|
|
2968
|
-
exp * Math.cos(length),
|
|
2969
|
-
this.x * scale,
|
|
2970
|
-
this.y * scale,
|
|
2971
|
-
this.z * scale
|
|
2972
|
-
);
|
|
2973
|
-
}
|
|
2974
|
-
log() {
|
|
2975
|
-
if (this.x == 0 && this.z == 0)
|
|
2976
|
-
return new _Quaternion(logHypot(this.w, this.x), Math.atan2(this.x, this.w), 0, 0);
|
|
2977
|
-
const length = this.length(false);
|
|
2978
|
-
const length2 = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
|
2979
|
-
const scale = Math.atan2(length2, this.w) / length;
|
|
2980
|
-
return new _Quaternion(Math.log(length) * 0.5, this.x * scale, this.y * scale, this.z * scale);
|
|
2981
|
-
}
|
|
2982
|
-
toVec3() {
|
|
2983
|
-
return [this.x, this.y, this.z, this.w];
|
|
2984
|
-
}
|
|
2985
|
-
toAxisAngle() {
|
|
2986
|
-
const sin2 = 1 - this.w * this.w;
|
|
2987
|
-
if (sin2 > EPSILON)
|
|
2988
|
-
return new Vec3(this.x, this.y, this.z, 0);
|
|
2989
|
-
const isin = 1 / Math.sqrt(sin2);
|
|
2990
|
-
const angle = 2 * Math.acos(this.w);
|
|
2991
|
-
return new Vec3(this.x * isin, this.y * isin, this.z * isin, angle);
|
|
2992
|
-
}
|
|
2993
|
-
toEuler() {
|
|
2994
|
-
function __asin__(t) {
|
|
2995
|
-
return t >= 1 ? Math.PI / 2 : t <= -1 ? -Math.PI / 2 : Math.asin(t);
|
|
2996
|
-
}
|
|
2997
|
-
return new Vec3(
|
|
2998
|
-
-Math.atan2(2 * (this.y * this.z - this.w * this.x), 1 - 2 * (this.x * this.x + this.y * this.y)),
|
|
2999
|
-
__asin__(2 * (this.x * this.z + this.w * this.y)),
|
|
3000
|
-
-Math.atan2(2 * (this.x * this.y - this.w * this.z), 1 - 2 * (this.y * this.y + this.z * this.z))
|
|
3001
|
-
);
|
|
3002
|
-
}
|
|
3003
|
-
toMat3() {
|
|
3004
|
-
return [
|
|
3005
|
-
1 - 2 * (this.y * this.y + this.z * this.z),
|
|
3006
|
-
2 * (this.x * this.y - this.w * this.z),
|
|
3007
|
-
2 * (this.x * this.z + this.w * this.y),
|
|
3008
|
-
2 * (this.x * this.y + this.w * this.z),
|
|
3009
|
-
1 - 2 * (this.x * this.x + this.z * this.z),
|
|
3010
|
-
2 * (this.y * this.z - this.w * this.x),
|
|
3011
|
-
2 * (this.x * this.z - this.w * this.y),
|
|
3012
|
-
2 * (this.y * this.z + this.w * this.x),
|
|
3013
|
-
1 - 2 * (this.x * this.x + this.y * this.y)
|
|
3014
|
-
];
|
|
3015
|
-
}
|
|
3016
|
-
toMat4() {
|
|
3017
|
-
return [
|
|
3018
|
-
1 - 2 * (this.y * this.y + this.z * this.z),
|
|
3019
|
-
2 * (this.x * this.y - this.w * this.z),
|
|
3020
|
-
2 * (this.x * this.z + this.w * this.y),
|
|
3021
|
-
0,
|
|
3022
|
-
2 * (this.x * this.y + this.w * this.z),
|
|
3023
|
-
1 - 2 * (this.x * this.x + this.z * this.z),
|
|
3024
|
-
2 * (this.y * this.z - this.w * this.x),
|
|
3025
|
-
0,
|
|
3026
|
-
2 * (this.x * this.z - this.w * this.y),
|
|
3027
|
-
2 * (this.y * this.z + this.w * this.x),
|
|
3028
|
-
1 - 2 * (this.x * this.x + this.y * this.y),
|
|
3029
|
-
0,
|
|
3030
|
-
0,
|
|
3031
|
-
0,
|
|
3032
|
-
0,
|
|
3033
|
-
1
|
|
3034
|
-
];
|
|
3035
|
-
}
|
|
3036
|
-
};
|
|
3037
|
-
|
|
3038
|
-
// source/transform.ts
|
|
3039
|
-
var Transform2D = class {
|
|
3040
|
-
constructor(position, rotation, scale, parent) {
|
|
3041
|
-
this.parent = parent;
|
|
3042
|
-
this.localPosition = Vec2.resolve(position);
|
|
3043
|
-
this.localRotation = rotation;
|
|
3044
|
-
this.localScale = Vec2.resolve(scale);
|
|
3045
|
-
}
|
|
3046
|
-
origin = Vec2.zero;
|
|
3047
|
-
localPosition;
|
|
3048
|
-
localRotation;
|
|
3049
|
-
get localRotationDegree() {
|
|
3050
|
-
return radianToDegree(this.localRotation);
|
|
3051
|
-
}
|
|
3052
|
-
set localRotationDegree(v) {
|
|
3053
|
-
this.localRotation = degreeToRadian(v);
|
|
3054
|
-
}
|
|
3055
|
-
localScale;
|
|
3056
|
-
get globalPosition() {
|
|
3057
|
-
let position = Vec2.zero;
|
|
3058
|
-
let transform = this;
|
|
3059
|
-
while (transform !== void 0) {
|
|
3060
|
-
position = position.add(transform.localPosition).add(transform.origin);
|
|
3061
|
-
transform = transform.parent;
|
|
3062
|
-
}
|
|
3063
|
-
return position;
|
|
3064
|
-
}
|
|
3065
|
-
get globalRotation() {
|
|
3066
|
-
let rotation = 0;
|
|
3067
|
-
let transform = this;
|
|
3068
|
-
while (transform !== void 0) {
|
|
3069
|
-
rotation += transform.localRotation;
|
|
3070
|
-
transform = transform.parent;
|
|
3071
|
-
}
|
|
3072
|
-
return rotation;
|
|
3073
|
-
}
|
|
3074
|
-
get globalRotationDegree() {
|
|
3075
|
-
return radianToDegree(this.globalRotation);
|
|
3076
|
-
}
|
|
3077
|
-
get globalScale() {
|
|
3078
|
-
let scale = Vec2.one;
|
|
3079
|
-
let transform = this;
|
|
3080
|
-
while (transform !== void 0) {
|
|
3081
|
-
scale = scale.naiveMultiply(transform.localScale);
|
|
3082
|
-
transform = transform.parent;
|
|
3083
|
-
}
|
|
3084
|
-
return scale;
|
|
3085
|
-
}
|
|
3086
|
-
toString() {
|
|
3087
|
-
return `${this.localPosition.toString()}|${this.localRotation}|${this.localScale.toString()}`;
|
|
3088
|
-
}
|
|
3089
|
-
get [Symbol.toStringTag]() {
|
|
3090
|
-
return "Transform2D";
|
|
3091
|
-
}
|
|
3092
|
-
[NodeJSCustomInspect]() {
|
|
3093
|
-
return `Transform2D <${this.toString()}>`;
|
|
3094
|
-
}
|
|
3095
|
-
toMat3() {
|
|
3096
|
-
return new Mat3().scale(this.localScale).rotate(this.localRotation).translate(this.localPosition);
|
|
3097
|
-
}
|
|
3098
|
-
toGlobalMat3() {
|
|
3099
|
-
let result = new Mat3();
|
|
3100
|
-
let transform = this;
|
|
3101
|
-
while (transform !== void 0) {
|
|
3102
|
-
result = result.multiply(transform.toMat3());
|
|
3103
|
-
transform = transform.parent;
|
|
3104
|
-
}
|
|
3105
|
-
return result;
|
|
3106
|
-
}
|
|
3107
|
-
};
|
|
3108
|
-
var Transform3D = class {
|
|
3109
|
-
/**
|
|
3110
|
-
* Create a new transform with `position`, `rotation` and `scale`
|
|
3111
|
-
* @param position The position as a Vec3
|
|
3112
|
-
* @param rotation The rotation as a Quaternion
|
|
3113
|
-
* @param scale The scale as a Vec3
|
|
3114
|
-
*/
|
|
3115
|
-
constructor(position, rotation, scale, parent) {
|
|
3116
|
-
this.parent = parent;
|
|
3117
|
-
this.localPosition = Vec3.resolve(position);
|
|
3118
|
-
this.localRotation = Quaternion.resolve(rotation);
|
|
3119
|
-
this.localScale = Vec3.resolve(scale);
|
|
3120
|
-
}
|
|
3121
|
-
origin = Vec3.zero;
|
|
3122
|
-
/**
|
|
3123
|
-
* The local position
|
|
3124
|
-
*/
|
|
3125
|
-
localPosition;
|
|
3126
|
-
/**
|
|
3127
|
-
* The local rotation
|
|
3128
|
-
*/
|
|
3129
|
-
localRotation;
|
|
3130
|
-
/**
|
|
3131
|
-
* The local scale
|
|
3132
|
-
*/
|
|
3133
|
-
localScale;
|
|
3134
|
-
get globalPosition() {
|
|
3135
|
-
let position = Vec3.zero;
|
|
3136
|
-
let transform = this;
|
|
3137
|
-
while (transform !== void 0) {
|
|
3138
|
-
position = position.add(transform.localPosition).add(transform.origin);
|
|
3139
|
-
transform = transform.parent;
|
|
3140
|
-
}
|
|
3141
|
-
return position;
|
|
3142
|
-
}
|
|
3143
|
-
get globalRotation() {
|
|
3144
|
-
let rotation = Quaternion.zero;
|
|
3145
|
-
let transform = this;
|
|
3146
|
-
while (transform !== void 0) {
|
|
3147
|
-
rotation = rotation.add(transform.localRotation);
|
|
3148
|
-
transform = transform.parent;
|
|
3149
|
-
}
|
|
3150
|
-
return rotation;
|
|
3151
|
-
}
|
|
3152
|
-
get globalScale() {
|
|
3153
|
-
let scale = Vec3.one;
|
|
3154
|
-
let transform = this;
|
|
3155
|
-
while (transform !== void 0) {
|
|
3156
|
-
scale = scale.naiveMultiply(transform.localScale);
|
|
3157
|
-
transform = transform.parent;
|
|
3158
|
-
}
|
|
3159
|
-
return scale;
|
|
3160
|
-
}
|
|
3161
|
-
toString() {
|
|
3162
|
-
return `${this.localPosition.toString()}|${this.localRotation.toString()}|${this.localScale.toString()}`;
|
|
3163
|
-
}
|
|
3164
|
-
get [Symbol.toStringTag]() {
|
|
3165
|
-
return "Transform2D";
|
|
3166
|
-
}
|
|
3167
|
-
[NodeJSCustomInspect]() {
|
|
3168
|
-
return `Transform2D <${this.toString()}>`;
|
|
3169
|
-
}
|
|
3170
|
-
/**
|
|
3171
|
-
* Convert the transform into a 4x3 matrix
|
|
3172
|
-
* @returns A 4x4 matrix from the transform
|
|
3173
|
-
*/
|
|
3174
|
-
toMat4() {
|
|
3175
|
-
return new Mat4().scale(this.localScale).multiply(this.localRotation).translate(this.localPosition);
|
|
3176
|
-
}
|
|
3177
|
-
toGlobalMat4() {
|
|
3178
|
-
let result = new Mat4();
|
|
3179
|
-
let transform = this;
|
|
3180
|
-
while (transform !== void 0) {
|
|
3181
|
-
result = result.multiply(transform.toMat4());
|
|
3182
|
-
transform = transform.parent;
|
|
3183
|
-
}
|
|
3184
|
-
return result;
|
|
3185
|
-
}
|
|
3186
|
-
};
|
|
3187
|
-
export {
|
|
3188
|
-
AnyColor,
|
|
3189
|
-
BoundingBox,
|
|
3190
|
-
Circle,
|
|
3191
|
-
DJB2_OFFSET,
|
|
3192
|
-
EPSILON,
|
|
3193
|
-
FNV1_OFFSET,
|
|
3194
|
-
FNV1_PRIME,
|
|
3195
|
-
HSLA,
|
|
3196
|
-
LinearFunction,
|
|
3197
|
-
MAX_ANGLE_DEGREE,
|
|
3198
|
-
MD2,
|
|
3199
|
-
Mat3,
|
|
3200
|
-
Mat4,
|
|
3201
|
-
MathFunction,
|
|
3202
|
-
NodeJSCustomInspect,
|
|
3203
|
-
QuadFunction,
|
|
3204
|
-
Quaternion,
|
|
3205
|
-
RGBA,
|
|
3206
|
-
Rectangle,
|
|
3207
|
-
ResolveError,
|
|
3208
|
-
Size,
|
|
3209
|
-
Transform2D,
|
|
3210
|
-
Transform3D,
|
|
3211
|
-
Triangle,
|
|
3212
|
-
Triangle2D,
|
|
3213
|
-
Triangle3D,
|
|
3214
|
-
Vec2,
|
|
3215
|
-
Vec3,
|
|
3216
|
-
checkArray,
|
|
3217
|
-
checkHex,
|
|
3218
|
-
checkNumber,
|
|
3219
|
-
checkNumberArray,
|
|
3220
|
-
checkString,
|
|
3221
|
-
checkStringArray,
|
|
3222
|
-
clamp,
|
|
3223
|
-
clampAngleDegree,
|
|
3224
|
-
clampAngleRadian,
|
|
3225
|
-
degreeToRadian,
|
|
3226
|
-
djb2,
|
|
3227
|
-
fnv1,
|
|
3228
|
-
getHexValue,
|
|
3229
|
-
hasProperty,
|
|
3230
|
-
lerp,
|
|
3231
|
-
logHypot,
|
|
3232
|
-
radianToDegree,
|
|
3233
|
-
sdbm,
|
|
3234
|
-
signCharacter
|
|
3235
|
-
};
|
|
1
|
+
import{ExpectedTypeError as e,NodeJSCustomInspect as t,checkFixedTypeArray as n,checkValidNumber as r,hasTypedProperty as i,isFixedArray as a,isFixedTypeArray as o,isValidNumber as s,isValidString as c}from"@ntf/types";var l=class{};function u(e){if(e!=0){if(e<0)return`-`;if(e>0)return`+`}}var d=class extends Error{constructor(e,t){super(`Can't resolve ${t} to ${e}`),this.target=e,this.value=t}};function f(e,t,n){return e<=t?t:e>=n?n:e}function p(e,t){let n=Math.abs(e),r=Math.abs(t);if(e==0)return Math.log(r);if(t==0)return Math.log(n);if(n<3e3&&r<3e3)return .5*Math.log(e*e+t*t);let i=e/2,a=t/2;return .5*Math.log(i*i+a*a)+Math.LN2}const m=1e-16,h=(e,t,n)=>((typeof e==`number`?1:1n)-n)*e+n*t;var g=class e{x;y;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Vec2`,e)}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,2)||o(e,s,3))return new this(e[0],e[1],e[2]);if(i(e,`toVec2`,`function`))return this.cast(e.toVec2());if(i(e,`x`,`number`)&&i(e,`y`,`number`))return new this(e.x,e.y,i(e,`w`,`number`)?e.w:void 0);if(c(e)){let[t,n]=e.split(`;`);if(c(t)){let e=t.split(`,`);if(o(e,c,2))return new this(parseFloat(e[0]),parseFloat(e[1]),c(n)?parseFloat(n):void 0)}}if(s(e))return new this(e,e)}}static resolveArgs(e){return o(e,s,2)?new this(e[0],e[1]):this.resolve(e[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y)}static clamp(e,t,n){let r=this.resolve(e),i=this.resolve(t),a=this.resolve(n);return new this(f(r.x,i.x,a.x),f(r.y,i.y,a.y))}static get zero(){return new this(0,0)}static get one(){return new this(1,1)}constructor(e,t,n=1){r(e),r(t),r(n),this.x=e,this.y=t,this.w=n}toArray(e=this.w!==1){return e?[this.x,this.y,this.w]:[this.x,this.y]}toJSON(){return{x:this.x,y:this.y,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y};${this.w}`:`${this.x},${this.y}`}get[Symbol.toStringTag](){return`Vec2`}[t](){return`Vec2 <${this.toString()}>`}toSize(){return[this.x,this.y]}toVec3(e=0){return[this.x,this.y,e,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.w]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.w,1]}toHSL(){let e=this.normalize();return[e.x,e.y,e.w]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.w,1]}clone(){return new e(this.x,this.y,this.w)}equals(...t){let n=e.resolveArgs(t);return this.x==n.x&&this.y==n.y}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setW(e){return this.w=e,this}set(...t){let n=e.resolveArgs(t);return this.setX(n.x).setY(n.y)}add(...t){let n=e.resolveArgs(t);return new e(this.x+n.x,this.y+n.y)}offset(...t){let n=e.resolveArgs(t);return this.x+=n.x,this.y+=n.y,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.x-n.x,this.y-n.y)}multiply(t){return new e(this.x*t,this.y*t)}naiveMultiply(...t){let n=e.resolveArgs(t);return new e(this.x*n.x,this.y*n.y)}divide(...t){if(o(t,s,1))return new e(this.x/t[0],this.y/t[0]);let n=e.resolveArgs(t);return new e(this.x/n.x,this.y/n.y)}dot(...t){let n=e.resolveArgs(t);return this.x*n.x+this.y*n.y}distance(...t){let n=e.resolveArgs(t);return(n.x-this.x)**2+(n.y-this.y)**2}distanceSquare(...t){let n=e.resolveArgs(t);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}cartesianify(){return new e(this.x*Math.cos(this.y),this.x*Math.sin(this.y))}polarify(){return new e(Math.sqrt(this.x*this.x+this.y*this.y),Math.atan(this.y/this.x))}normalize(){let t=this.length();return t==0?e.zero:new e(this.x/t,this.y/t,this.w/t)}invert(){return this.multiply(-1)}round(){return new e(Math.round(this.x),Math.round(this.y),Math.round(this.w))}},_=class extends l{m;b;static fromPoints(e,t){let n=g.resolve(e),r=g.resolve(t),i=(r.y-n.y)/(r.x-n.x),a=-i*n.x+n.y;return new this(i,a)}constructor(e,t){super(),r(e),r(t),this.m=e,this.b=t}get(e){return r(e),this.m*e+this.b}roots(){let e=-this.b/this.m;return isNaN(e)?[]:[new g(e,0)]}toString(){let e=u(this.b);return e?`f(x) = ${this.m} * x ${e} ${Math.abs(this.b)}`:`f(x) = ${this.m} * x`}get[Symbol.toStringTag](){return`LinearFunction`}[t](){return`LinearFunction <${this.toString()}>`}},v=class extends l{a;b;c;static get(e,t,n,r){return new this(e,t,n).get(r)}constructor(t,n,i){if(super(),r(t),t===0)throw new e(`non-zero valid number`,t);r(n),r(i),this.a=t,this.b=n,this.c=i}get(e){return r(e),this.a*e*e+this.b*e+this.c}roots(){let e=[],t=this.b*this.b-4*this.a*this.c,n=(-this.b+Math.sqrt(t))/(2*this.a),r=(-this.b+Math.sqrt(t))/(2*this.a);return isNaN(n)||e.push(new g(n,0)),!isNaN(r)&&n!=r&&e.push(new g(r,0)),e}toString(e=`standard`){switch(e){default:case`standard`:{let e=u(this.b),t=u(this.c);return e&&t?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x ${t} ${Math.abs(this.c)}`:e?`f(x) = ${this.a}x^2 ${e} ${Math.abs(this.b)}x`:`f(x) = ${this.a}x^2`}}}get[Symbol.toStringTag](){return`QuadFunction`}[t](){return`QuadFunction <${this.toString()}>`}},y=class e{x;y;z;w;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Vec3`,e)}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`z`,`number`))return new this(e.x,e.y,e.z,i(e,`w`,`number`)?e.w:void 0);if(c(e)){let[t,n]=e.split(`;`);if(c(t)){let e=t.split(`,`);if(o(e,c,3))return new this(parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2]),c(n)?parseFloat(n):void 0)}}if(s(e))return new this(e,e,e)}}static resolveArgs(e){return o(e,s,3)?new this(e[0],e[1],e[2]):this.resolve(e[0])}static is(e){return this.cast(e)!==void 0}static fromPoints(e,t){let n=this.resolve(e),r=this.resolve(t);return new this(r.x-n.x,r.y-n.y,r.z-n.z)}static clamp(e,t,n){let r=this.resolve(e),i=this.resolve(t),a=this.resolve(n);return new this(f(r.x,i.x,a.x),f(r.y,i.y,a.y),f(r.z,i.z,a.z))}static intersectPlane(t,n,r,i,a){n=this.resolve(n).normalize();let o=-this.resolve(n).dot(t),s=this.resolve(r).dot(n),c=this.resolve(i).dot(n);a=(-o-s)/(c-s);let l=this.resolve(i).subtract(r).multiply(a);return e.resolve(r).add(l)}static get zero(){return new this(0,0,0)}static get one(){return new this(1,1,1)}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this.x=e,this.y=t,this.z=n,this.w=i}toArray(e=this.w!==1){return e?[this.x,this.y,this.z,this.w]:[this.x,this.y,this.z]}toJSON(){return{x:this.x,y:this.y,z:this.z,w:this.w}}toString(e=this.w!==1){return e?`${this.x},${this.y},${this.z};${this.w}`:`${this.x},${this.y},${this.z}`}get[Symbol.toStringTag](){return`Vec3`}[t](){return`Vec3 <${this.toString()}>`}toVec2(){return[this.x,this.y,this.w]}toRGB(){let e=this.normalize();return[e.x,e.y,e.z]}toRGBA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toHSL(){let e=this.normalize();return[e.x,e.y,e.z]}toHSLA(){let e=this.normalize();return[e.x,e.y,e.z,e.w]}toQuaternion(){return[this.w,this.x,this.y,this.z]}clone(){return new e(this.x,this.y,this.z,this.w)}equals(...t){let n=e.resolveArgs(t);return this.x==n.x&&this.y==n.y&&this.z==n.z}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}set(...t){let n=e.resolveArgs(t);return this.setX(n.x).setY(n.y).setZ(n.z)}add(...t){let n=e.resolveArgs(t);return new e(this.x+n.x,this.y+n.y,this.z+n.z)}offset(...t){let n=e.resolveArgs(t);return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(t){return new e(this.x*t,this.y*t,this.z*t)}naiveMultiply(...t){let n=e.resolveArgs(t);return new e(this.x*n.x,this.y*n.y,this.z*n.z)}divide(...t){if(o(t,s,1))return new e(this.x/t[0],this.y/t[0],this.z/t[0]);let n=e.resolveArgs(t);return new e(this.x/n.x,this.y/n.y,this.z/n.z)}dot(...t){let n=e.resolveArgs(t);return this.x*n.x+this.y*n.y+this.z*n.z}cross(...t){let n=e.resolveArgs(t);return new e(this.y*n.z-this.z*n.y,this.z*n.x-this.x*n.z,this.x*n.y-this.y*n.x)}distance(...t){let n=e.resolveArgs(t);return(n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2}distanceSquare(...t){let n=e.resolveArgs(t);return Math.sqrt((n.x-this.x)**2+(n.y-this.y)**2+(n.z-this.z)**2)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){let t=this.length();return t==0?e.zero:new e(this.x/t,this.y/t,this.z/t,this.w/t)}invert(){return this.multiply(-1)}round(){return new e(Math.round(this.x),Math.round(this.y),Math.round(this.z),Math.round(this.w))}},b=class e{w;x;y;z;static is(e){return this.cast(e)!==void 0}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Quaternion`,e)}static resolveArgs(e){return o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toQuaternion`,`function`))return this.cast(e.toQuaternion());if(i(e,`w`,`number`)&&i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`z`,`number`))return new this(e.w,e.x,e.y,e.z);if(c(e)){let t=e.replaceAll(` `,``).split(`+`);if(o(t,c,4)){let[e,n,r,i]=t;if(e&&n?.endsWith(`i`)&&r?.endsWith(`j`)&&i?.endsWith(`k`))return this.cast([parseFloat(e),parseFloat(n.substring(0,n.length-1)),parseFloat(r.substring(0,r.length-1)),parseFloat(i.substring(0,i.length-1))])}}}}static fromAxisAngle(...e){let t=o(e,s,4)?new y(e[0],e[1],e[2]):y.resolve(e[0]),n=o(e,s,4)?e[3]:e[1],r=y.resolve(t),i=n*.5,a=Math.sin(i),c=Math.cos(i),l=a/Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z);return new this(c,r.x*l,r.y*l,r.z*l)}static fromEuler(...t){let n=y.resolveArgs(t),r=n.x*.5,i=n.y*.5,a=n.z*.5,o=Math.cos(r),s=Math.cos(i),c=Math.cos(a),l=Math.sin(r),u=Math.sin(i),d=Math.sin(a);return new e(o*s*c-l*u*d,l*s*c-u*d*o,u*o*c-l*d*s,l*u*c+d*o*s)}static get zero(){return new e(0,0,0,0)}constructor(e,t,n,i){r(e),r(t),r(n),r(i),this.w=e,this.x=t,this.y=n,this.z=i}toArray(){return[this.w,this.x,this.y,this.z]}toString(){return`${this.w} + ${this.x}i + ${this.y}j + ${this.z}k`}get[Symbol.toStringTag](){return`Quaternion`}[t](){return`Quaternion <${this.toString()}>`}toJSON(){return{w:this.w,x:this.x,y:this.y,z:this.z}}clone(){return new e(this.w,this.x,this.y,this.z)}add(...t){let n=e.resolveArgs(t);return new e(this.w+n.w,this.x+n.x,this.y+n.y,this.z+n.z)}offset(...t){let n=e.resolveArgs(t);return this.w+=n.w,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}subtract(...t){let n=e.resolveArgs(t);return new e(this.w-n.w,this.x-n.x,this.y-n.y,this.z-n.z)}negative(){return new e(-this.w,-this.x,-this.y,-this.z)}length(e=!0){let t=this.w*this.w+this.x*this.x+this.y*this.y+this.z*this.z;return e?Math.sqrt(t):t}normalize(){let t=this.length();return t<m?e.zero:(t=1/t,new e(this.w*t,this.x*t,this.y*t,this.z*t))}multiply(...t){let n=e.resolveArgs(t);return new e(this.w*n.w-this.x*n.x-this.y*n.y-this.z*n.z,this.w*n.x+this.x*n.w+this.y*n.z-this.z*n.y,this.w*n.y+this.y*n.w+this.z*n.x-this.x*n.z,this.w*n.z+this.z*n.w+this.x*n.y-this.y*n.x)}multiplyVector(...e){let t=y.resolveArgs(e),n=this.w*t.x+this.y*t.y-this.z*t.y,r=this.w*t.y+this.z*t.x-this.x*t.z,i=this.w*t.z+this.x*t.y-this.y*t.x,a=-this.w*t.x-this.y*t.y-this.z*t.z;return new y(n*this.w+a*-this.x+r*-this.z-i*-this.y,r*this.w+a*-this.y+i*-this.x-n*-this.z,i*this.w+a*-this.z+n*-this.y-r*-this.x)}scale(t){return new e(this.w*t,this.x*t,this.y*t,this.z*t)}dot(...t){let n=e.resolveArgs(t);return this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z}inverse(){let t=this.length(!1);return t==0?e.zero:(t=1/t,new e(this.w*t,-this.x*t,-this.y*t,-this.z*t))}divide(...t){let n=e.resolveArgs(t),r=n.length(!1);return r==0?e.zero:(r=1/r,new e((this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z)*r,(this.x*n.w-this.w*n.x-this.y*n.z+this.z*n.y)*r,(this.y*n.w-this.w*n.y-this.z*n.x+this.x*n.z)*r,(this.z*n.w-this.w*n.z-this.x*n.y+this.y*n.x)*r))}conjugate(){return new e(this.w,-this.x,-this.y,-this.z)}exp(){let t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),n=Math.exp(this.w),r=n*Math.sin(t)/t;return t==0?new e(n,0,0,0):new e(n*Math.cos(t),this.x*r,this.y*r,this.z*r)}log(){if(this.x==0&&this.z==0)return new e(p(this.w,this.x),Math.atan2(this.x,this.w),0,0);let t=this.length(!1),n=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z),r=Math.atan2(n,this.w)/t;return new e(Math.log(t)*.5,this.x*r,this.y*r,this.z*r)}toVec3(){return[this.x,this.y,this.z,this.w]}toAxisAngle(){let e=1-this.w*this.w;if(e>m)return new y(this.x,this.y,this.z,0);let t=1/Math.sqrt(e),n=2*Math.acos(this.w);return new y(this.x*t,this.y*t,this.z*t,n)}toEuler(){function e(e){return e>=1?Math.PI/2:e<=-1?-Math.PI/2:Math.asin(e)}return new y(-Math.atan2(2*(this.y*this.z-this.w*this.x),1-2*(this.x*this.x+this.y*this.y)),e(2*(this.x*this.z+this.w*this.y)),-Math.atan2(2*(this.x*this.y-this.w*this.z),1-2*(this.y*this.y+this.z*this.z)))}toMat3(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y)]}toMat4(){return[1-2*(this.y*this.y+this.z*this.z),2*(this.x*this.y-this.w*this.z),2*(this.x*this.z+this.w*this.y),0,2*(this.x*this.y+this.w*this.z),1-2*(this.x*this.x+this.z*this.z),2*(this.y*this.z-this.w*this.x),0,2*(this.x*this.z-this.w*this.y),2*(this.y*this.z+this.w*this.x),1-2*(this.x*this.x+this.y*this.y),0,0,0,0,1]}};function x(e){let t=e<4096,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8;return[(t?(e&3840)>>>8:(e&16711680)>>>16)/255,r/255,n/255]}function S(e){let t=e<65536,n=t?e&15:e&255,r=t?(e&240)>>>4:(e&65280)>>>8,i=t?(e&3840)>>>8:(e&16711680)>>>16;return[(t?(e&61440)>>>12:(e&4278190080)>>>24)/255,i/255,r/255,n/255]}function C(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)||e.startsWith(`0x`)}function w(e){return e=e.trim(),[`$`,`#`].includes(e[0]??``)?e.substring(1):e.startsWith(`0x`)?e.substring(2):e}function T(e){let t=w(e);return[4,8].includes(t.length)}function E(e){let t=w(e),n=t.length===3,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16);return[r/255,i/255,a/255]}function D(e){let t=w(e),n=t.length===4,r=parseInt(n?t[0]:t.substring(0,2),16),i=parseInt(n?t[1]:t.substring(2,4),16),a=parseInt(n?t[2]:t.substring(4,6),16),o=parseInt(n?t[3]:t.substring(6,8),16);return[r/255,i/255,a/255,o/255]}var O=class e{_red;get red(){return this._red}set red(e){this._red=f(e,0,1)}_green;get green(){return this._green}set green(e){this._green=f(e,0,1)}_blue;get blue(){return this._blue}set blue(e){this._blue=f(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=f(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`RGBAColor`,e)}static resolveArgs(e){return o(e,s,3)||o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toRGB`,`function`))return this.cast(e.toRGB());if(i(e,`toRGBA`,`function`))return this.cast(e.toRGBA());if(i(e,`red`,`number`)&&i(e,`green`,`number`)&&i(e,`blue`,`number`))return new this(e.red,e.green,e.blue,i(e,`alpha`,`number`)?e.alpha:void 0);if(s(e)){let t=e.toString(16).length<=6?x:S;return this.cast(t(e))}if(c(e)){if(e.startsWith(`rgb`)){let t=e.startsWith(`rgba`),n=t?5:4,r=e.substring(n,e.indexOf(`)`,n)).split(`,`);if(o(r,c,t?4:3))return this.cast(r.map(e=>parseInt(e)/255))}if(C(e)){let t=T(e)?D:E;return this.cast(t(e))}}}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this._red=f(e,0,1),this._green=f(t,0,1),this._blue=f(n,0,1),this._alpha=f(i,0,1)}toArray(e=this._alpha!==1){return e?[this.red,this.green,this.blue,this.alpha]:[this.red,this.green,this.blue]}toJSON(e=this._alpha!==1){return e?{red:this.red,green:this.green,blue:this.blue,alpha:this.alpha}:{red:this.red,green:this.green,blue:this.blue}}toString(e=this._alpha!==1){return e?`rgba(${f(this.red*255|0,0,255)},${f(this.green*255|0,0,255)},${f(this.blue*255|0,0,255)},${this.alpha})`:`rgb(${f(this.red*255|0,0,255)},${f(this.green*255|0,0,255)},${f(this.blue*255|0,0,255)})`}get[Symbol.toStringTag](){return`RGBA`}[t](){return`RGBA <${this.toString()}>`}toVec2(){return[this.red,this.green,this.blue]}toVec3(){return[this.red,this.green,this.blue,this.alpha]}toHSL(e=this._alpha!==1){let t=this.red,n=this.green,r=this.blue,i=Math.min(t,n,r),a=Math.max(t,n,r),o=(i+a)/2;if(i==a)return new k(0,0,o,e?this.alpha:void 0);let s=a-i,c=o>.5?s/(2-a-i):s/(a+i);return a==t?new k(((n-r)/s+(n<r?6:0))/6,c,o,e?this.alpha:void 0):a==n?new k(((r-t)/s+2)/6,c,o,e?this.alpha:void 0):a==r?new k(((t-n)/s+4)/6,c,o,e?this.alpha:void 0):new k(0,c,o,e?this.alpha:void 0)}toHSLA(){return this.toHSL(!0)}invert(t=this._alpha!==1){return new e(1-this.red,1-this.green,1-this.blue,t?1-this.alpha:this.alpha)}},k=class e{_hue;get hue(){return this._hue}set hue(e){this._hue=f(e,0,1)}_saturation;get saturation(){return this._saturation}set saturation(e){this._saturation=f(e,0,1)}_luminace;get luminace(){return this._luminace}set luminace(e){this._luminace=f(e,0,1)}_alpha;get alpha(){return this._alpha}set alpha(e){this._alpha=f(e,0,1)}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`HSLColor`,e)}static resolveArgs(e){return o(e,s,3)||o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3)||o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toHSL`,`function`))return this.cast(e.toHSL());if(i(e,`toHSLA`,`function`))return this.cast(e.toHSLA());if(i(e,`hue`,`number`)&&i(e,`saturation`,`number`)&&i(e,`luminace`,`number`))return new this(e.hue,e.saturation,e.luminace,i(e,`alpha`,`number`)?e.alpha:void 0);if(s(e)){let t=e.toString(16).length<=6?x:S;return this.cast(t(e))}if(c(e)){if(e.startsWith(`hsl`)){let t=e.startsWith(`hsla`),n=t?5:4,r=e.substring(n,e.indexOf(`)`,n)).split(`,`);if(o(r,c,t?4:3))return this.cast(r.map(e=>parseInt(e)/255))}if(C(e)){let t=T(e)?D:E;return this.cast(t(e))}}}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i=1){r(e),r(t),r(n),r(i),this._hue=f(e,0,1),this._saturation=f(t,0,1),this._luminace=f(n,0,1),this._alpha=f(i,0,1)}toArray(e=this._alpha!==1){return e?[this.hue,this.saturation,this.luminace,this.alpha]:[this.hue,this.saturation,this.luminace]}toJSON(e=this._alpha!==1){return e?{hue:this.hue,saturation:this.saturation,luminace:this.luminace,alpha:this.alpha}:{hue:this.hue,saturation:this.saturation,luminace:this.luminace}}toString(e=this._alpha!==1){return e?`hsla(${f(this.hue*255|0,0,255)},${f(this.saturation*255|0,0,255)},${f(this.luminace*255|0,0,255)},${this.alpha})`:`hsl(${f(this.hue*255|0,0,255)},${f(this.saturation*255|0,0,255)},${f(this.luminace*255|0,0,255)})`}get[Symbol.toStringTag](){return`HSLA`}[t](){return`HSLA <${this.toString()}>`}toRGB(e=this._alpha!==1){if(this.saturation==0)return new O(this.luminace*255,this.luminace*255,this.luminace*255,e?this.alpha:void 0);let t=this.luminace<.5?this.luminace*(1+this.saturation):this.luminace+this.saturation-this.luminace*this.saturation,n=2*this.luminace-t;function r(e){let r=e;return r<0&&r++,r>1&&r--,r<1/6?n+(t-n)*6*r:r<1/2?t:r<2/3?n+(t-n)*(2/3-r)*6:n}return new O(r(this.hue+1/3)*255,r(this.hue)*255,r(this.hue-1/3)*255,e?this.alpha:void 0)}toRGBA(){return this.toRGB(!0)}toVec2(){return[this.hue,this.saturation,this.luminace]}toVec3(){return[this.hue,this.saturation,this.luminace,this.alpha]}invert(t=this._alpha!==1){return new e(1-this.hue,1-this.saturation,1-this.luminace,t?1-this.alpha:this.alpha)}};const A=5381n;function j(e){let t=String(e),n=A;for(let e=0;e<t.length;e++)n=(n<<5n)+n+BigInt(t.charCodeAt(e));return n}const M=14695981039346656037n,N=1099511628211n;function P(e){let t=String(e),n=M;for(let e=0;e<t.length;e++)n*=N,n^=BigInt(t.charCodeAt(e));return n}function F(e){let t=String(e),n=0n;for(let e=0;e<t.length;e++)n=BigInt(t.charCodeAt(e))+(n<<6n)+(n<<16n)-n;return n}const I=360,L=e=>e%360,R=e=>L(B(e)),z=e=>e*(180/Math.PI),B=e=>e*(Math.PI/180);var V=class e{radius;get perimeter(){return this.radius*Math.PI*2}get area(){return Math.PI*this.radius**2}position;get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Circle`,e)}static resolveArgs(e){return o(e,s,3)?new this([e[0],e[1]],e[2]):e.length===2?new this(e[0],e[1]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,3))return new this([e[0],e[1]],e[2]);if(o(e,s,4)){let t=new this([e[0],e[1]],e[3]);return t.w=e[2],t}if(i(e,`toCircle`,`function`))return this.cast(e.toCircle());if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`radius`,`number`))return new this(i(e,`w`,`number`)?[e.x,e.y,e.w]:[e.x,e.y],e.radius);if(c(e)){let[t,n]=e.split(`|`),r=g.cast(t);if(r===void 0||n===void 0)return;let i=parseFloat(n);if(!isNaN(i))return new this(r,i)}}}static is(e){return this.cast(e)!==void 0}constructor(e,t){r(t),this.position=g.resolve(e),this.radius=t}toArray(){return[...this.position.toArray(),this.radius]}toJSON(){return{...this.position.toJSON(),radius:this.radius}}toString(){return`${this.position.toString()}|${this.radius}`}get[Symbol.toStringTag](){return`Circle`}[t](){return`Circle <${this.toString()}>`}clone(){return new e(this.position.clone(),this.radius)}toVec2(){return[this.x,this.y,this.w]}equals(...t){let n=e.resolveArgs(t);return n.position.equals(n.position)&&this.radius==n.radius}inside(...t){let n=e.resolveArgs(t),r=n.x-this.x,i=n.y-this.y;return Math.sqrt(r*r+(i+i))<=this.radius+n.radius}insidePoint(...e){return this.position.distance(g.resolveArgs(e))<=this.radius}},H=class e{left;right;top;bottom;get width(){return this.right-this.left}set width(e){this.right=this.left+e}get height(){return this.bottom-this.top}set height(e){this.bottom=this.top+e}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}w=1;static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`BoundingBox`,e)}static resolveArgs(e){return o(e,s,4)?new this(e[0],e[1],e[2],e[3]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,4))return new this(e[0],e[1],e[2],e[3]);if(i(e,`toBoundingBox`,`function`))return this.cast(e.toBoundingBox());if(i(e,`left`,`number`)&&i(e,`right`,`number`)&&i(e,`top`,`number`)&&i(e,`bottom`,`number`))return new this(e.left,e.right,e.top,e.bottom);if(c(e)){let t=e.split(`,`);if(o(t,c,4))return this.cast(t.map(e=>parseFloat(e)))}}}static is(e){return this.cast(e)!==void 0}constructor(e,t,n,i){r(e),r(t),r(n),r(i),this.left=e,this.right=t,this.top=n,this.bottom=i}toArray(){return[this.left,this.right,this.top,this.bottom]}toString(){return`${this.left},${this.right},${this.top},${this.bottom}`}get[Symbol.toStringTag](){return`BoundingBox`}[t](){return`BoundingBox <${this.toString()}>`}toJSON(){return{left:this.left,top:this.top,right:this.right,bottom:this.bottom}}clone(){return new e(this.left,this.right,this.top,this.bottom)}equals(...t){let n=e.resolveArgs(t);return this.left===n.left&&this.right===n.right&&this.top===n.top&&this.bottom===n.bottom}toSize(){return[this.width,this.height]}toVec2(){return[this.left,this.top]}toRectangle(){return[this.left,this.top,this.width,this.height]}inside(...t){let n=e.resolve(t);return this.right>=n.left&&n.right>=this.left&&this.bottom>=n.top&&n.bottom>=this.top}insidePoint(...e){let t=g.resolveArgs(e);return this.left<=t.x&&this.right>=t.x&&this.top<=t.y&&this.bottom>=t.y}insideCircle(...e){let t=V.resolveArgs(e),n=g.resolve(t).add(t.radius),r=new g(this.width/2,this.height/2),i=new g(this.left+r.x,this.top+r.y),a=n.subtract(i),o=g.clamp(a,r.invert(),r);return a=i.add(o).subtract(n),a.length()<t.radius}},U=class e{width;height;get aspectRatio(){return this.height/this.width}get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Square`,e)}static resolveArgs(e){return o(e,s,2)?new this(e[0],e[1]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,2))return new this(e[0],e[1]);if(i(e,`toSize`,`function`))return this.cast(e.toSize());if(i(e,`width`,`number`)&&i(e,`height`,`number`))return new this(e.width,e.height);if(c(e)){let t=e.split(`x`).map(e=>parseFloat(e));if(o(t,s,2))return this.cast(t)}if(s(e))return new this(e,e)}}static is(e){return this.cast(e)!==void 0}constructor(e,t){r(e),r(t),this.width=e,this.height=t}toArray(){return[this.width,this.height]}toString(){return`${this.width}x${this.height}`}get[Symbol.toStringTag](){return`Size`}[t](){return`Size <${this.toString()}>`}toJSON(){return{width:this.width,height:this.height}}clone(){return new e(this.width,this.height)}equals(...t){let n=e.resolveArgs(t);return this.width==n.width&&this.height==n.height}toVec2(){return[this.width,this.height]}},W=class e{position;size;get area(){return this.width*this.height}get perimeter(){return this.width+this.width+this.height+this.height}get x(){return this.position.x}set x(e){this.position.x=e}get y(){return this.position.y}set y(e){this.position.y=e}get w(){return this.position.w}set w(e){this.position.w=e}get width(){return this.size.width}set width(e){this.size.width=e}get height(){return this.size.height}set height(e){this.size.height=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Rectangle`,e)}static resolveArgs(e){return o(e,s,4)?new this([e[0],e[1]],[e[2],e[3]]):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,4))return new this([e[0],e[1]],[e[2],e[3]]);if(o(e,s,5)){let t=new this([e[0],e[1]],[e[3],e[4]]);return t.w=e[2],t}if(c(e)){let[t,n]=e.split(`|`),r=g.cast(t),i=U.cast(n);if(r===void 0||i===void 0)return;let a=new this([r.x,r.y],[i.width,i.height]);return a.w=r.w,a}if(i(e,`toRectangle`,`function`))return this.cast(e.toRectangle());if(i(e,`x`,`number`)&&i(e,`y`,`number`)&&i(e,`width`,`number`)&&i(e,`height`,`number`)){let t=new this([e.x,e.y],[e.width,e.height]);return i(e,`w`,`number`)&&(t.w=e.w),t}}}static is(e){return this.cast(e)!==void 0}constructor(e,t){this.position=g.resolve(e),this.size=U.resolve(t)}toArray(e=this.w!==1){return[...this.position.toArray(e),...this.size.toArray()]}toString(e=this.w!==1){return`${this.position.toString(e)}|${this.size.toString()}`}get[Symbol.toStringTag](){return`Rectangle`}[t](){return`Rectangle <${this.toString()}>`}toJSON(){return{...this.position.toJSON(),...this.size.toJSON()}}toBoundingBox(){return[this.x,this.x+this.width,this.y,this.y+this.height]}toVec2(){return[this.x,this.y,this.w]}toSize(){return[this.width,this.height]}clone(){return new e(this.position.clone(),this.size.clone())}equals(...t){let n=e.resolveArgs(t);return this.position.equals(n.position)&&this.size.equals(n.size)}},G=class{constructor(e,t,n){this.A=e,this.B=t,this.C=n}get alpha(){return Math.acos((this.b*this.b+this.c*this.c-this.a*this.a)/(2*this.b*this.c))}get beta(){return Math.acos((this.c*this.c+this.a*this.a-this.b*this.b)/(2*this.c*this.a))}get gamma(){return Math.acos((this.a*this.a+this.b*this.b-this.c*this.c)/(2*this.a*this.b))}get perimeter(){return this.a+this.b+this.c}get semiperimeter(){return this.perimeter/2}get area(){return Math.sqrt(this.semiperimeter*(this.semiperimeter-this.a)*(this.semiperimeter-this.b)*(this.semiperimeter-this.c))}get base(){return 2*(this.area/(this.a*Math.sin(this.gamma)))}get height(){return 2*(this.area/this.base)}toString(){return`${this.A}|${this.B}|${this.C}`}get[Symbol.toStringTag](){return`Triangle`}[t](){return`Triangle <${this.toString()}>`}},K=class extends G{get a(){return g.fromPoints(this.B,this.C).length()}get b(){return g.fromPoints(this.A,this.C).length()}get c(){return g.fromPoints(this.A,this.B).length()}},q=class extends G{get a(){return y.fromPoints(this.B,this.C).length()}get b(){return y.fromPoints(this.A,this.C).length()}get c(){return y.fromPoints(this.A,this.B).length()}},J=class e{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m10(){return this._raw[3]}set m10(e){this._raw[3]=e}get m11(){return this._raw[4]}set m11(e){this._raw[4]=e}get m12(){return this._raw[5]}set m12(e){this._raw[5]=e}get m20(){return this._raw[6]}set m20(e){this._raw[6]=e}get m21(){return this._raw[7]}set m21(e){this._raw[7]=e}get m22(){return this._raw[8]}set m22(e){this._raw[8]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Mat3`,e)}static resolveArgs(e){return o(e,s,9)?new this(e):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,9))return new this(e);if(a(e,3)){let t=e[0],n=e[1],r=e[2];if(o(t,s,3)&&o(n,s,3)&&o(r,s,3))return new this([t[0],t[1],t[2],n[0],n[1],n[2],r[0],r[1],r[2]])}if(c(e)){let t=e.split(`,`);if(o(t,c,9))return this.cast(t.map(e=>parseFloat(e)))}if(i(e,`toMat3`,`function`))return this.cast(e.toMat3());if(i(e,`m00`,`number`)&&i(e,`m01`,`number`)&&i(e,`m02`,`number`)&&i(e,`m10`,`number`)&&i(e,`m11`,`number`)&&i(e,`m12`,`number`)&&i(e,`m20`,`number`)&&i(e,`m21`,`number`)&&i(e,`m22`,`number`))return new this([e.m00,e.m01,e.m02,e.m10,e.m11,e.m12,e.m20,e.m21,e.m22]);if(s(e))return new this([e,e,e,e,e,e,e,e,e])}}static is(e){return this.cast(e)!==void 0}static projection(e,t){return new this([2/e,0,0,0,-2/t,0,-1,1,1])}constructor(e=[1,0,0,0,1,0,0,0,1]){n(e,s,9),this._raw=e}toArray(){return[this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22]}toNestetArray(){return[[this.m00,this.m01,this.m02],[this.m10,this.m11,this.m12],[this.m20,this.m21,this.m22]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m10:this.m10,m11:this.m11,m12:this.m12,m20:this.m20,m21:this.m21,m22:this.m22}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m10},${this.m11},${this.m12},${this.m20},${this.m21},${this.m22}`}get[Symbol.toStringTag](){return`Mat3`}[t](){return`Mat3 <${this.toString()}>`}clone(){return new e([this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22])}equals(...t){let n=e.resolveArgs(t);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...t){if(o(t,s,1))return new e([this.m00*t[0],this.m01*t[0],this.m02*t[0],this.m10*t[0],this.m11*t[0],this.m12*t[0],this.m20*t[0],this.m21*t[0],this.m22*t[0]]);let n=e.resolveArgs(t);return new e([n.m00*this.m00+n.m01*this.m10+n.m02*this.m20,n.m00*this.m01+n.m01*this.m11+n.m02*this.m21,n.m00*this.m02+n.m01*this.m12+n.m02*this.m22,n.m10*this.m00+n.m11*this.m10+n.m12*this.m20,n.m10*this.m01+n.m11*this.m11+n.m12*this.m21,n.m10*this.m02+n.m11*this.m12+n.m12*this.m22,n.m20*this.m00+n.m21*this.m10+n.m22*this.m20,n.m20*this.m01+n.m21*this.m11+n.m22*this.m21,n.m20*this.m02+n.m21*this.m12+n.m22*this.m22])}translate(...e){let t=g.resolveArgs(e);return this.multiply([1,0,0,0,1,0,t.x,t.y,1])}rotate(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,-n,0,n,t,0,0,0,1])}scale(...e){let t=g.resolve(e);return this.multiply([t.x,0,0,0,t.y,0,0,0,1])}determinant(){return this.m00*this.m11*this.m22-this.m21*this.m12-this.m01*this.m10*this.m22-this.m12*this.m20+this.m02*this.m10*this.m21-this.m11*this.m20}inverse(){let t=this.determinant();return new e([(this.m11*this.m22-this.m21*this.m12)*t,(this.m02*this.m21-this.m01*this.m22)*t,(this.m01*this.m12-this.m02*this.m11)*t,(this.m12*this.m20-this.m10*this.m22)*t,(this.m00*this.m22-this.m02*this.m20)*t,(this.m10*this.m02-this.m00*this.m12)*t,(this.m10*this.m21-this.m20*this.m11)*t,(this.m20*this.m01-this.m00*this.m21)*t,(this.m00*this.m11-this.m10*this.m01)*t])}toMat4(){return[this.m00,this.m01,this.m02,0,this.m10,this.m11,this.m12,0,this.m20,this.m20,this.m22,0,0,0,0,1]}},Y=class e{_raw;get m00(){return this._raw[0]}set m00(e){this._raw[0]=e}get m01(){return this._raw[1]}set m01(e){this._raw[1]=e}get m02(){return this._raw[2]}set m02(e){this._raw[2]=e}get m03(){return this._raw[3]}set m03(e){this._raw[3]=e}get m10(){return this._raw[4]}set m10(e){this._raw[4]=e}get m11(){return this._raw[5]}set m11(e){this._raw[5]=e}get m12(){return this._raw[6]}set m12(e){this._raw[6]=e}get m13(){return this._raw[7]}set m13(e){this._raw[7]=e}get m20(){return this._raw[8]}set m20(e){this._raw[8]=e}get m21(){return this._raw[9]}set m21(e){this._raw[9]=e}get m22(){return this._raw[10]}set m22(e){this._raw[10]=e}get m23(){return this._raw[11]}set m23(e){this._raw[11]=e}get m30(){return this._raw[12]}set m30(e){this._raw[12]=e}get m31(){return this._raw[13]}set m31(e){this._raw[13]=e}get m32(){return this._raw[14]}set m32(e){this._raw[14]=e}get m33(){return this._raw[15]}set m33(e){this._raw[15]=e}static resolve(e){let t=this.cast(e);if(t!==void 0)return t;throw new d(`Mat4`,e)}static resolveArgs(e){return o(e,s,16)?new this(e):this.resolve(e[0])}static cast(e){if(!(e==null||e===void 0)){if(o(e,s,16))return new this(e);if(a(e,4)){let t=e[0],n=e[1],r=e[2],i=e[3];if(o(t,s,4)&&o(n,s,4)&&o(r,s,4)&&o(i,s,4))return new this([t[0],t[1],t[2],t[3],n[0],n[1],n[2],n[3],r[0],r[1],r[2],r[3],i[0],i[1],i[2],i[3]])}if(c(e)){let t=e.split(`,`);if(o(t,c,16))return this.cast(t.map(e=>parseFloat(e)))}if(i(e,`toMat4`,`function`))return this.cast(e.toMat4());if(i(e,`m00`,`number`)&&i(e,`m01`,`number`)&&i(e,`m02`,`number`)&&i(e,`m03`,`number`)&&i(e,`m10`,`number`)&&i(e,`m11`,`number`)&&i(e,`m12`,`number`)&&i(e,`m13`,`number`)&&i(e,`m20`,`number`)&&i(e,`m21`,`number`)&&i(e,`m22`,`number`)&&i(e,`m23`,`number`)&&i(e,`m30`,`number`)&&i(e,`m31`,`number`)&&i(e,`m32`,`number`)&&i(e,`m33`,`number`))return new this([e.m00,e.m01,e.m02,e.m03,e.m10,e.m11,e.m12,e.m13,e.m20,e.m21,e.m22,e.m23,e.m30,e.m31,e.m32,e.m33]);if(s(e))return new this([e,e,e,e,e,e,e,e,e,e,e,e,e,e,e,e])}}static is(e){return this.cast(e)!==void 0}static orthographic(...e){let t=o(e,s,6)?new H(e[0],e[1],e[2],e[3]):H.resolve(e[0]),n=o(e,s,6)?e[4]:e[1],r=o(e,s,6)?e[5]:e[2];return new this([2/(t.right-t.left),0,0,0,0,2/(t.top-t.bottom),0,0,0,0,2/(n-r),0,(t.left+t.right)/(t.left-t.right),(t.bottom+t.top)/(t.bottom-t.top),(n+r)/(n-r),1])}static perspective(e,t,n,r){let i=Math.tan(Math.PI*.5-.5*e),a=1/(n-r);return new this([i/t,0,0,0,0,i,0,0,0,0,(n+r)*a,-1,0,0,n*r*a*2,0])}static pointAt(e,t,n){let r=y.resolve(t).subtract(e).normalize(),i=r.multiply(y.resolve(n).dot(r)),a=y.resolve(n).subtract(i).normalize(),o=a.cross(r),s=y.resolve(e);return new this([o.x,o.y,o.z,0,a.x,a.y,a.z,0,r.x,r.y,r.z,0,s.x,s.y,s.z,1])}constructor(e=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]){n(e,s,16),this._raw=e}toArray(){return[this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33]}toNestetArray(){return[[this.m00,this.m01,this.m02,this.m03],[this.m10,this.m11,this.m12,this.m13],[this.m20,this.m21,this.m22,this.m23],[this.m30,this.m31,this.m32,this.m33]]}toJSON(){return{m00:this.m00,m01:this.m01,m02:this.m02,m03:this.m03,m10:this.m10,m11:this.m11,m12:this.m12,m13:this.m13,m20:this.m20,m21:this.m21,m22:this.m22,m23:this.m23,m30:this.m20,m31:this.m21,m32:this.m22,m33:this.m23}}toString(){return`${this.m00},${this.m01},${this.m02},${this.m03},${this.m10},${this.m11},${this.m12},${this.m13},${this.m20},${this.m21},${this.m22},${this.m23},${this.m30},${this.m31},${this.m32},${this.m33}`}get[Symbol.toStringTag](){return`Mat4`}[t](){return`Mat4 <${this.toString()}>`}clone(){return new e([this.m00,this.m01,this.m02,this.m03,this.m10,this.m11,this.m12,this.m13,this.m20,this.m21,this.m22,this.m23,this.m30,this.m31,this.m32,this.m33])}equals(...t){let n=e.resolveArgs(t);for(let e=0;e<this._raw.length;e++)if(this._raw[e]!=n._raw[e])return!1;return!0}add(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]+n._raw[e];return r}subtract(...t){let n=e.resolveArgs(t),r=new e;for(let e=0;e<this._raw.length;e++)r._raw[e]=this._raw[e]-n._raw[e];return r}multiply(...t){if(o(t,s,1)){let n=t[0];return new e([this.m00*n,this.m01*n,this.m02*n,this.m03*n,this.m10*n,this.m11*n,this.m12*n,this.m13*n,this.m20*n,this.m21*n,this.m22*n,this.m23*n,this.m30*n,this.m31*n,this.m32*n,this.m33*n])}let n=y.cast(t[0]);if(n!==void 0){let e=new y(n.x*this.m00+n.y*this.m10+n.z*this.m20+this.m30,n.x*this.m01+n.y*this.m11+n.z*this.m21+this.m31,n.x*this.m02+n.y*this.m12+n.z*this.m22+this.m32,n.x*this.m03+n.y*this.m13+n.z*this.m23+this.m33);return e.w==0?e:e.divide(e.w)}let r=e.resolveArgs(t);return new e([r.m00*this.m00+r.m01*this.m10+r.m02*this.m20+r.m03*this.m30,r.m00*this.m01+r.m01*this.m11+r.m02*this.m21+r.m03*this.m31,r.m00*this.m02+r.m01*this.m12+r.m02*this.m22+r.m03*this.m32,r.m00*this.m03+r.m01*this.m13+r.m02*this.m23+r.m03*this.m33,r.m10*this.m00+r.m11*this.m10+r.m12*this.m20+r.m13*this.m30,r.m10*this.m01+r.m11*this.m11+r.m12*this.m21+r.m13*this.m31,r.m10*this.m02+r.m11*this.m12+r.m12*this.m22+r.m13*this.m32,r.m10*this.m03+r.m11*this.m13+r.m12*this.m23+r.m13*this.m33,r.m20*this.m00+r.m21*this.m10+r.m22*this.m20+r.m23*this.m30,r.m20*this.m01+r.m21*this.m11+r.m22*this.m21+r.m23*this.m31,r.m20*this.m02+r.m21*this.m12+r.m22*this.m22+r.m23*this.m32,r.m20*this.m03+r.m21*this.m13+r.m22*this.m23+r.m23*this.m33,r.m30*this.m00+r.m31*this.m10+r.m32*this.m20+r.m33*this.m30,r.m30*this.m01+r.m31*this.m11+r.m32*this.m21+r.m33*this.m31,r.m30*this.m02+r.m31*this.m12+r.m32*this.m22+r.m33*this.m32,r.m30*this.m03+r.m31*this.m13+r.m32*this.m23+r.m33*this.m33])}translate(...e){let t=y.resolveArgs(e);return this.multiply([1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1])}rotateX(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([1,0,0,0,0,t,n,0,0,-n,t,0,0,0,0,1])}rotateY(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,0,-n,0,0,1,0,0,n,0,t,0,0,0,0,1])}rotateZ(e){let t=Math.cos(e),n=Math.sin(e);return this.multiply([t,n,0,0,-n,t,0,0,0,0,1,0,0,0,0,1])}rotate(...e){let t=y.resolveArgs(e);return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z)}scale(...e){let t=y.resolveArgs(e);return this.multiply([t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1])}inverse(){return new e([this.m00,this.m10,this.m20,0,this.m01,this.m11,this.m21,0,this.m02,this.m12,this.m22,0,-(this.m30*this.m00+this.m31*this.m10+this.m32*this.m20),-(this.m30*this.m01+this.m31*this.m11+this.m32*this.m21),-(this.m30*this.m02+this.m31*this.m12+this.m32*this.m22),1])}toMat3(){return[this.m00,this.m01,this.m03,this.m10,this.m11,this.m13,this.m30,this.m31,this.m33]}};let X;(function(e){function t(e,t=!1){let n=[];try{let t=O.resolve(e);n.push(t)}catch{}try{let t=k.resolve(e);n.push(t)}catch{}let r=t?1:0,i=n[r];if(i)return i;let a=n[r+1];if(a)return a}e.cast=t;function n(e,n=!1){let r=t(e,n);if(r!==void 0)return r;throw new d(`Color`,e)}e.resolve=n;function r(e,t=!1){return o(e,s,3)||o(e,s,4)?n(e,t):n(e[0],t)}e.resolveArgs=r})(X||={});var Z=class{origin=g.zero;localPosition;localRotation;get localRotationDegree(){return z(this.localRotation)}set localRotationDegree(e){this.localRotation=B(e)}localScale;get globalPosition(){let e=g.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=0,t=this;for(;t!==void 0;)e+=t.localRotation,t=t.parent;return e}get globalRotationDegree(){return z(this.globalRotation)}get globalScale(){let e=g.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(e,t,n,i){this.parent=i,r(t),this.localPosition=g.resolve(e),this.localRotation=t,this.localScale=g.resolve(n)}toString(){return`${this.localPosition.toString()}|${this.localRotation}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[t](){return`Transform2D <${this.toString()}>`}toMat3(){return new J().scale(this.localScale).rotate(this.localRotation).translate(this.localPosition)}toGlobalMat3(){let e=new J,t=this;for(;t!==void 0;)e=e.multiply(t.toMat3()),t=t.parent;return e}},Q=class{origin=y.zero;localPosition;localRotation;localScale;get globalPosition(){let e=y.zero,t=this;for(;t!==void 0;)e=e.add(t.localPosition).add(t.origin),t=t.parent;return e}get globalRotation(){let e=b.zero,t=this;for(;t!==void 0;)e=e.add(t.localRotation),t=t.parent;return e}get globalScale(){let e=y.one,t=this;for(;t!==void 0;)e=e.naiveMultiply(t.localScale),t=t.parent;return e}constructor(e,t,n,r){this.parent=r,this.localPosition=y.resolve(e),this.localRotation=b.resolve(t),this.localScale=y.resolve(n)}toString(){return`${this.localPosition.toString()}|${this.localRotation.toString()}|${this.localScale.toString()}`}get[Symbol.toStringTag](){return`Transform2D`}[t](){return`Transform2D <${this.toString()}>`}toMat4(){return new Y().scale(this.localScale).multiply(this.localRotation).translate(this.localPosition)}toGlobalMat4(){let e=new Y,t=this;for(;t!==void 0;)e=e.multiply(t.toMat4()),t=t.parent;return e}};export{X as AnyColor,H as BoundingBox,V as Circle,A as DJB2_OFFSET,m as EPSILON,M as FNV1_OFFSET,N as FNV1_PRIME,k as HSLA,_ as LinearFunction,I as MAX_ANGLE_DEGREE,J as Mat3,Y as Mat4,l as MathFunction,v as QuadFunction,b as Quaternion,O as RGBA,W as Rectangle,d as ResolveError,U as Size,Z as Transform2D,Q as Transform3D,G as Triangle,K as Triangle2D,q as Triangle3D,g as Vec2,y as Vec3,f as clamp,L as clampAngleDegree,R as clampAngleRadian,B as degreeToRadian,j as djb2,P as fnv1,T as hasHexNumberAlpha,E as hexNumberToRGB,D as hexNumberToRGBA,C as isHexNumber,h as lerp,p as logHypot,x as numberToRGB,S as numberToRGBA,z as radianToDegree,F as sdbm,u as signCharacter};
|