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