@ntf/math 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ var MathFunction = class {
3
3
  };
4
4
 
5
5
  // source/common/sign.ts
6
- function sign_char(num) {
6
+ function signCharacter(num) {
7
7
  if (num == 0)
8
8
  return void 0;
9
9
  if (num < 0)
@@ -14,35 +14,10 @@ function sign_char(num) {
14
14
  }
15
15
 
16
16
  // source/common/types.ts
17
- function check_number(obj) {
18
- return obj != null && typeof obj == "number" && !isNaN(obj) && isFinite(obj);
17
+ function checkNumber(value) {
18
+ return value !== null && typeof value == "number" && !isNaN(value) && isFinite(value);
19
19
  }
20
- function check_hex_digit(obj) {
21
- if (!check_string(obj) || obj.length != 1)
22
- return false;
23
- switch (obj.toUpperCase()) {
24
- default:
25
- return false;
26
- case "0":
27
- case "1":
28
- case "2":
29
- case "3":
30
- case "4":
31
- case "5":
32
- case "6":
33
- case "7":
34
- case "8":
35
- case "9":
36
- case "A":
37
- case "B":
38
- case "C":
39
- case "D":
40
- case "E":
41
- case "F":
42
- return true;
43
- }
44
- }
45
- function get_hex_part(string) {
20
+ function getHexValue(string) {
46
21
  let offset = 0;
47
22
  if (string.startsWith("#") || string.startsWith("$"))
48
23
  offset = 1;
@@ -50,112 +25,48 @@ function get_hex_part(string) {
50
25
  offset = 2;
51
26
  return string.substring(offset);
52
27
  }
53
- function check_hex(obj) {
54
- if (!check_string(obj))
28
+ function checkHex(value) {
29
+ if (!checkString(value))
55
30
  return false;
56
- const value = get_hex_part(obj).split("").map((char) => parseInt(char.toUpperCase(), 16));
57
- return check_number_array(value);
31
+ const hexValue = getHexValue(value).split("").map((char) => parseInt(char.toUpperCase(), 16));
32
+ return checkNumberArray(hexValue);
58
33
  }
59
- function check_string(obj) {
60
- return obj != null && typeof obj == "string" && obj.length > 0;
34
+ function checkString(value) {
35
+ return value !== null && typeof value == "string" && value.length > 0;
61
36
  }
62
- function check_array(obj, predicate, requiredLength) {
63
- if (!Array.isArray(obj)) return false;
64
- if (requiredLength && requiredLength != obj.length) return false;
65
- for (const item of obj)
66
- if (predicate && !predicate(item))
37
+ function checkArray(value, predicate, requiredLength) {
38
+ if (!Array.isArray(value)) return false;
39
+ if (typeof requiredLength == "number" && requiredLength !== value.length) return false;
40
+ for (const item of value)
41
+ if (typeof predicate == "function" && !predicate(item))
67
42
  return false;
68
43
  return true;
69
44
  }
70
- function check_number_array(obj, requiredLength) {
71
- return check_array(obj, check_number, requiredLength);
45
+ function checkNumberArray(value, requiredLength) {
46
+ return checkArray(value, checkNumber, requiredLength);
72
47
  }
73
- function check_string_array(obj, requiredLength) {
74
- return check_array(obj, check_string, requiredLength);
48
+ function checkStringArray(value, requiredLength) {
49
+ return checkArray(value, checkString, requiredLength);
75
50
  }
76
- function has_property(obj, name, type) {
77
- return obj != null && typeof obj == "object" && name in obj && typeof obj[name] == type;
51
+ function hasProperty(value, propertyName, type) {
52
+ return value !== null && typeof value == "object" && propertyName in value && typeof value[propertyName] == type;
78
53
  }
54
+ var NodeJSCustomInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
79
55
 
80
56
  // source/common/error.ts
81
57
  var ResolveError = class extends Error {
58
+ /**
59
+ * Create a resolve exception
60
+ * @param target The target type name
61
+ * @param value A value
62
+ */
82
63
  constructor(target, value) {
83
- super(`can't resolve ${value} to ${target}`);
64
+ super(`Can't resolve ${value} to ${target}`);
84
65
  this.target = target;
85
66
  this.value = value;
86
67
  }
87
68
  };
88
69
 
89
- // source/geometry/size.ts
90
- var Size = class _Size {
91
- width;
92
- height;
93
- get aspectRatio() {
94
- return this.height / this.width;
95
- }
96
- get area() {
97
- return this.width * this.height;
98
- }
99
- get perimeter() {
100
- return this.width + this.width + this.height + this.height;
101
- }
102
- static resolve(a) {
103
- const value = this.cast(a);
104
- if (typeof value != "undefined")
105
- return value;
106
- throw new ResolveError("Square", a);
107
- }
108
- static cast(a) {
109
- if (a == null || typeof a == "undefined")
110
- return void 0;
111
- if (check_number_array(a, 2))
112
- return new this(a[0], a[1]);
113
- if (has_property(a, "width", "number") && has_property(a, "height", "number"))
114
- return new this(a.width, a.height);
115
- if (check_string(a)) {
116
- const parts = a.split("x").map((v) => parseFloat(v));
117
- if (check_number_array(parts, 2))
118
- return this.cast(parts);
119
- }
120
- if (check_number(a))
121
- return new this(a, a);
122
- return void 0;
123
- }
124
- static is(a) {
125
- return typeof this.cast(a) != "undefined";
126
- }
127
- constructor(width, height) {
128
- if (!check_number(width))
129
- throw new TypeError("expected number for width");
130
- if (!check_number(height))
131
- throw new TypeError("expected number for height");
132
- this.width = width;
133
- this.height = height;
134
- }
135
- toArray() {
136
- return [this.width, this.height];
137
- }
138
- toString() {
139
- return `${this.width}x${this.height}`;
140
- }
141
- toJSON() {
142
- return {
143
- width: this.width,
144
- height: this.height
145
- };
146
- }
147
- clone() {
148
- return new _Size(this.width, this.height);
149
- }
150
- equals(square) {
151
- const s = _Size.resolve(square);
152
- return this.width == s.width && this.height == s.height;
153
- }
154
- toVec2() {
155
- return [this.width, this.height];
156
- }
157
- };
158
-
159
70
  // source/utils.ts
160
71
  function clamp(value, min, max) {
161
72
  if (value <= min)
@@ -164,7 +75,7 @@ function clamp(value, min, max) {
164
75
  return max;
165
76
  return value;
166
77
  }
167
- function log_hypot(a, b) {
78
+ function logHypot(a, b) {
168
79
  const a_abs = Math.abs(a);
169
80
  const b_abs = Math.abs(b);
170
81
  if (a == 0)
@@ -177,41 +88,43 @@ function log_hypot(a, b) {
177
88
  return 0.5 * Math.log(_a * _a + _b * _b) + Math.LN2;
178
89
  }
179
90
  var EPSILON = 1e-16;
91
+ var lerp = (a, b, t) => ((typeof a == "number" ? 1 : 1n) - t) * a + t * b;
180
92
 
181
- // source/vectors/vec3.ts
182
- var Vec3 = class _Vec3 {
93
+ // source/vectors/vec2.ts
94
+ var Vec2 = class _Vec2 {
183
95
  x;
184
96
  y;
185
- z;
186
97
  w;
187
98
  static resolve(a) {
188
99
  const value = this.cast(a);
189
100
  if (typeof value != "undefined")
190
101
  return value;
191
- throw new ResolveError("Vec3", a);
102
+ throw new ResolveError("Vec2", a);
192
103
  }
193
104
  static cast(a) {
194
105
  if (a == null || typeof a == "undefined")
195
106
  return void 0;
196
- if (check_number_array(a, 3) || check_number_array(a, 4))
197
- return new this(a[0], a[1], a[2], check_number(a[3]) ? a[3] : void 0);
198
- if (has_property(a, "x", "number") && has_property(a, "y", "number") && has_property(a, "z", "number"))
199
- return new this(a.x, a.y, a.z, has_property(a, "w", "number") ? a.w : void 0);
200
- if (check_string(a)) {
201
- const [sxyz, sw] = a.split(";");
202
- if (check_string(sxyz)) {
203
- const parts = sxyz.split(",");
204
- if (check_string_array(parts, 3))
205
- return new this(parseFloat(parts[0]), parseFloat(parts[1]), parseFloat(parts[2]), check_string(sw) ? parseFloat(sw) : void 0);
107
+ if (checkNumberArray(a, 2) || checkNumberArray(a, 3))
108
+ return new this(a[0], a[1], checkNumber(a[2]) ? a[2] : void 0);
109
+ if (hasProperty(a, "toVec2", "function"))
110
+ return this.cast(a.toVec2());
111
+ if (hasProperty(a, "x", "number") && hasProperty(a, "y", "number"))
112
+ return new this(a.x, a.y, hasProperty(a, "w", "number") ? a.w : void 0);
113
+ if (checkString(a)) {
114
+ const [sxy, sw] = a.split(";");
115
+ if (checkString(sxy)) {
116
+ const parts = sxy.split(",");
117
+ if (checkStringArray(parts, 2))
118
+ return new this(parseFloat(parts[0]), parseFloat(parts[1]), checkString(sw) ? parseFloat(sw) : void 0);
206
119
  }
207
120
  }
208
- if (check_number(a))
209
- return new this(a, a, a);
121
+ if (checkNumber(a))
122
+ return new this(a, a);
210
123
  return void 0;
211
124
  }
212
125
  static resolveArgs(args) {
213
- if (check_number_array(args, 3))
214
- return new this(args[0], args[1], args[2]);
126
+ if (checkNumberArray(args, 2))
127
+ return new this(args[0], args[1]);
215
128
  return this.resolve(args[0]);
216
129
  }
217
130
  static is(a) {
@@ -220,63 +133,79 @@ var Vec3 = class _Vec3 {
220
133
  static fromPoints(a, b) {
221
134
  const veca = this.resolve(a);
222
135
  const vecb = this.resolve(b);
223
- return new this(vecb.x - veca.x, vecb.y - veca.y, vecb.z - veca.z);
136
+ return new this(vecb.x - veca.x, vecb.y - veca.y);
224
137
  }
225
138
  static clamp(value, min, max) {
226
139
  const a = this.resolve(value), b = this.resolve(min), c = this.resolve(max);
227
140
  return new this(
228
141
  clamp(a.x, b.x, c.x),
229
- clamp(a.y, b.y, c.y),
230
- clamp(a.z, b.z, c.z)
142
+ clamp(a.y, b.y, c.y)
231
143
  );
232
144
  }
233
- static intersectPlane(planeP, planeN, lineStart, lineEnd, t) {
234
- planeN = this.resolve(planeN).normalize();
235
- const plane_d = -this.resolve(planeN).dot(planeP);
236
- const ad = this.resolve(lineStart).dot(planeN);
237
- const bd = this.resolve(lineEnd).dot(planeN);
238
- t = (-plane_d - ad) / (bd - ad);
239
- const lineStartToEnd = this.resolve(lineEnd).subtract(lineStart);
240
- const linetoIntersect = lineStartToEnd.multiply(t);
241
- return _Vec3.resolve(lineStart).add(linetoIntersect);
145
+ static get zero() {
146
+ return new this(0, 0);
242
147
  }
243
- constructor(x = 0, y = 0, z = 0, w = 1) {
244
- if (!check_number(x))
148
+ static get one() {
149
+ return new this(1, 1);
150
+ }
151
+ constructor(x, y, w = 1) {
152
+ if (!checkNumber(x))
245
153
  throw new TypeError("expected number for x");
246
- if (!check_number(y))
154
+ if (!checkNumber(y))
247
155
  throw new TypeError("expected number for y");
248
- if (!check_number(z))
249
- throw new TypeError("expected number for z");
250
- if (!check_number(w))
156
+ if (!checkNumber(w))
251
157
  throw new TypeError("expected number for w");
252
158
  this.x = x;
253
159
  this.y = y;
254
- this.z = z;
255
160
  this.w = w;
256
161
  }
257
- toArray(w = false) {
258
- return w ? [this.x, this.y, this.z] : [this.x, this.y, this.z, this.w];
162
+ toArray(w = this.w !== 1) {
163
+ return w ? [this.x, this.y, this.w] : [this.x, this.y];
259
164
  }
260
165
  toJSON() {
261
166
  return {
262
167
  x: this.x,
263
168
  y: this.y,
264
- z: this.z,
265
169
  w: this.w
266
170
  };
267
171
  }
268
- toString(w = false) {
269
- return w ? `${this.x},${this.y},${this.z}` : `${this.x},${this.y},${this.z};${this.w}`;
172
+ toString(w = this.w !== 1) {
173
+ return w ? `${this.x},${this.y};${this.w}` : `${this.x},${this.y}`;
270
174
  }
271
- toVec2() {
272
- return [this.x, this.y, this.w];
175
+ get [Symbol.toStringTag]() {
176
+ return "Vec2";
177
+ }
178
+ [NodeJSCustomInspect]() {
179
+ return `Vec2 <${this.toString()}>`;
180
+ }
181
+ toSize() {
182
+ return [this.x, this.y];
183
+ }
184
+ toVec3(z = 0) {
185
+ return [this.x, this.y, z, this.w];
186
+ }
187
+ toRGB() {
188
+ const vec = this.normalize();
189
+ return [vec.x, vec.y, vec.w];
190
+ }
191
+ toRGBA() {
192
+ const vec = this.normalize();
193
+ return [vec.x, vec.y, vec.w, 1];
194
+ }
195
+ toHSL() {
196
+ const vec = this.normalize();
197
+ return [vec.x, vec.y, vec.w];
198
+ }
199
+ toHSLA() {
200
+ const vec = this.normalize();
201
+ return [vec.x, vec.y, vec.w, 1];
273
202
  }
274
203
  clone() {
275
- return new _Vec3(this.x, this.y, this.z, this.w);
204
+ return new _Vec2(this.x, this.y, this.w);
276
205
  }
277
- equals(vec) {
278
- const a = _Vec3.resolve(vec);
279
- return this.x == a.x && this.y == a.y && this.z == a.z;
206
+ equals(...args) {
207
+ const a = _Vec2.resolveArgs(args);
208
+ return this.x == a.x && this.y == a.y;
280
209
  }
281
210
  setX(x) {
282
211
  this.x = x;
@@ -286,319 +215,125 @@ var Vec3 = class _Vec3 {
286
215
  this.y = y;
287
216
  return this;
288
217
  }
289
- setZ(z) {
290
- this.z = z;
218
+ setW(w) {
219
+ this.w = w;
291
220
  return this;
292
221
  }
293
222
  set(...args) {
294
- const vec = _Vec3.resolveArgs(args);
295
- return this.setX(vec.x).setY(vec.y).setZ(vec.z);
223
+ const vec = _Vec2.resolveArgs(args);
224
+ return this.setX(vec.x).setY(vec.y);
296
225
  }
297
226
  add(...args) {
298
- const vec = _Vec3.resolveArgs(args);
299
- return new _Vec3(
227
+ const vec = _Vec2.resolveArgs(args);
228
+ return new _Vec2(
300
229
  this.x + vec.x,
301
- this.y + vec.y,
302
- this.z + vec.z
230
+ this.y + vec.y
303
231
  );
304
232
  }
305
233
  offset(...args) {
306
- const vec = _Vec3.resolveArgs(args);
234
+ const vec = _Vec2.resolveArgs(args);
307
235
  this.x += vec.x;
308
236
  this.y += vec.y;
309
- this.z += vec.z;
310
237
  return this;
311
238
  }
312
239
  subtract(...args) {
313
- const vec = _Vec3.resolveArgs(args);
314
- return new _Vec3(
240
+ const vec = _Vec2.resolveArgs(args);
241
+ return new _Vec2(
315
242
  this.x - vec.x,
316
- this.y - vec.y,
317
- this.z - vec.z
243
+ this.y - vec.y
318
244
  );
319
245
  }
320
246
  multiply(scalar) {
321
- return new _Vec3(
247
+ return new _Vec2(
322
248
  this.x * scalar,
323
- this.y * scalar,
324
- this.z * scalar
249
+ this.y * scalar
325
250
  );
326
251
  }
327
252
  naiveMultiply(...args) {
328
- const vec = _Vec3.resolveArgs(args);
329
- return new _Vec3(
253
+ const vec = _Vec2.resolveArgs(args);
254
+ return new _Vec2(
330
255
  this.x * vec.x,
331
- this.y * vec.y,
332
- this.z * vec.z
256
+ this.y * vec.y
333
257
  );
334
258
  }
335
259
  divide(...args) {
336
- if (check_number_array(args, 1))
337
- return new _Vec3(
260
+ if (checkNumberArray(args, 1))
261
+ return new _Vec2(
338
262
  this.x / args[0],
339
- this.y / args[0],
340
- this.z / args[0]
263
+ this.y / args[0]
341
264
  );
342
- const vec = _Vec3.resolveArgs(args);
343
- return new _Vec3(
265
+ const vec = _Vec2.resolveArgs(args);
266
+ return new _Vec2(
344
267
  this.x / vec.x,
345
- this.y / vec.y,
346
- this.z / vec.z
268
+ this.y / vec.y
347
269
  );
348
270
  }
349
271
  dot(...args) {
350
- const vec = _Vec3.resolveArgs(args);
351
- return this.x * vec.x + this.y * vec.y + this.z * vec.z;
352
- }
353
- cross(...args) {
354
- const vec = _Vec3.resolveArgs(args);
355
- return new _Vec3(
356
- this.y * vec.z - this.z * vec.y,
357
- this.z * vec.x - this.x * vec.z,
358
- this.x * vec.y - this.y * vec.x
359
- );
272
+ const vec = _Vec2.resolveArgs(args);
273
+ return this.x * vec.x + this.y * vec.y;
360
274
  }
361
275
  distance(...args) {
362
- const vec = _Vec3.resolveArgs(args);
363
- return Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2) + Math.pow(vec.z - this.z, 2);
276
+ const vec = _Vec2.resolveArgs(args);
277
+ return Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2);
364
278
  }
365
279
  distanceSquare(...args) {
366
- const vec = _Vec3.resolveArgs(args);
367
- return Math.sqrt(Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2) + Math.pow(vec.z - this.z, 2));
280
+ const vec = _Vec2.resolveArgs(args);
281
+ return Math.sqrt(Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2));
368
282
  }
369
283
  length() {
370
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
284
+ return Math.sqrt(this.x * this.x + this.y * this.y);
285
+ }
286
+ cartesianify() {
287
+ return new _Vec2(
288
+ this.x * Math.cos(this.y),
289
+ this.x * Math.sin(this.y)
290
+ );
291
+ }
292
+ polarify() {
293
+ return new _Vec2(
294
+ Math.sqrt(this.x * this.x + this.y * this.y),
295
+ Math.atan(this.y / this.x)
296
+ );
371
297
  }
372
298
  normalize() {
373
299
  const length = this.length();
374
- if (length == 0) return new _Vec3();
375
- return new _Vec3(
300
+ if (length == 0) return _Vec2.zero;
301
+ return new _Vec2(
376
302
  this.x / length,
377
303
  this.y / length,
378
- this.z / length
304
+ this.w / length
379
305
  );
380
306
  }
381
307
  invert() {
382
308
  return this.multiply(-1);
383
309
  }
384
310
  round() {
385
- return new _Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z), Math.round(this.w));
311
+ return new _Vec2(Math.round(this.x), Math.round(this.y), Math.round(this.w));
386
312
  }
387
313
  };
388
314
 
389
- // source/vectors/vec2.ts
390
- var Vec2 = class _Vec2 {
391
- x;
392
- y;
393
- w;
394
- static resolve(a) {
395
- const value = this.cast(a);
396
- if (typeof value != "undefined")
397
- return value;
398
- throw new ResolveError("Vec2", a);
399
- }
400
- static cast(a) {
401
- if (a == null || typeof a == "undefined")
402
- return void 0;
403
- if (check_number_array(a, 2) || check_number_array(a, 3))
404
- return new this(a[0], a[1], check_number(a[2]) ? a[2] : void 0);
405
- if (has_property(a, "x", "number") && has_property(a, "y", "number"))
406
- return new this(a.x, a.y, has_property(a, "w", "number") ? a.w : void 0);
407
- if (check_string(a)) {
408
- const [sxy, sw] = a.split(";");
409
- if (check_string(sxy)) {
410
- const parts = sxy.split(",");
411
- if (check_string_array(parts, 2))
412
- return new this(parseFloat(parts[0]), parseFloat(parts[1]), check_string(sw) ? parseFloat(sw) : void 0);
413
- }
414
- }
415
- if (check_number(a))
416
- return new this(a, a);
417
- return void 0;
418
- }
419
- static resolveArgs(args) {
420
- if (check_number_array(args, 2))
421
- return new this(args[0], args[1]);
422
- return this.resolve(args[0]);
423
- }
424
- static is(a) {
425
- return typeof this.cast(a) != "undefined";
426
- }
315
+ // source/algebra/linear.ts
316
+ var LinearFunction = class extends MathFunction {
317
+ /**
318
+ * The factor of the linear function
319
+ */
320
+ m;
321
+ /**
322
+ * The height of the linear function
323
+ */
324
+ b;
325
+ /**
326
+ * Create a linear function from two points
327
+ * @param a A point
328
+ * @param b A point
329
+ * @returns A linear function from two points
330
+ */
427
331
  static fromPoints(a, b) {
428
- const veca = this.resolve(a);
429
- const vecb = this.resolve(b);
430
- return new this(vecb.x - veca.x, vecb.y - veca.y);
431
- }
432
- static clamp(value, min, max) {
433
- const a = this.resolve(value), b = this.resolve(min), c = this.resolve(max);
434
- return new this(
435
- clamp(a.x, b.x, c.x),
436
- clamp(a.y, b.y, c.y)
437
- );
438
- }
439
- constructor(x = 0, y = 0, w = 1) {
440
- if (!check_number(x))
441
- throw new TypeError("expected number for x");
442
- if (!check_number(y))
443
- throw new TypeError("expected number for y");
444
- if (!check_number(w))
445
- throw new TypeError("expected number for w");
446
- this.x = x;
447
- this.y = y;
448
- this.w = w;
449
- }
450
- toArray(w = false) {
451
- return w ? [this.x, this.y] : [this.x, this.y, this.w];
452
- }
453
- toJSON() {
454
- return {
455
- x: this.x,
456
- y: this.y,
457
- w: this.w
458
- };
459
- }
460
- toString(w = false) {
461
- return w ? `${this.x},${this.y}` : `${this.x},${this.y};${this.w}`;
462
- }
463
- toSquare() {
464
- return new Size(this.x, this.y);
465
- }
466
- toVec3(z) {
467
- return new Vec3(this.x, this.y, z, this.w);
468
- }
469
- clone() {
470
- return new _Vec2(this.x, this.y, this.w);
471
- }
472
- equals(vec) {
473
- const a = _Vec2.resolve(vec);
474
- return this.x == a.x && this.y == a.y;
475
- }
476
- setX(x) {
477
- this.x = x;
478
- return this;
479
- }
480
- setY(y) {
481
- this.y = y;
482
- return this;
483
- }
484
- setW(w) {
485
- this.w = w;
486
- return this;
487
- }
488
- set(...args) {
489
- const vec = _Vec2.resolveArgs(args);
490
- return this.setX(vec.x).setY(vec.y);
491
- }
492
- add(...args) {
493
- const vec = _Vec2.resolveArgs(args);
494
- return new _Vec2(
495
- this.x + vec.x,
496
- this.y + vec.y
497
- );
498
- }
499
- offset(...args) {
500
- const vec = _Vec2.resolveArgs(args);
501
- this.x += vec.x;
502
- this.y += vec.y;
503
- return this;
504
- }
505
- subtract(...args) {
506
- const vec = _Vec2.resolveArgs(args);
507
- return new _Vec2(
508
- this.x - vec.x,
509
- this.y - vec.y
510
- );
511
- }
512
- multiply(scalar) {
513
- return new _Vec2(
514
- this.x * scalar,
515
- this.y * scalar
516
- );
517
- }
518
- naiveMultiply(...args) {
519
- const vec = _Vec2.resolveArgs(args);
520
- return new _Vec2(
521
- this.x * vec.x,
522
- this.y * vec.y
523
- );
524
- }
525
- divide(...args) {
526
- if (check_number_array(args, 1))
527
- return new _Vec2(
528
- this.x / args[0],
529
- this.y / args[0]
530
- );
531
- const vec = _Vec2.resolveArgs(args);
532
- return new _Vec2(
533
- this.x / vec.x,
534
- this.y / vec.y
535
- );
536
- }
537
- dot(...args) {
538
- const vec = _Vec2.resolveArgs(args);
539
- return this.x * vec.x + this.y * vec.y;
540
- }
541
- distance(...args) {
542
- const vec = _Vec2.resolveArgs(args);
543
- return Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2);
544
- }
545
- distanceSquare(...args) {
546
- const vec = _Vec2.resolveArgs(args);
547
- return Math.sqrt(Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2));
548
- }
549
- length() {
550
- return Math.sqrt(this.x * this.x + this.y * this.y);
551
- }
552
- cartesianify() {
553
- return new _Vec2(
554
- this.x * Math.cos(this.y),
555
- this.x * Math.sin(this.y)
556
- );
557
- }
558
- polarify() {
559
- return new _Vec2(
560
- Math.sqrt(this.x * this.x + this.y * this.y),
561
- Math.atan(this.y / this.x)
562
- );
563
- }
564
- normalize() {
565
- const length = this.length();
566
- if (length == 0) return new _Vec2();
567
- return new _Vec2(
568
- this.x / length,
569
- this.y / length
570
- );
571
- }
572
- invert() {
573
- return this.multiply(-1);
574
- }
575
- round() {
576
- return new _Vec2(Math.round(this.x), Math.round(this.y), Math.round(this.w));
577
- }
578
- };
579
-
580
- // source/algebra/linear.ts
581
- var LinearFunction = class extends MathFunction {
582
- /**
583
- * The factor of the linear function
584
- */
585
- m;
586
- /**
587
- * The height of the linear function
588
- */
589
- b;
590
- /**
591
- * Create a linear function from two points
592
- * @param a A point
593
- * @param b A point
594
- * @returns A linear function from two points
595
- */
596
- static fromPoints(a, b) {
597
- const veca = Vec2.resolve(a);
598
- const vecb = Vec2.resolve(b);
599
- const m = (vecb.y - veca.y) / (vecb.x - veca.x);
600
- const h = -m * veca.x + veca.y;
601
- return new this(m, h);
332
+ const veca = Vec2.resolve(a);
333
+ const vecb = Vec2.resolve(b);
334
+ const m = (vecb.y - veca.y) / (vecb.x - veca.x);
335
+ const h = -m * veca.x + veca.y;
336
+ return new this(m, h);
602
337
  }
603
338
  /**
604
339
  * Create a linear function with a factor and height
@@ -607,30 +342,36 @@ var LinearFunction = class extends MathFunction {
607
342
  */
608
343
  constructor(m, b) {
609
344
  super();
610
- if (!check_number(m))
345
+ if (!checkNumber(m))
611
346
  throw new TypeError("expected number for m");
612
- if (!check_number(b))
347
+ if (!checkNumber(b))
613
348
  throw new TypeError("expected number for b");
614
349
  this.m = m;
615
350
  this.b = b;
616
351
  }
617
352
  get(x) {
618
- if (!check_number(x))
353
+ if (!checkNumber(x))
619
354
  throw new TypeError("expected number for x");
620
355
  return this.m;
621
356
  }
622
357
  roots() {
623
358
  const x = -this.b / this.m;
624
359
  if (!isNaN(x))
625
- return [new Vec2(x)];
360
+ return [new Vec2(x, 0)];
626
361
  return [];
627
362
  }
628
363
  toString() {
629
- const bsign = sign_char(this.b);
364
+ const bsign = signCharacter(this.b);
630
365
  if (bsign)
631
366
  return `f(x) = ${this.m} * x ${bsign} ${Math.abs(this.b)}`;
632
367
  return `f(x) = ${this.m} * x`;
633
368
  }
369
+ get [Symbol.toStringTag]() {
370
+ return "LinearFunction";
371
+ }
372
+ [NodeJSCustomInspect]() {
373
+ return `LinearFunction <${this.toString()}>`;
374
+ }
634
375
  };
635
376
 
636
377
  // source/algebra/quad.ts
@@ -643,20 +384,20 @@ var QuadFunction = class extends MathFunction {
643
384
  }
644
385
  constructor(a, b, c) {
645
386
  super();
646
- if (!check_number(a))
387
+ if (!checkNumber(a))
647
388
  throw new TypeError("expected number for a");
648
389
  if (a == 0)
649
390
  throw new TypeError("a cannot be 0");
650
- if (!check_number(b))
391
+ if (!checkNumber(b))
651
392
  throw new TypeError("expected number for b");
652
- if (!check_number(c))
393
+ if (!checkNumber(c))
653
394
  throw new TypeError("expected number for c");
654
395
  this.a = a;
655
396
  this.b = b;
656
397
  this.c = c;
657
398
  }
658
399
  get(x) {
659
- if (!check_number(x))
400
+ if (!checkNumber(x))
660
401
  throw new TypeError("expected number for x");
661
402
  return this.a * x * x + this.b * x + this.c;
662
403
  }
@@ -666,17 +407,17 @@ var QuadFunction = class extends MathFunction {
666
407
  const n0 = (-this.b + Math.sqrt(discriminant)) / (2 * this.a);
667
408
  const n1 = (-this.b + Math.sqrt(discriminant)) / (2 * this.a);
668
409
  if (!isNaN(n0))
669
- roots.push(new Vec2(n0));
410
+ roots.push(new Vec2(n0, 0));
670
411
  if (!isNaN(n1) && n0 != n1)
671
- roots.push(new Vec2(n1));
412
+ roots.push(new Vec2(n1, 0));
672
413
  return roots;
673
414
  }
674
415
  toString(type = "standard") {
675
416
  switch (type) {
676
417
  default:
677
418
  case "standard": {
678
- const bsign = sign_char(this.b);
679
- const csign = sign_char(this.c);
419
+ const bsign = signCharacter(this.b);
420
+ const csign = signCharacter(this.c);
680
421
  if (bsign && csign)
681
422
  return `f(x) = ${this.a}x^2 ${bsign} ${Math.abs(this.b)}x ${csign} ${Math.abs(this.c)}`;
682
423
  if (bsign)
@@ -685,17 +426,18 @@ var QuadFunction = class extends MathFunction {
685
426
  }
686
427
  }
687
428
  }
429
+ get [Symbol.toStringTag]() {
430
+ return "QuadFunction";
431
+ }
432
+ [NodeJSCustomInspect]() {
433
+ return `QuadFunction <${this.toString()}>`;
434
+ }
688
435
  };
689
436
 
690
- // source/common/string.ts
691
- function stringify(value) {
692
- return value != null && typeof value == "object" && "toString" in value && typeof value.toString == "function" ? value.toString() : String(value);
693
- }
694
-
695
437
  // source/crypto/hash.ts
696
438
  var DJB2_OFFSET = 5381n;
697
439
  function djb2(value) {
698
- const string = stringify(value);
440
+ const string = String(value);
699
441
  let hash = DJB2_OFFSET;
700
442
  for (let i = 0; i < string.length; i++) {
701
443
  hash = (hash << 5n) + hash + BigInt(string.charCodeAt(i));
@@ -705,7 +447,7 @@ function djb2(value) {
705
447
  var FNV1_OFFSET = 14695981039346656037n;
706
448
  var FNV1_PRIME = 1099511628211n;
707
449
  function fnv1(value) {
708
- const string = stringify(value);
450
+ const string = String(value);
709
451
  let hash = FNV1_OFFSET;
710
452
  for (let i = 0; i < string.length; i++) {
711
453
  hash *= FNV1_PRIME;
@@ -714,7 +456,7 @@ function fnv1(value) {
714
456
  return hash;
715
457
  }
716
458
  function sdbm(value) {
717
- const string = stringify(value);
459
+ const string = String(value);
718
460
  let hash = 0n;
719
461
  for (let i = 0; i < string.length; i++) {
720
462
  hash = BigInt(string.charCodeAt(i)) + (hash << 6n) + (hash << 16n) - hash;
@@ -1031,14 +773,23 @@ var MD2 = class _MD2 {
1031
773
  this._transform(this._checksum);
1032
774
  return this._state.slice();
1033
775
  }
776
+ toString() {
777
+ return "";
778
+ }
779
+ get [Symbol.toStringTag]() {
780
+ return "MD2";
781
+ }
782
+ [NodeJSCustomInspect]() {
783
+ return `MD2 <${this.toString()}>`;
784
+ }
1034
785
  };
1035
786
 
1036
787
  // source/geometry/angle.ts
1037
788
  var MAX_ANGLE_DEGREE = 360;
1038
- var cap_angle_degree = (angle) => angle % MAX_ANGLE_DEGREE;
1039
- var cap_angle_radian = (angle) => cap_angle_degree(degree_to_radian(angle));
1040
- var radian_to_degree = (angle) => angle * (180 / Math.PI);
1041
- var degree_to_radian = (angle) => angle * (Math.PI / 180);
789
+ var clampAngleDegree = (angle) => angle % MAX_ANGLE_DEGREE;
790
+ var clampAngleRadian = (angle) => clampAngleDegree(degreeToRadian(angle));
791
+ var radianToDegree = (angle) => angle * (180 / Math.PI);
792
+ var degreeToRadian = (angle) => angle * (Math.PI / 180);
1042
793
 
1043
794
  // source/geometry/circle.ts
1044
795
  var Circle = class _Circle {
@@ -1074,19 +825,28 @@ var Circle = class _Circle {
1074
825
  return value;
1075
826
  throw new ResolveError("Circle", a);
1076
827
  }
828
+ static resolveArgs(args) {
829
+ if (checkNumberArray(args, 3))
830
+ return new this([args[0], args[1]], args[2]);
831
+ if (args.length === 2)
832
+ return new this(args[0], args[1]);
833
+ return this.resolve(args[0]);
834
+ }
1077
835
  static cast(a) {
1078
836
  if (a == null || typeof a == "undefined")
1079
837
  return void 0;
1080
- if (check_number_array(a, 3))
838
+ if (checkNumberArray(a, 3))
1081
839
  return new this([a[0], a[1]], a[2]);
1082
- if (check_number_array(a, 4)) {
840
+ if (checkNumberArray(a, 4)) {
1083
841
  const c = new this([a[0], a[1]], a[3]);
1084
842
  c.w = a[2];
1085
843
  return c;
1086
844
  }
1087
- if (has_property(a, "x", "number") && has_property(a, "y", "number") && has_property(a, "radius", "number"))
1088
- return new this(has_property(a, "w", "number") ? [a.x, a.y, a.w] : [a.x, a.y], a.radius);
1089
- if (check_string(a)) {
845
+ if (hasProperty(a, "toCircle", "function"))
846
+ return this.cast(a.toCircle());
847
+ if (hasProperty(a, "x", "number") && hasProperty(a, "y", "number") && hasProperty(a, "radius", "number"))
848
+ return new this(hasProperty(a, "w", "number") ? [a.x, a.y, a.w] : [a.x, a.y], a.radius);
849
+ if (checkString(a)) {
1090
850
  const [spos, sradius] = a.split("|");
1091
851
  const pos = Vec2.cast(spos);
1092
852
  if (typeof pos == "undefined")
@@ -1102,7 +862,7 @@ var Circle = class _Circle {
1102
862
  }
1103
863
  constructor(position, radius) {
1104
864
  this.position = Vec2.resolve(position);
1105
- if (!check_number(radius))
865
+ if (!checkNumber(radius))
1106
866
  throw new TypeError("expected number for radius");
1107
867
  this.radius = radius;
1108
868
  }
@@ -1118,22 +878,246 @@ var Circle = class _Circle {
1118
878
  toString() {
1119
879
  return `${this.position.toString()}|${this.radius}`;
1120
880
  }
881
+ get [Symbol.toStringTag]() {
882
+ return "Circle";
883
+ }
884
+ [NodeJSCustomInspect]() {
885
+ return `Circle <${this.toString()}>`;
886
+ }
1121
887
  clone() {
1122
888
  return new _Circle(this.position.clone(), this.radius);
1123
889
  }
1124
- equals(circle) {
1125
- const c = _Circle.resolve(circle);
890
+ toVec2() {
891
+ return [this.x, this.y, this.w];
892
+ }
893
+ equals(...args) {
894
+ const c = _Circle.resolveArgs(args);
1126
895
  return c.position.equals(c.position) && this.radius == c.radius;
1127
896
  }
1128
- inside(a) {
1129
- const circle = _Circle.resolve(a);
897
+ inside(...args) {
898
+ const circle = _Circle.resolveArgs(args);
1130
899
  const distX = circle.x - this.x;
1131
900
  const distY = circle.y - this.y;
1132
901
  const dist = Math.sqrt(distX * distX + (distY + distY));
1133
902
  return dist <= this.radius + circle.radius;
1134
903
  }
1135
- insidePoint(a) {
1136
- return this.position.distance(a) <= this.radius;
904
+ insidePoint(...args) {
905
+ return this.position.distance(Vec2.resolveArgs(args)) <= this.radius;
906
+ }
907
+ };
908
+
909
+ // source/geometry/bbox.ts
910
+ var BoundingBox = class _BoundingBox {
911
+ left;
912
+ right;
913
+ top;
914
+ bottom;
915
+ get width() {
916
+ return this.right - this.left;
917
+ }
918
+ set width(val) {
919
+ this.right = this.left + val;
920
+ }
921
+ get height() {
922
+ return this.bottom - this.top;
923
+ }
924
+ set height(val) {
925
+ this.bottom = this.top + val;
926
+ }
927
+ get x() {
928
+ return this.left;
929
+ }
930
+ set x(x) {
931
+ this.left = x;
932
+ }
933
+ get y() {
934
+ return this.top;
935
+ }
936
+ set y(y) {
937
+ this.top = y;
938
+ }
939
+ w = 1;
940
+ static resolve(a) {
941
+ const value = this.cast(a);
942
+ if (typeof value != "undefined")
943
+ return value;
944
+ throw new ResolveError("BoundingBox", a);
945
+ }
946
+ static resolveArgs(args) {
947
+ if (checkNumberArray(args, 4))
948
+ return new this(args[0], args[1], args[2], args[3]);
949
+ return this.resolve(args[0]);
950
+ }
951
+ static cast(a) {
952
+ if (a == null || typeof a == "undefined")
953
+ return void 0;
954
+ if (checkNumberArray(a, 4))
955
+ return new this(a[0], a[1], a[2], a[3]);
956
+ if (hasProperty(a, "toBoundingBox", "function"))
957
+ return this.cast(a.toBoundingBox());
958
+ if (hasProperty(a, "left", "number") && hasProperty(a, "right", "number") && hasProperty(a, "top", "number") && hasProperty(a, "bottom", "number"))
959
+ return new this(a.left, a.right, a.top, a.bottom);
960
+ if (checkString(a)) {
961
+ const parts = a.split(",");
962
+ if (checkStringArray(parts, 4))
963
+ return this.cast(parts.map((v) => parseFloat(v)));
964
+ }
965
+ return void 0;
966
+ }
967
+ static is(a) {
968
+ return typeof this.cast(a) != "undefined";
969
+ }
970
+ constructor(left, right, top, bottom) {
971
+ if (!checkNumber(left))
972
+ throw new TypeError("expected number for left");
973
+ if (!checkNumber(right))
974
+ throw new TypeError("expected number for right");
975
+ if (!checkNumber(top))
976
+ throw new TypeError("expected number for top");
977
+ if (!checkNumber(bottom))
978
+ throw new TypeError("expected number for bottom");
979
+ this.left = left;
980
+ this.right = right;
981
+ this.top = top;
982
+ this.bottom = bottom;
983
+ }
984
+ toArray() {
985
+ return [this.left, this.right, this.top, this.bottom];
986
+ }
987
+ toString() {
988
+ return `${this.left},${this.right},${this.top},${this.bottom}`;
989
+ }
990
+ get [Symbol.toStringTag]() {
991
+ return "BoundingBox";
992
+ }
993
+ [NodeJSCustomInspect]() {
994
+ return `BoundingBox <${this.toString()}>`;
995
+ }
996
+ toJSON() {
997
+ return {
998
+ left: this.left,
999
+ top: this.top,
1000
+ right: this.right,
1001
+ bottom: this.bottom
1002
+ };
1003
+ }
1004
+ clone() {
1005
+ return new _BoundingBox(this.left, this.right, this.top, this.bottom);
1006
+ }
1007
+ equals(...args) {
1008
+ const b = _BoundingBox.resolveArgs(args);
1009
+ return this.left === b.left && this.right === b.right && this.top === b.top && this.bottom === b.bottom;
1010
+ }
1011
+ toSize() {
1012
+ return [this.width, this.height];
1013
+ }
1014
+ toVec2() {
1015
+ return [this.left, this.top];
1016
+ }
1017
+ toRectangle() {
1018
+ return [this.left, this.top, this.width, this.height];
1019
+ }
1020
+ inside(...args) {
1021
+ const bbox = _BoundingBox.resolve(args);
1022
+ return this.right >= bbox.left && bbox.right >= this.left && this.bottom >= bbox.top && bbox.bottom >= this.top;
1023
+ }
1024
+ insidePoint(...args) {
1025
+ const point = Vec2.resolveArgs(args);
1026
+ return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y;
1027
+ }
1028
+ insideCircle(...args) {
1029
+ const circle = Circle.resolveArgs(args);
1030
+ const center = Vec2.resolve(circle).add(circle.radius);
1031
+ const bboxhe = new Vec2(this.width / 2, this.height / 2);
1032
+ const bboxcenter = new Vec2(this.left + bboxhe.x, this.top + bboxhe.y);
1033
+ let diff = center.subtract(bboxcenter);
1034
+ const clamped = Vec2.clamp(diff, bboxhe.invert(), bboxhe);
1035
+ const closest = bboxcenter.add(clamped);
1036
+ diff = closest.subtract(center);
1037
+ return diff.length() < circle.radius;
1038
+ }
1039
+ };
1040
+
1041
+ // source/geometry/size.ts
1042
+ var Size = class _Size {
1043
+ width;
1044
+ height;
1045
+ get aspectRatio() {
1046
+ return this.height / this.width;
1047
+ }
1048
+ get area() {
1049
+ return this.width * this.height;
1050
+ }
1051
+ get perimeter() {
1052
+ return this.width + this.width + this.height + this.height;
1053
+ }
1054
+ static resolve(a) {
1055
+ const value = this.cast(a);
1056
+ if (typeof value != "undefined")
1057
+ return value;
1058
+ throw new ResolveError("Square", a);
1059
+ }
1060
+ static resolveArgs(args) {
1061
+ if (checkNumberArray(args, 2))
1062
+ return new this(args[0], args[1]);
1063
+ return this.resolve(args[0]);
1064
+ }
1065
+ static cast(a) {
1066
+ if (a == null || typeof a == "undefined")
1067
+ return void 0;
1068
+ if (checkNumberArray(a, 2))
1069
+ return new this(a[0], a[1]);
1070
+ if (hasProperty(a, "toSize", "function"))
1071
+ return this.cast(a.toSize());
1072
+ if (hasProperty(a, "width", "number") && hasProperty(a, "height", "number"))
1073
+ return new this(a.width, a.height);
1074
+ if (checkString(a)) {
1075
+ const parts = a.split("x").map((v) => parseFloat(v));
1076
+ if (checkNumberArray(parts, 2))
1077
+ return this.cast(parts);
1078
+ }
1079
+ if (checkNumber(a))
1080
+ return new this(a, a);
1081
+ return void 0;
1082
+ }
1083
+ static is(a) {
1084
+ return typeof this.cast(a) != "undefined";
1085
+ }
1086
+ constructor(width, height) {
1087
+ if (!checkNumber(width))
1088
+ throw new TypeError("expected number for width");
1089
+ if (!checkNumber(height))
1090
+ throw new TypeError("expected number for height");
1091
+ this.width = width;
1092
+ this.height = height;
1093
+ }
1094
+ toArray() {
1095
+ return [this.width, this.height];
1096
+ }
1097
+ toString() {
1098
+ return `${this.width}x${this.height}`;
1099
+ }
1100
+ get [Symbol.toStringTag]() {
1101
+ return "Size";
1102
+ }
1103
+ [NodeJSCustomInspect]() {
1104
+ return `Size <${this.toString()}>`;
1105
+ }
1106
+ toJSON() {
1107
+ return {
1108
+ width: this.width,
1109
+ height: this.height
1110
+ };
1111
+ }
1112
+ clone() {
1113
+ return new _Size(this.width, this.height);
1114
+ }
1115
+ equals(...args) {
1116
+ const s = _Size.resolveArgs(args);
1117
+ return this.width == s.width && this.height == s.height;
1118
+ }
1119
+ toVec2() {
1120
+ return [this.width, this.height];
1137
1121
  }
1138
1122
  };
1139
1123
 
@@ -1183,17 +1167,22 @@ var Rectangle = class _Rectangle {
1183
1167
  return value;
1184
1168
  throw new ResolveError("Rectangle", a);
1185
1169
  }
1170
+ static resolveArgs(args) {
1171
+ if (checkNumberArray(args, 4))
1172
+ return new this([args[0], args[1]], [args[2], args[3]]);
1173
+ return this.resolve(args[0]);
1174
+ }
1186
1175
  static cast(a) {
1187
1176
  if (a == null || typeof a == "undefined")
1188
1177
  return void 0;
1189
- if (check_number_array(a, 4))
1178
+ if (checkNumberArray(a, 4))
1190
1179
  return new this([a[0], a[1]], [a[2], a[3]]);
1191
- if (check_number_array(a, 5)) {
1180
+ if (checkNumberArray(a, 5)) {
1192
1181
  const rect = new this([a[0], a[1]], [a[3], a[4]]);
1193
1182
  rect.w = a[2];
1194
1183
  return rect;
1195
1184
  }
1196
- if (check_string(a)) {
1185
+ if (checkString(a)) {
1197
1186
  const [spos, ssize] = a.split("|");
1198
1187
  const pos = Vec2.cast(spos);
1199
1188
  const size = Size.cast(ssize);
@@ -1203,9 +1192,11 @@ var Rectangle = class _Rectangle {
1203
1192
  rect.w = pos.w;
1204
1193
  return rect;
1205
1194
  }
1206
- if (has_property(a, "x", "number") && has_property(a, "y", "number") && has_property(a, "width", "number") && has_property(a, "height", "number")) {
1195
+ if (hasProperty(a, "toRectangle", "function"))
1196
+ return this.cast(a.toRectangle());
1197
+ if (hasProperty(a, "x", "number") && hasProperty(a, "y", "number") && hasProperty(a, "width", "number") && hasProperty(a, "height", "number")) {
1207
1198
  const rect = new this([a.x, a.y], [a.width, a.height]);
1208
- if (has_property(a, "w", "number"))
1199
+ if (hasProperty(a, "w", "number"))
1209
1200
  rect.w = a.w;
1210
1201
  return rect;
1211
1202
  }
@@ -1218,132 +1209,286 @@ var Rectangle = class _Rectangle {
1218
1209
  this.position = Vec2.resolve(pos);
1219
1210
  this.size = Size.resolve(size);
1220
1211
  }
1221
- toArray(w = false) {
1212
+ toArray(w = this.w !== 1) {
1222
1213
  return [...this.position.toArray(w), ...this.size.toArray()];
1223
1214
  }
1224
- toString(w = false) {
1215
+ toString(w = this.w !== 1) {
1225
1216
  return `${this.position.toString(w)}|${this.size.toString()}`;
1226
1217
  }
1218
+ get [Symbol.toStringTag]() {
1219
+ return "Rectangle";
1220
+ }
1221
+ [NodeJSCustomInspect]() {
1222
+ return `Rectangle <${this.toString()}>`;
1223
+ }
1227
1224
  toJSON() {
1228
1225
  return { ...this.position.toJSON(), ...this.size.toJSON() };
1229
1226
  }
1230
1227
  toBoundingBox() {
1231
1228
  return [this.x, this.x + this.width, this.y, this.y + this.height];
1232
1229
  }
1230
+ toVec2() {
1231
+ return [this.x, this.y, this.w];
1232
+ }
1233
+ toSize() {
1234
+ return [this.width, this.height];
1235
+ }
1233
1236
  clone() {
1234
1237
  return new _Rectangle(this.position.clone(), this.size.clone());
1235
1238
  }
1236
- equals(rectangle) {
1237
- const rect = _Rectangle.resolve(rectangle);
1239
+ equals(...args) {
1240
+ const rect = _Rectangle.resolveArgs(args);
1238
1241
  return this.position.equals(rect.position) && this.size.equals(rect.size);
1239
1242
  }
1240
1243
  };
1241
1244
 
1242
- // source/geometry/bbox.ts
1243
- var BoundingBox = class _BoundingBox {
1244
- left;
1245
- right;
1246
- top;
1247
- bottom;
1248
- get width() {
1249
- return this.right - this.left;
1245
+ // source/common/string.ts
1246
+ function stringify(value) {
1247
+ return value != null && typeof value == "object" && "toString" in value && typeof value.toString == "function" ? value.toString() : String(value);
1248
+ }
1249
+
1250
+ // source/vectors/vec3.ts
1251
+ var Vec3 = class _Vec3 {
1252
+ x;
1253
+ y;
1254
+ z;
1255
+ w;
1256
+ static resolve(a) {
1257
+ const value = this.cast(a);
1258
+ if (typeof value != "undefined")
1259
+ return value;
1260
+ throw new ResolveError("Vec3", a);
1261
+ }
1262
+ static cast(a) {
1263
+ if (a == null || typeof a == "undefined")
1264
+ return void 0;
1265
+ if (checkNumberArray(a, 3) || checkNumberArray(a, 4))
1266
+ return new this(a[0], a[1], a[2], checkNumber(a[3]) ? a[3] : void 0);
1267
+ if (hasProperty(a, "x", "number") && hasProperty(a, "y", "number") && hasProperty(a, "z", "number"))
1268
+ return new this(a.x, a.y, a.z, hasProperty(a, "w", "number") ? a.w : void 0);
1269
+ if (checkString(a)) {
1270
+ const [sxyz, sw] = a.split(";");
1271
+ if (checkString(sxyz)) {
1272
+ const parts = sxyz.split(",");
1273
+ if (checkStringArray(parts, 3))
1274
+ return new this(parseFloat(parts[0]), parseFloat(parts[1]), parseFloat(parts[2]), checkString(sw) ? parseFloat(sw) : void 0);
1275
+ }
1276
+ }
1277
+ if (checkNumber(a))
1278
+ return new this(a, a, a);
1279
+ return void 0;
1280
+ }
1281
+ static resolveArgs(args) {
1282
+ if (checkNumberArray(args, 3))
1283
+ return new this(args[0], args[1], args[2]);
1284
+ return this.resolve(args[0]);
1285
+ }
1286
+ static is(a) {
1287
+ return typeof this.cast(a) != "undefined";
1288
+ }
1289
+ static fromPoints(a, b) {
1290
+ const veca = this.resolve(a);
1291
+ const vecb = this.resolve(b);
1292
+ return new this(vecb.x - veca.x, vecb.y - veca.y, vecb.z - veca.z);
1293
+ }
1294
+ static clamp(value, min, max) {
1295
+ const a = this.resolve(value), b = this.resolve(min), c = this.resolve(max);
1296
+ return new this(
1297
+ clamp(a.x, b.x, c.x),
1298
+ clamp(a.y, b.y, c.y),
1299
+ clamp(a.z, b.z, c.z)
1300
+ );
1301
+ }
1302
+ static intersectPlane(planeP, planeN, lineStart, lineEnd, t) {
1303
+ planeN = this.resolve(planeN).normalize();
1304
+ const plane_d = -this.resolve(planeN).dot(planeP);
1305
+ const ad = this.resolve(lineStart).dot(planeN);
1306
+ const bd = this.resolve(lineEnd).dot(planeN);
1307
+ t = (-plane_d - ad) / (bd - ad);
1308
+ const lineStartToEnd = this.resolve(lineEnd).subtract(lineStart);
1309
+ const linetoIntersect = lineStartToEnd.multiply(t);
1310
+ return _Vec3.resolve(lineStart).add(linetoIntersect);
1311
+ }
1312
+ static get zero() {
1313
+ return new this(0, 0, 0);
1314
+ }
1315
+ static get one() {
1316
+ return new this(1, 1, 1);
1317
+ }
1318
+ constructor(x, y, z, w = 1) {
1319
+ if (!checkNumber(x))
1320
+ throw new TypeError("expected number for x");
1321
+ if (!checkNumber(y))
1322
+ throw new TypeError("expected number for y");
1323
+ if (!checkNumber(z))
1324
+ throw new TypeError("expected number for z");
1325
+ if (!checkNumber(w))
1326
+ throw new TypeError("expected number for w");
1327
+ this.x = x;
1328
+ this.y = y;
1329
+ this.z = z;
1330
+ this.w = w;
1331
+ }
1332
+ toArray(w = this.w !== 1) {
1333
+ return w ? [this.x, this.y, this.z, this.w] : [this.x, this.y, this.z];
1334
+ }
1335
+ toJSON() {
1336
+ return {
1337
+ x: this.x,
1338
+ y: this.y,
1339
+ z: this.z,
1340
+ w: this.w
1341
+ };
1342
+ }
1343
+ toString(w = this.w !== 1) {
1344
+ return w ? `${this.x},${this.y},${this.z};${this.w}` : `${this.x},${this.y},${this.z}`;
1345
+ }
1346
+ get [Symbol.toStringTag]() {
1347
+ return "Vec3";
1348
+ }
1349
+ [NodeJSCustomInspect]() {
1350
+ return `Vec3 <${this.toString()}>`;
1351
+ }
1352
+ toVec2() {
1353
+ return [this.x, this.y, this.w];
1354
+ }
1355
+ toRGB() {
1356
+ const vec = this.normalize();
1357
+ return [vec.x, vec.y, vec.z];
1358
+ }
1359
+ toRGBA() {
1360
+ const vec = this.normalize();
1361
+ return [vec.x, vec.y, vec.z, vec.w];
1362
+ }
1363
+ toHSL() {
1364
+ const vec = this.normalize();
1365
+ return [vec.x, vec.y, vec.z];
1366
+ }
1367
+ toHSLA() {
1368
+ const vec = this.normalize();
1369
+ return [vec.x, vec.y, vec.z, vec.w];
1250
1370
  }
1251
- set width(val) {
1252
- this.right = this.left + val;
1371
+ toQuaternion() {
1372
+ return [this.w, this.x, this.y, this.z];
1253
1373
  }
1254
- get height() {
1255
- return this.bottom - this.top;
1374
+ clone() {
1375
+ return new _Vec3(this.x, this.y, this.z, this.w);
1256
1376
  }
1257
- set height(val) {
1258
- this.bottom = this.top + val;
1377
+ equals(...args) {
1378
+ const a = _Vec3.resolveArgs(args);
1379
+ return this.x == a.x && this.y == a.y && this.z == a.z;
1259
1380
  }
1260
- static resolve(a) {
1261
- const value = this.cast(a);
1262
- if (typeof value != "undefined")
1263
- return value;
1264
- throw new ResolveError("BoundingBox", a);
1381
+ setX(x) {
1382
+ this.x = x;
1383
+ return this;
1265
1384
  }
1266
- static cast(a) {
1267
- if (a == null || typeof a == "undefined")
1268
- return void 0;
1269
- if (check_number_array(a, 4))
1270
- return new this(a[0], a[1], a[2], a[3]);
1271
- if (has_property(a, "left", "number") && has_property(a, "right", "number") && has_property(a, "top", "number") && has_property(a, "bottom", "number"))
1272
- return new this(a.left, a.right, a.top, a.bottom);
1273
- if (check_string(a)) {
1274
- const parts = a.split(",");
1275
- if (check_string_array(parts, 4))
1276
- return this.cast(parts.map((v) => parseFloat(v)));
1277
- }
1278
- return void 0;
1385
+ setY(y) {
1386
+ this.y = y;
1387
+ return this;
1279
1388
  }
1280
- static is(a) {
1281
- return typeof this.cast(a) != "undefined";
1389
+ setZ(z) {
1390
+ this.z = z;
1391
+ return this;
1282
1392
  }
1283
- constructor(left, right, top, bottom) {
1284
- if (!check_number(left))
1285
- throw new TypeError("expected number for left");
1286
- if (!check_number(right))
1287
- throw new TypeError("expected number for right");
1288
- if (!check_number(top))
1289
- throw new TypeError("expected number for top");
1290
- if (!check_number(bottom))
1291
- throw new TypeError("expected number for bottom");
1292
- this.left = left;
1293
- this.right = right;
1294
- this.top = top;
1295
- this.bottom = bottom;
1393
+ set(...args) {
1394
+ const vec = _Vec3.resolveArgs(args);
1395
+ return this.setX(vec.x).setY(vec.y).setZ(vec.z);
1296
1396
  }
1297
- toArray() {
1298
- return [this.left, this.right, this.top, this.bottom];
1397
+ add(...args) {
1398
+ const vec = _Vec3.resolveArgs(args);
1399
+ return new _Vec3(
1400
+ this.x + vec.x,
1401
+ this.y + vec.y,
1402
+ this.z + vec.z
1403
+ );
1299
1404
  }
1300
- toString() {
1301
- return `${this.left},${this.right},${this.top},${this.bottom}`;
1405
+ offset(...args) {
1406
+ const vec = _Vec3.resolveArgs(args);
1407
+ this.x += vec.x;
1408
+ this.y += vec.y;
1409
+ this.z += vec.z;
1410
+ return this;
1302
1411
  }
1303
- toJSON() {
1304
- return {
1305
- left: this.left,
1306
- top: this.top,
1307
- right: this.right,
1308
- bottom: this.bottom
1309
- };
1412
+ subtract(...args) {
1413
+ const vec = _Vec3.resolveArgs(args);
1414
+ return new _Vec3(
1415
+ this.x - vec.x,
1416
+ this.y - vec.y,
1417
+ this.z - vec.z
1418
+ );
1310
1419
  }
1311
- clone() {
1312
- return new _BoundingBox(this.left, this.right, this.top, this.bottom);
1420
+ multiply(scalar) {
1421
+ return new _Vec3(
1422
+ this.x * scalar,
1423
+ this.y * scalar,
1424
+ this.z * scalar
1425
+ );
1313
1426
  }
1314
- equals(bbox) {
1315
- const b = _BoundingBox.resolve(bbox);
1316
- return this.left == b.left && this.right == b.right && this.top == b.top && this.bottom == b.bottom;
1427
+ naiveMultiply(...args) {
1428
+ const vec = _Vec3.resolveArgs(args);
1429
+ return new _Vec3(
1430
+ this.x * vec.x,
1431
+ this.y * vec.y,
1432
+ this.z * vec.z
1433
+ );
1317
1434
  }
1318
- toSquare() {
1319
- return new Size(this.width, this.height);
1435
+ divide(...args) {
1436
+ if (checkNumberArray(args, 1))
1437
+ return new _Vec3(
1438
+ this.x / args[0],
1439
+ this.y / args[0],
1440
+ this.z / args[0]
1441
+ );
1442
+ const vec = _Vec3.resolveArgs(args);
1443
+ return new _Vec3(
1444
+ this.x / vec.x,
1445
+ this.y / vec.y,
1446
+ this.z / vec.z
1447
+ );
1320
1448
  }
1321
- toRectangle() {
1322
- return new Rectangle([this.left, this.top], [this.width, this.height]);
1449
+ dot(...args) {
1450
+ const vec = _Vec3.resolveArgs(args);
1451
+ return this.x * vec.x + this.y * vec.y + this.z * vec.z;
1323
1452
  }
1324
- inside(a) {
1325
- const bbox = _BoundingBox.resolve(a);
1326
- return this.right >= bbox.left && bbox.right >= this.left && this.bottom >= bbox.top && bbox.bottom >= this.top;
1453
+ cross(...args) {
1454
+ const vec = _Vec3.resolveArgs(args);
1455
+ return new _Vec3(
1456
+ this.y * vec.z - this.z * vec.y,
1457
+ this.z * vec.x - this.x * vec.z,
1458
+ this.x * vec.y - this.y * vec.x
1459
+ );
1327
1460
  }
1328
- insidePoint(a) {
1329
- const point = Vec2.resolve(a);
1330
- return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y;
1461
+ distance(...args) {
1462
+ const vec = _Vec3.resolveArgs(args);
1463
+ return Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2) + Math.pow(vec.z - this.z, 2);
1331
1464
  }
1332
- insideCircle(a) {
1333
- const circle = Circle.resolve(a);
1334
- const center = Vec2.resolve(circle).add(circle.radius);
1335
- const bboxhe = new Vec2(this.width / 2, this.height / 2);
1336
- const bboxcenter = new Vec2(this.left + bboxhe.x, this.top + bboxhe.y);
1337
- let diff = center.subtract(bboxcenter);
1338
- const clamped = Vec2.clamp(diff, bboxhe.invert(), bboxhe);
1339
- const closest = bboxcenter.add(clamped);
1340
- diff = closest.subtract(center);
1341
- return diff.length() < circle.radius;
1465
+ distanceSquare(...args) {
1466
+ const vec = _Vec3.resolveArgs(args);
1467
+ return Math.sqrt(Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2) + Math.pow(vec.z - this.z, 2));
1468
+ }
1469
+ length() {
1470
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
1471
+ }
1472
+ normalize() {
1473
+ const length = this.length();
1474
+ if (length == 0) return _Vec3.zero;
1475
+ return new _Vec3(
1476
+ this.x / length,
1477
+ this.y / length,
1478
+ this.z / length,
1479
+ this.w / length
1480
+ );
1481
+ }
1482
+ invert() {
1483
+ return this.multiply(-1);
1484
+ }
1485
+ round() {
1486
+ return new _Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z), Math.round(this.w));
1342
1487
  }
1343
1488
  };
1344
1489
 
1345
1490
  // source/geometry/triangle.ts
1346
- var ATriangle = class {
1491
+ var Triangle = class {
1347
1492
  constructor(A, B, C) {
1348
1493
  this.A = A;
1349
1494
  this.B = B;
@@ -1373,8 +1518,17 @@ var ATriangle = class {
1373
1518
  get height() {
1374
1519
  return 2 * (this.area / this.base);
1375
1520
  }
1521
+ toString() {
1522
+ return `${stringify(this.A)}|${stringify(this.B)}|${stringify(this.C)}`;
1523
+ }
1524
+ get [Symbol.toStringTag]() {
1525
+ return "Triangle";
1526
+ }
1527
+ [NodeJSCustomInspect]() {
1528
+ return `Triangle <${this.toString()}>`;
1529
+ }
1376
1530
  };
1377
- var Triangle2D = class extends ATriangle {
1531
+ var Triangle2D = class extends Triangle {
1378
1532
  get a() {
1379
1533
  return Vec2.fromPoints(this.B, this.C).length();
1380
1534
  }
@@ -1385,7 +1539,7 @@ var Triangle2D = class extends ATriangle {
1385
1539
  return Vec2.fromPoints(this.A, this.B).length();
1386
1540
  }
1387
1541
  };
1388
- var Triangle3D = class extends ATriangle {
1542
+ var Triangle3D = class extends Triangle {
1389
1543
  get a() {
1390
1544
  return Vec3.fromPoints(this.B, this.C).length();
1391
1545
  }
@@ -1460,15 +1614,20 @@ var Mat3 = class _Mat3 {
1460
1614
  return value;
1461
1615
  throw new ResolveError("Mat3", a);
1462
1616
  }
1617
+ static resolveArgs(args) {
1618
+ if (checkNumberArray(args, 9))
1619
+ return new this(args);
1620
+ return this.resolve(args[0]);
1621
+ }
1463
1622
  static cast(a) {
1464
1623
  if (a == null || typeof a == "undefined")
1465
1624
  return void 0;
1466
- if (check_number_array(a, 9)) {
1625
+ if (checkNumberArray(a, 9)) {
1467
1626
  return new this(a);
1468
1627
  }
1469
- if (check_array(a, void 0, 3)) {
1628
+ if (checkArray(a, void 0, 3)) {
1470
1629
  const row0 = a[0], row1 = a[1], row2 = a[2];
1471
- if (check_number_array(row0, 3) && check_number_array(row1, 3) && check_number_array(row2, 3))
1630
+ if (checkNumberArray(row0, 3) && checkNumberArray(row1, 3) && checkNumberArray(row2, 3))
1472
1631
  return new this([
1473
1632
  row0[0],
1474
1633
  row0[1],
@@ -1481,12 +1640,14 @@ var Mat3 = class _Mat3 {
1481
1640
  row2[2]
1482
1641
  ]);
1483
1642
  }
1484
- if (check_string(a)) {
1643
+ if (checkString(a)) {
1485
1644
  const parts = a.split(",");
1486
- if (check_string_array(parts, 9))
1645
+ if (checkStringArray(parts, 9))
1487
1646
  return this.cast(parts.map((i) => parseFloat(i)));
1488
1647
  }
1489
- if (has_property(a, "m00", "number") && has_property(a, "m01", "number") && has_property(a, "m02", "number") && has_property(a, "m10", "number") && has_property(a, "m11", "number") && has_property(a, "m12", "number") && has_property(a, "m20", "number") && has_property(a, "m21", "number") && has_property(a, "m22", "number"))
1648
+ if (hasProperty(a, "toMat3", "function"))
1649
+ return this.cast(a.toMat3());
1650
+ if (hasProperty(a, "m00", "number") && hasProperty(a, "m01", "number") && hasProperty(a, "m02", "number") && hasProperty(a, "m10", "number") && hasProperty(a, "m11", "number") && hasProperty(a, "m12", "number") && hasProperty(a, "m20", "number") && hasProperty(a, "m21", "number") && hasProperty(a, "m22", "number"))
1490
1651
  return new this([
1491
1652
  a.m00,
1492
1653
  a.m01,
@@ -1498,7 +1659,7 @@ var Mat3 = class _Mat3 {
1498
1659
  a.m21,
1499
1660
  a.m22
1500
1661
  ]);
1501
- if (check_number(a)) {
1662
+ if (checkNumber(a)) {
1502
1663
  return new this([a, a, a, a, a, a, a, a, a]);
1503
1664
  }
1504
1665
  return void 0;
@@ -1520,7 +1681,7 @@ var Mat3 = class _Mat3 {
1520
1681
  ]);
1521
1682
  }
1522
1683
  constructor(init = [1, 0, 0, 0, 1, 0, 0, 0, 1]) {
1523
- if (!check_number_array(init, 9))
1684
+ if (!checkNumberArray(init, 9))
1524
1685
  throw new TypeError("expected a number array with 9 elements");
1525
1686
  this._raw = init;
1526
1687
  }
@@ -1560,6 +1721,12 @@ var Mat3 = class _Mat3 {
1560
1721
  toString() {
1561
1722
  return `${this.m00},${this.m01},${this.m02},${this.m10},${this.m11},${this.m12},${this.m20},${this.m21},${this.m22}`;
1562
1723
  }
1724
+ get [Symbol.toStringTag]() {
1725
+ return "Mat3";
1726
+ }
1727
+ [NodeJSCustomInspect]() {
1728
+ return `Mat3 <${this.toString()}>`;
1729
+ }
1563
1730
  clone() {
1564
1731
  return new _Mat3([
1565
1732
  this.m00,
@@ -1573,41 +1740,41 @@ var Mat3 = class _Mat3 {
1573
1740
  this.m22
1574
1741
  ]);
1575
1742
  }
1576
- equals(mat) {
1577
- const m = _Mat3.resolve(mat);
1743
+ equals(...args) {
1744
+ const m = _Mat3.resolveArgs(args);
1578
1745
  for (let index = 0; index < this._raw.length; index++)
1579
1746
  if (this._raw[index] != m._raw[index])
1580
1747
  return false;
1581
1748
  return true;
1582
1749
  }
1583
- add(mat) {
1584
- const b = _Mat3.resolve(mat);
1750
+ add(...args) {
1751
+ const b = _Mat3.resolveArgs(args);
1585
1752
  const m = new _Mat3();
1586
1753
  for (let index = 0; index < this._raw.length; index++)
1587
1754
  m._raw[index] = this._raw[index] + b._raw[index];
1588
1755
  return m;
1589
1756
  }
1590
- subtract(mat) {
1591
- const b = _Mat3.resolve(mat);
1757
+ subtract(...args) {
1758
+ const b = _Mat3.resolveArgs(args);
1592
1759
  const m = new _Mat3();
1593
1760
  for (let index = 0; index < this._raw.length; index++)
1594
1761
  m._raw[index] = this._raw[index] - b._raw[index];
1595
1762
  return m;
1596
1763
  }
1597
- multiply(a) {
1598
- if (check_number(a))
1764
+ multiply(...args) {
1765
+ if (checkNumberArray(args, 1))
1599
1766
  return new _Mat3([
1600
- this.m00 * a,
1601
- this.m01 * a,
1602
- this.m02 * a,
1603
- this.m10 * a,
1604
- this.m11 * a,
1605
- this.m12 * a,
1606
- this.m20 * a,
1607
- this.m21 * a,
1608
- this.m22 * a
1767
+ this.m00 * args[0],
1768
+ this.m01 * args[0],
1769
+ this.m02 * args[0],
1770
+ this.m10 * args[0],
1771
+ this.m11 * args[0],
1772
+ this.m12 * args[0],
1773
+ this.m20 * args[0],
1774
+ this.m21 * args[0],
1775
+ this.m22 * args[0]
1609
1776
  ]);
1610
- const b = _Mat3.resolve(a);
1777
+ const b = _Mat3.resolveArgs(args);
1611
1778
  return new _Mat3([
1612
1779
  b.m00 * this.m00 + b.m01 * this.m10 + b.m02 * this.m20,
1613
1780
  b.m00 * this.m01 + b.m01 * this.m11 + b.m02 * this.m21,
@@ -1807,15 +1974,20 @@ var Mat4 = class _Mat4 {
1807
1974
  return value;
1808
1975
  throw new ResolveError("Mat4", a);
1809
1976
  }
1977
+ static resolveArgs(args) {
1978
+ if (checkNumberArray(args, 16))
1979
+ return new this(args);
1980
+ return this.resolve(args[0]);
1981
+ }
1810
1982
  static cast(a) {
1811
1983
  if (a == null || typeof a == "undefined")
1812
1984
  return void 0;
1813
- if (check_number_array(a, 16)) {
1985
+ if (checkNumberArray(a, 16)) {
1814
1986
  return new this(a);
1815
1987
  }
1816
- if (check_array(a, void 0, 4)) {
1988
+ if (checkArray(a, void 0, 4)) {
1817
1989
  const row0 = a[0], row1 = a[1], row2 = a[2], row3 = a[3];
1818
- if (check_number_array(row0, 4) && check_number_array(row1, 4) && check_number_array(row2, 4) && check_number_array(row3, 4))
1990
+ if (checkNumberArray(row0, 4) && checkNumberArray(row1, 4) && checkNumberArray(row2, 4) && checkNumberArray(row3, 4))
1819
1991
  return new this([
1820
1992
  row0[0],
1821
1993
  row0[1],
@@ -1835,12 +2007,14 @@ var Mat4 = class _Mat4 {
1835
2007
  row3[3]
1836
2008
  ]);
1837
2009
  }
1838
- if (check_string(a)) {
2010
+ if (checkString(a)) {
1839
2011
  const parts = a.split(",");
1840
- if (check_string_array(parts, 16))
2012
+ if (checkStringArray(parts, 16))
1841
2013
  return this.cast(parts.map((i) => parseFloat(i)));
1842
2014
  }
1843
- if (has_property(a, "m00", "number") && has_property(a, "m01", "number") && has_property(a, "m02", "number") && has_property(a, "m03", "number") && has_property(a, "m10", "number") && has_property(a, "m11", "number") && has_property(a, "m12", "number") && has_property(a, "m13", "number") && has_property(a, "m20", "number") && has_property(a, "m21", "number") && has_property(a, "m22", "number") && has_property(a, "m23", "number") && has_property(a, "m30", "number") && has_property(a, "m31", "number") && has_property(a, "m32", "number") && has_property(a, "m33", "number"))
2015
+ if (hasProperty(a, "toMat4", "function"))
2016
+ return this.cast(a.toMat4());
2017
+ if (hasProperty(a, "m00", "number") && hasProperty(a, "m01", "number") && hasProperty(a, "m02", "number") && hasProperty(a, "m03", "number") && hasProperty(a, "m10", "number") && hasProperty(a, "m11", "number") && hasProperty(a, "m12", "number") && hasProperty(a, "m13", "number") && hasProperty(a, "m20", "number") && hasProperty(a, "m21", "number") && hasProperty(a, "m22", "number") && hasProperty(a, "m23", "number") && hasProperty(a, "m30", "number") && hasProperty(a, "m31", "number") && hasProperty(a, "m32", "number") && hasProperty(a, "m33", "number"))
1844
2018
  return new this([
1845
2019
  a.m00,
1846
2020
  a.m01,
@@ -1859,7 +2033,7 @@ var Mat4 = class _Mat4 {
1859
2033
  a.m32,
1860
2034
  a.m33
1861
2035
  ]);
1862
- if (check_number(a)) {
2036
+ if (checkNumber(a)) {
1863
2037
  return new this([a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a]);
1864
2038
  }
1865
2039
  return void 0;
@@ -1867,22 +2041,25 @@ var Mat4 = class _Mat4 {
1867
2041
  static is(a) {
1868
2042
  return typeof this.cast(a) != "undefined";
1869
2043
  }
1870
- static orthographic(left, right, bottom, top, near, far) {
2044
+ static orthographic(...args) {
2045
+ const bbox = checkNumberArray(args, 6) ? new BoundingBox(args[0], args[1], args[2], args[3]) : BoundingBox.resolve(args[0]);
2046
+ const near = checkNumberArray(args, 6) ? args[4] : args[1];
2047
+ const far = checkNumberArray(args, 6) ? args[5] : args[2];
1871
2048
  return new this([
1872
- 2 / (right - left),
2049
+ 2 / (bbox.right - bbox.left),
1873
2050
  0,
1874
2051
  0,
1875
2052
  0,
1876
2053
  0,
1877
- 2 / (top - bottom),
2054
+ 2 / (bbox.top - bbox.bottom),
1878
2055
  0,
1879
2056
  0,
1880
2057
  0,
1881
2058
  0,
1882
2059
  2 / (near - far),
1883
2060
  0,
1884
- (left + right) / (left - right),
1885
- (bottom + top) / (bottom - top),
2061
+ (bbox.left + bbox.right) / (bbox.left - bbox.right),
2062
+ (bbox.bottom + bbox.top) / (bbox.bottom - bbox.top),
1886
2063
  (near + far) / (near - far),
1887
2064
  1
1888
2065
  ]);
@@ -1935,7 +2112,7 @@ var Mat4 = class _Mat4 {
1935
2112
  ]);
1936
2113
  }
1937
2114
  constructor(init = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) {
1938
- if (!check_number_array(init, 16))
2115
+ if (!checkNumberArray(init, 16))
1939
2116
  throw new TypeError("expected a number array with 16 elements");
1940
2117
  this._raw = init;
1941
2118
  }
@@ -1990,6 +2167,12 @@ var Mat4 = class _Mat4 {
1990
2167
  toString() {
1991
2168
  return `${this.m00},${this.m01},${this.m02},${this.m03},${this.m10},${this.m11},${this.m12},${this.m13},${this.m20},${this.m21},${this.m22},${this.m23},${this.m30},${this.m31},${this.m32},${this.m33}`;
1992
2169
  }
2170
+ get [Symbol.toStringTag]() {
2171
+ return "Mat4";
2172
+ }
2173
+ [NodeJSCustomInspect]() {
2174
+ return `Mat4 <${this.toString()}>`;
2175
+ }
1993
2176
  clone() {
1994
2177
  return new _Mat4([
1995
2178
  this.m00,
@@ -2010,82 +2193,80 @@ var Mat4 = class _Mat4 {
2010
2193
  this.m33
2011
2194
  ]);
2012
2195
  }
2013
- equals(mat) {
2014
- const m = _Mat4.resolve(mat);
2196
+ equals(...args) {
2197
+ const m = _Mat4.resolveArgs(args);
2015
2198
  for (let index = 0; index < this._raw.length; index++)
2016
2199
  if (this._raw[index] != m._raw[index])
2017
2200
  return false;
2018
2201
  return true;
2019
2202
  }
2020
- add(mat) {
2021
- const b = _Mat4.resolve(mat);
2203
+ add(...args) {
2204
+ const b = _Mat4.resolveArgs(args);
2022
2205
  const m = new _Mat4();
2023
2206
  for (let index = 0; index < this._raw.length; index++)
2024
2207
  m._raw[index] = this._raw[index] + b._raw[index];
2025
2208
  return m;
2026
2209
  }
2027
- subtract(mat) {
2028
- const b = _Mat4.resolve(mat);
2210
+ subtract(...args) {
2211
+ const b = _Mat4.resolveArgs(args);
2029
2212
  const m = new _Mat4();
2030
2213
  for (let index = 0; index < this._raw.length; index++)
2031
2214
  m._raw[index] = this._raw[index] - b._raw[index];
2032
2215
  return m;
2033
2216
  }
2034
- multiply(a) {
2035
- if (check_number(a)) {
2036
- return new _Mat4([
2037
- this.m00 * a,
2038
- this.m01 * a,
2039
- this.m02 * a,
2040
- this.m03 * a,
2041
- this.m10 * a,
2042
- this.m11 * a,
2043
- this.m12 * a,
2044
- this.m13 * a,
2045
- this.m20 * a,
2046
- this.m21 * a,
2047
- this.m22 * a,
2048
- this.m23 * a,
2049
- this.m30 * a,
2050
- this.m31 * a,
2051
- this.m32 * a,
2052
- this.m33 * a
2053
- ]);
2054
- }
2055
- if (_Mat4.is(a)) {
2056
- const b = _Mat4.resolve(a);
2217
+ multiply(...args) {
2218
+ if (checkNumberArray(args, 1)) {
2219
+ const scalar = args[0];
2057
2220
  return new _Mat4([
2058
- b.m00 * this.m00 + b.m01 * this.m10 + b.m02 * this.m20 + b.m03 * this.m30,
2059
- b.m00 * this.m01 + b.m01 * this.m11 + b.m02 * this.m21 + b.m03 * this.m31,
2060
- b.m00 * this.m02 + b.m01 * this.m12 + b.m02 * this.m22 + b.m03 * this.m32,
2061
- b.m00 * this.m03 + b.m01 * this.m13 + b.m02 * this.m23 + b.m03 * this.m33,
2062
- b.m10 * this.m00 + b.m11 * this.m10 + b.m12 * this.m20 + b.m13 * this.m30,
2063
- b.m10 * this.m01 + b.m11 * this.m11 + b.m12 * this.m21 + b.m13 * this.m31,
2064
- b.m10 * this.m02 + b.m11 * this.m12 + b.m12 * this.m22 + b.m13 * this.m32,
2065
- b.m10 * this.m03 + b.m11 * this.m13 + b.m12 * this.m23 + b.m13 * this.m33,
2066
- b.m20 * this.m00 + b.m21 * this.m10 + b.m22 * this.m20 + b.m23 * this.m30,
2067
- b.m20 * this.m01 + b.m21 * this.m11 + b.m22 * this.m21 + b.m23 * this.m31,
2068
- b.m20 * this.m02 + b.m21 * this.m12 + b.m22 * this.m22 + b.m23 * this.m32,
2069
- b.m20 * this.m03 + b.m21 * this.m13 + b.m22 * this.m23 + b.m23 * this.m33,
2070
- b.m30 * this.m00 + b.m31 * this.m10 + b.m32 * this.m20 + b.m33 * this.m30,
2071
- b.m30 * this.m01 + b.m31 * this.m11 + b.m32 * this.m21 + b.m33 * this.m31,
2072
- b.m30 * this.m02 + b.m31 * this.m12 + b.m32 * this.m22 + b.m33 * this.m32,
2073
- b.m30 * this.m03 + b.m31 * this.m13 + b.m32 * this.m23 + b.m33 * this.m33
2221
+ this.m00 * scalar,
2222
+ this.m01 * scalar,
2223
+ this.m02 * scalar,
2224
+ this.m03 * scalar,
2225
+ this.m10 * scalar,
2226
+ this.m11 * scalar,
2227
+ this.m12 * scalar,
2228
+ this.m13 * scalar,
2229
+ this.m20 * scalar,
2230
+ this.m21 * scalar,
2231
+ this.m22 * scalar,
2232
+ this.m23 * scalar,
2233
+ this.m30 * scalar,
2234
+ this.m31 * scalar,
2235
+ this.m32 * scalar,
2236
+ this.m33 * scalar
2074
2237
  ]);
2075
2238
  }
2076
- if (Vec3.is(a)) {
2077
- const b = Vec3.resolve(a);
2078
- const vec = new Vec3(
2079
- b.x * this.m00 + b.y * this.m10 + b.z * this.m20 + this.m30,
2080
- b.x * this.m01 + b.y * this.m11 + b.z * this.m21 + this.m31,
2081
- b.x * this.m02 + b.y * this.m12 + b.z * this.m22 + this.m32,
2082
- b.x * this.m03 + b.y * this.m13 + b.z * this.m23 + this.m33
2239
+ const vec = Vec3.cast(args[0]);
2240
+ if (vec !== void 0) {
2241
+ const result = new Vec3(
2242
+ vec.x * this.m00 + vec.y * this.m10 + vec.z * this.m20 + this.m30,
2243
+ vec.x * this.m01 + vec.y * this.m11 + vec.z * this.m21 + this.m31,
2244
+ vec.x * this.m02 + vec.y * this.m12 + vec.z * this.m22 + this.m32,
2245
+ vec.x * this.m03 + vec.y * this.m13 + vec.z * this.m23 + this.m33
2083
2246
  );
2084
- if (vec.w != 0)
2085
- return vec.divide(vec.w);
2086
- return vec;
2247
+ if (result.w != 0)
2248
+ return result.divide(result.w);
2249
+ return result;
2087
2250
  }
2088
- throw new ResolveError("Mat4 or Vec3 or number", a);
2251
+ const mat = _Mat4.resolveArgs(args);
2252
+ return new _Mat4([
2253
+ mat.m00 * this.m00 + mat.m01 * this.m10 + mat.m02 * this.m20 + mat.m03 * this.m30,
2254
+ mat.m00 * this.m01 + mat.m01 * this.m11 + mat.m02 * this.m21 + mat.m03 * this.m31,
2255
+ mat.m00 * this.m02 + mat.m01 * this.m12 + mat.m02 * this.m22 + mat.m03 * this.m32,
2256
+ mat.m00 * this.m03 + mat.m01 * this.m13 + mat.m02 * this.m23 + mat.m03 * this.m33,
2257
+ mat.m10 * this.m00 + mat.m11 * this.m10 + mat.m12 * this.m20 + mat.m13 * this.m30,
2258
+ mat.m10 * this.m01 + mat.m11 * this.m11 + mat.m12 * this.m21 + mat.m13 * this.m31,
2259
+ mat.m10 * this.m02 + mat.m11 * this.m12 + mat.m12 * this.m22 + mat.m13 * this.m32,
2260
+ mat.m10 * this.m03 + mat.m11 * this.m13 + mat.m12 * this.m23 + mat.m13 * this.m33,
2261
+ mat.m20 * this.m00 + mat.m21 * this.m10 + mat.m22 * this.m20 + mat.m23 * this.m30,
2262
+ mat.m20 * this.m01 + mat.m21 * this.m11 + mat.m22 * this.m21 + mat.m23 * this.m31,
2263
+ mat.m20 * this.m02 + mat.m21 * this.m12 + mat.m22 * this.m22 + mat.m23 * this.m32,
2264
+ mat.m20 * this.m03 + mat.m21 * this.m13 + mat.m22 * this.m23 + mat.m23 * this.m33,
2265
+ mat.m30 * this.m00 + mat.m31 * this.m10 + mat.m32 * this.m20 + mat.m33 * this.m30,
2266
+ mat.m30 * this.m01 + mat.m31 * this.m11 + mat.m32 * this.m21 + mat.m33 * this.m31,
2267
+ mat.m30 * this.m02 + mat.m31 * this.m12 + mat.m32 * this.m22 + mat.m33 * this.m32,
2268
+ mat.m30 * this.m03 + mat.m31 * this.m13 + mat.m32 * this.m23 + mat.m33 * this.m33
2269
+ ]);
2089
2270
  }
2090
2271
  translate(...args) {
2091
2272
  const vec = Vec3.resolveArgs(args);
@@ -2235,33 +2416,31 @@ var Mat4 = class _Mat4 {
2235
2416
  };
2236
2417
 
2237
2418
  // source/color.ts
2238
- function _hex_to_array(hex) {
2239
- if (!check_hex(hex))
2419
+ function __hex_to_array__(hex) {
2420
+ if (!checkHex(hex))
2240
2421
  return void 0;
2241
- const part = get_hex_part(hex);
2242
- const a = parseInt(part.substring(0, 2), 16) / 255;
2243
- const b = parseInt(part.substring(2, 4), 16) / 255;
2244
- const c = parseInt(part.substring(4, 6), 16) / 255;
2245
- const d = part.length == 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1;
2246
- return [a, b, c, d];
2422
+ const part = getHexValue(hex);
2423
+ const red = parseInt(part.substring(0, 2), 16) / 255;
2424
+ const green = parseInt(part.substring(2, 4), 16) / 255;
2425
+ const blue = parseInt(part.substring(4, 6), 16) / 255;
2426
+ const alpha = part.length == 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1;
2427
+ return [red, green, blue, alpha];
2247
2428
  }
2248
- function _number_to_rgb(number) {
2429
+ function __number_to_rgb__(number) {
2249
2430
  const blue = number & 255;
2250
2431
  const green = (number & 65280) >>> 8;
2251
2432
  const red = (number & 16711680) >>> 16;
2252
2433
  return [red / 255, green / 255, blue / 255];
2253
2434
  }
2254
- function _number_to_rgba(number) {
2435
+ function __number_to_rgba__(number) {
2255
2436
  const alpha = number & 255;
2256
2437
  const blue = (number & 65280) >>> 8;
2257
2438
  const green = (number & 16711680) >>> 16;
2258
2439
  const red = (number & 4278190080) >>> 24;
2259
2440
  return [red / 255, green / 255, blue / 255, alpha / 255];
2260
2441
  }
2261
- function _fix_integer(number) {
2262
- return number * 255 | 0;
2263
- }
2264
- var RGBAColor = class _RGBAColor {
2442
+ var __to_byte__ = (scale) => clamp(scale * 255 | 0, 0, 255);
2443
+ var RGBA = class _RGBA {
2265
2444
  _red;
2266
2445
  get red() {
2267
2446
  return this._red;
@@ -2296,27 +2475,36 @@ var RGBAColor = class _RGBAColor {
2296
2475
  return value;
2297
2476
  throw new ResolveError("RGBAColor", a);
2298
2477
  }
2478
+ static resolveArgs(args) {
2479
+ if (checkNumberArray(args, 3) || checkNumberArray(args, 4))
2480
+ return new this(args[0], args[1], args[2], args[3]);
2481
+ return this.resolve(args[0]);
2482
+ }
2299
2483
  static cast(a) {
2300
2484
  if (a == null || typeof a == "undefined")
2301
2485
  return void 0;
2302
- if (check_number_array(a, 3) || check_number_array(a, 4))
2486
+ if (checkNumberArray(a, 3) || checkNumberArray(a, 4))
2303
2487
  return new this(a[0], a[1], a[2], a[3]);
2304
- if (has_property(a, "red", "number") && has_property(a, "green", "number") && has_property(a, "blue", "number"))
2305
- return new this(a.red, a.green, a.blue, has_property(a, "alpha", "number") ? a.alpha : void 0);
2306
- if (check_number(a)) {
2488
+ if (hasProperty(a, "toRGB", "function"))
2489
+ return this.cast(a.toRGB());
2490
+ if (hasProperty(a, "toRGBA", "function"))
2491
+ return this.cast(a.toRGBA());
2492
+ if (hasProperty(a, "red", "number") && hasProperty(a, "green", "number") && hasProperty(a, "blue", "number"))
2493
+ return new this(a.red, a.green, a.blue, hasProperty(a, "alpha", "number") ? a.alpha : void 0);
2494
+ if (checkNumber(a)) {
2307
2495
  const hex = a.toString(16);
2308
- const convert = hex.length <= 6 ? _number_to_rgb : _number_to_rgba;
2496
+ const convert = hex.length <= 6 ? __number_to_rgb__ : __number_to_rgba__;
2309
2497
  return this.cast(convert(a));
2310
2498
  }
2311
- if (check_string(a)) {
2499
+ if (checkString(a)) {
2312
2500
  if (a.startsWith("rgb")) {
2313
2501
  const hasAlpha = a.startsWith("rgba");
2314
2502
  const offset = hasAlpha ? 5 : 4;
2315
2503
  const parts = a.substring(offset, a.indexOf(")", offset)).split(",");
2316
- if (check_string_array(parts, hasAlpha ? 4 : 3))
2504
+ if (checkStringArray(parts, hasAlpha ? 4 : 3))
2317
2505
  return this.cast(parts.map((v) => parseInt(v) / 255));
2318
2506
  }
2319
- return this.cast(_hex_to_array(a));
2507
+ return this.cast(__hex_to_array__(a));
2320
2508
  }
2321
2509
  return void 0;
2322
2510
  }
@@ -2329,38 +2517,57 @@ var RGBAColor = class _RGBAColor {
2329
2517
  this._blue = clamp(blue, 0, 1);
2330
2518
  this._alpha = clamp(alpha, 0, 1);
2331
2519
  }
2332
- toArray(withAlpha = false) {
2333
- return withAlpha ? [this.red, this.green, this.blue, this.alpha] : this.alpha == 1 ? [this.red, this.green, this.blue] : this.toArray(true);
2520
+ toArray(withAlpha = this._alpha !== 1) {
2521
+ return withAlpha ? [this.red, this.green, this.blue, this.alpha] : [this.red, this.green, this.blue];
2334
2522
  }
2335
- toJSON(withAlpha = false) {
2523
+ toJSON(withAlpha = this._alpha !== 1) {
2336
2524
  return withAlpha ? {
2337
2525
  red: this.red,
2338
2526
  green: this.green,
2339
2527
  blue: this.blue,
2340
2528
  alpha: this.alpha
2341
- } : this.alpha == 1 ? { red: this.red, green: this.green, blue: this.blue } : this.toJSON(true);
2529
+ } : {
2530
+ red: this.red,
2531
+ green: this.green,
2532
+ blue: this.blue
2533
+ };
2534
+ }
2535
+ toString(withAlpha = this._alpha !== 1) {
2536
+ return withAlpha ? `rgba(${__to_byte__(this.red)},${__to_byte__(this.green)},${__to_byte__(this.blue)},${this.alpha})` : `rgb(${__to_byte__(this.red)},${__to_byte__(this.green)},${__to_byte__(this.blue)})`;
2537
+ }
2538
+ get [Symbol.toStringTag]() {
2539
+ return "RGBA";
2342
2540
  }
2343
- toString(withAlpha = false) {
2344
- return withAlpha ? `rgba(${_fix_integer(this.red)},${_fix_integer(this.green)},${_fix_integer(this.blue)},${this.alpha})` : this.alpha == 1 ? `rgb(${_fix_integer(this.red)},${_fix_integer(this.green)},${_fix_integer(this.blue)})` : this.toString(true);
2541
+ [NodeJSCustomInspect]() {
2542
+ return `RGBA <${this.toString()}>`;
2345
2543
  }
2346
- toHSL(withAlpha = true) {
2544
+ toVec2() {
2545
+ return [this.red, this.green, this.blue];
2546
+ }
2547
+ toVec3() {
2548
+ return [this.red, this.green, this.blue, this.alpha];
2549
+ }
2550
+ toHSL(withAlpha = this._alpha !== 1) {
2347
2551
  const red = this.red, green = this.green, blue = this.blue;
2348
2552
  const min = Math.min(red, green, blue), max = Math.max(red, green, blue);
2349
2553
  const luminace = (min + max) / 2;
2350
2554
  if (min == max)
2351
- return new HSLColor(0, 0, luminace, withAlpha ? this.alpha : void 0);
2555
+ return new HSLA(0, 0, luminace, withAlpha ? this.alpha : void 0);
2352
2556
  const d = max - min;
2353
2557
  const saturation = luminace > 0.5 ? d / (2 - max - min) : d / (max + min);
2354
2558
  if (max == red)
2355
- return new HSLColor(((green - blue) / d + (green < blue ? 6 : 0)) / 6, saturation, luminace);
2559
+ return new HSLA(((green - blue) / d + (green < blue ? 6 : 0)) / 6, saturation, luminace, withAlpha ? this.alpha : void 0);
2356
2560
  if (max == green)
2357
- return new HSLColor(((blue - red) / d + 2) / 6, saturation, luminace);
2561
+ return new HSLA(((blue - red) / d + 2) / 6, saturation, luminace, withAlpha ? this.alpha : void 0);
2358
2562
  if (max == blue)
2359
- return new HSLColor(((red - green) / d + 4) / 6, saturation, luminace);
2360
- return new HSLColor(0, saturation, luminace, withAlpha ? this.alpha : void 0);
2563
+ return new HSLA(((red - green) / d + 4) / 6, saturation, luminace, withAlpha ? this.alpha : void 0);
2564
+ return new HSLA(0, saturation, luminace, withAlpha ? this.alpha : void 0);
2565
+ }
2566
+ toHSLA() {
2567
+ return this.toHSL(true);
2361
2568
  }
2362
- invert(withAlpha = false) {
2363
- return new _RGBAColor(
2569
+ invert(withAlpha = this._alpha !== 1) {
2570
+ return new _RGBA(
2364
2571
  1 - this.red,
2365
2572
  1 - this.green,
2366
2573
  1 - this.blue,
@@ -2368,7 +2575,7 @@ var RGBAColor = class _RGBAColor {
2368
2575
  );
2369
2576
  }
2370
2577
  };
2371
- var HSLColor = class _HSLColor {
2578
+ var HSLA = class _HSLA {
2372
2579
  _hue;
2373
2580
  get hue() {
2374
2581
  return this._hue;
@@ -2403,27 +2610,36 @@ var HSLColor = class _HSLColor {
2403
2610
  return value;
2404
2611
  throw new ResolveError("HSLColor", a);
2405
2612
  }
2613
+ static resolveArgs(args) {
2614
+ if (checkNumberArray(args, 3) || checkNumberArray(args, 4))
2615
+ return new this(args[0], args[1], args[2], args[3]);
2616
+ return this.resolve(args[0]);
2617
+ }
2406
2618
  static cast(a) {
2407
2619
  if (a == null || typeof a == "undefined")
2408
2620
  return void 0;
2409
- if (check_number_array(a, 3) || check_number_array(a, 4))
2621
+ if (checkNumberArray(a, 3) || checkNumberArray(a, 4))
2410
2622
  return new this(a[0], a[1], a[2], a[3]);
2411
- if (has_property(a, "hue", "number") && has_property(a, "saturation", "number") && has_property(a, "luminace", "number"))
2412
- return new this(a.hue, a.saturation, a.luminace, has_property(a, "alpha", "number") ? a.alpha : void 0);
2413
- if (check_number(a)) {
2623
+ if (hasProperty(a, "toHSL", "function"))
2624
+ return this.cast(a.toHSL());
2625
+ if (hasProperty(a, "toHSLA", "function"))
2626
+ return this.cast(a.toHSLA());
2627
+ if (hasProperty(a, "hue", "number") && hasProperty(a, "saturation", "number") && hasProperty(a, "luminace", "number"))
2628
+ return new this(a.hue, a.saturation, a.luminace, hasProperty(a, "alpha", "number") ? a.alpha : void 0);
2629
+ if (checkNumber(a)) {
2414
2630
  const hex = a.toString(16);
2415
- const convert = hex.length <= 6 ? _number_to_rgb : _number_to_rgba;
2631
+ const convert = hex.length <= 6 ? __number_to_rgb__ : __number_to_rgba__;
2416
2632
  return this.cast(convert(a));
2417
2633
  }
2418
- if (check_string(a)) {
2634
+ if (checkString(a)) {
2419
2635
  if (a.startsWith("hsl")) {
2420
2636
  const hasAlpha = a.startsWith("hsla");
2421
2637
  const offset = hasAlpha ? 5 : 4;
2422
2638
  const parts = a.substring(offset, a.indexOf(")", offset)).split(",");
2423
- if (check_string_array(parts, hasAlpha ? 4 : 3))
2639
+ if (checkStringArray(parts, hasAlpha ? 4 : 3))
2424
2640
  return this.cast(parts.map((v) => parseInt(v) / 255));
2425
2641
  }
2426
- return this.cast(_hex_to_array(a));
2642
+ return this.cast(__hex_to_array__(a));
2427
2643
  }
2428
2644
  return void 0;
2429
2645
  }
@@ -2431,39 +2647,49 @@ var HSLColor = class _HSLColor {
2431
2647
  return typeof this.cast(a) != "undefined";
2432
2648
  }
2433
2649
  constructor(hue, saturation, luminace, alpha = 1) {
2434
- if (!check_number(hue))
2650
+ if (!checkNumber(hue))
2435
2651
  throw new TypeError("expected number for hue");
2436
- if (!check_number(saturation))
2652
+ if (!checkNumber(saturation))
2437
2653
  throw new TypeError("expected number for saturation");
2438
- if (!check_number(luminace))
2654
+ if (!checkNumber(luminace))
2439
2655
  throw new TypeError("expected number for luminace");
2440
- if (!check_number(alpha))
2656
+ if (!checkNumber(alpha))
2441
2657
  throw new TypeError("expected number for alpha");
2442
2658
  this._hue = clamp(hue, 0, 1);
2443
2659
  this._saturation = clamp(saturation, 0, 1);
2444
2660
  this._luminace = clamp(luminace, 0, 1);
2445
2661
  this._alpha = clamp(alpha, 0, 1);
2446
2662
  }
2447
- toArray(withAlpha = false) {
2448
- return withAlpha ? [this.hue, this.saturation, this.luminace, this.alpha] : this.alpha == 1 ? [this.hue, this.saturation, this.luminace] : this.toArray(true);
2663
+ toArray(withAlpha = this._alpha !== 1) {
2664
+ return withAlpha ? [this.hue, this.saturation, this.luminace, this.alpha] : [this.hue, this.saturation, this.luminace];
2449
2665
  }
2450
- toJSON(withAlpha = false) {
2666
+ toJSON(withAlpha = this._alpha !== 1) {
2451
2667
  return withAlpha ? {
2452
2668
  hue: this.hue,
2453
2669
  saturation: this.saturation,
2454
2670
  luminace: this.luminace,
2455
2671
  alpha: this.alpha
2456
- } : this.alpha == 1 ? { hue: this.hue, saturation: this.saturation, luminace: this.luminace } : this.toJSON(true);
2672
+ } : {
2673
+ hue: this.hue,
2674
+ saturation: this.saturation,
2675
+ luminace: this.luminace
2676
+ };
2677
+ }
2678
+ toString(withAlpha = this._alpha !== 1) {
2679
+ return withAlpha ? `hsla(${__to_byte__(this.hue)},${__to_byte__(this.saturation)},${__to_byte__(this.luminace)},${this.alpha})` : `hsl(${__to_byte__(this.hue)},${__to_byte__(this.saturation)},${__to_byte__(this.luminace)})`;
2680
+ }
2681
+ get [Symbol.toStringTag]() {
2682
+ return "HSLA";
2457
2683
  }
2458
- toString(withAlpha = false) {
2459
- return withAlpha ? `hsla(${_fix_integer(this.hue)},${_fix_integer(this.saturation)},${_fix_integer(this.luminace)},${this.alpha})` : this.alpha == 1 ? `hsl(${_fix_integer(this.hue)},${_fix_integer(this.saturation)},${_fix_integer(this.luminace)})` : this.toString(true);
2684
+ [NodeJSCustomInspect]() {
2685
+ return `HSLA <${this.toString()}>`;
2460
2686
  }
2461
- toRGB(withAlpha = true) {
2687
+ toRGB(withAlpha = this._alpha !== 1) {
2462
2688
  if (this.saturation == 0)
2463
- return new RGBAColor(this.luminace * 255, this.luminace * 255, this.luminace * 255, withAlpha ? this.alpha : void 0);
2689
+ return new RGBA(this.luminace * 255, this.luminace * 255, this.luminace * 255, withAlpha ? this.alpha : void 0);
2464
2690
  const q = this.luminace < 0.5 ? this.luminace * (1 + this.saturation) : this.luminace + this.saturation - this.luminace * this.saturation;
2465
2691
  const p = 2 * this.luminace - q;
2466
- function _hue_2_rgb(t) {
2692
+ function __hue_2_rgb__(t) {
2467
2693
  let _t = t;
2468
2694
  if (_t < 0)
2469
2695
  _t++;
@@ -2477,10 +2703,19 @@ var HSLColor = class _HSLColor {
2477
2703
  return p + (q - p) * (2 / 3 - _t) * 6;
2478
2704
  return p;
2479
2705
  }
2480
- return new RGBAColor(_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);
2706
+ return new RGBA(__hue_2_rgb__(this.hue + 1 / 3) * 255, __hue_2_rgb__(this.hue) * 255, __hue_2_rgb__(this.hue - 1 / 3) * 255, withAlpha ? this.alpha : void 0);
2481
2707
  }
2482
- invert(withAlpha = false) {
2483
- return new _HSLColor(
2708
+ toRGBA() {
2709
+ return this.toRGB(true);
2710
+ }
2711
+ toVec2() {
2712
+ return [this.hue, this.saturation, this.luminace];
2713
+ }
2714
+ toVec3() {
2715
+ return [this.hue, this.saturation, this.luminace, this.alpha];
2716
+ }
2717
+ invert(withAlpha = this._alpha !== 1) {
2718
+ return new _HSLA(
2484
2719
  1 - this.hue,
2485
2720
  1 - this.saturation,
2486
2721
  1 - this.luminace,
@@ -2488,33 +2723,44 @@ var HSLColor = class _HSLColor {
2488
2723
  );
2489
2724
  }
2490
2725
  };
2491
- function resolveColor(a, preferHSL = false) {
2492
- const value = castColor(a, preferHSL);
2493
- if (typeof value != "undefined")
2494
- return value;
2495
- throw new ResolveError("Color", a);
2496
- }
2497
- function castColor(a, preferHSL = false) {
2498
- const results = [];
2499
- try {
2500
- const rgba = RGBAColor.resolve(a);
2501
- results.push(rgba);
2502
- } catch (e) {
2503
- }
2504
- try {
2505
- const hsla = HSLColor.resolve(a);
2506
- results.push(hsla);
2507
- } catch (e) {
2508
- }
2509
- let offset = preferHSL ? 1 : 0;
2510
- const firstItem = results[offset];
2511
- if (firstItem)
2512
- return firstItem;
2513
- const secondItem = results[offset + 1];
2514
- if (secondItem)
2515
- return secondItem;
2516
- return void 0;
2517
- }
2726
+ var AnyColor;
2727
+ ((AnyColor2) => {
2728
+ function cast(a, preferHSL = false) {
2729
+ const results = [];
2730
+ try {
2731
+ const rgba = RGBA.resolve(a);
2732
+ results.push(rgba);
2733
+ } catch (e) {
2734
+ }
2735
+ try {
2736
+ const hsla = HSLA.resolve(a);
2737
+ results.push(hsla);
2738
+ } catch (e) {
2739
+ }
2740
+ let offset = preferHSL ? 1 : 0;
2741
+ const firstItem = results[offset];
2742
+ if (firstItem)
2743
+ return firstItem;
2744
+ const secondItem = results[offset + 1];
2745
+ if (secondItem)
2746
+ return secondItem;
2747
+ return void 0;
2748
+ }
2749
+ AnyColor2.cast = cast;
2750
+ function resolve(a, preferHSL = false) {
2751
+ const value = cast(a, preferHSL);
2752
+ if (typeof value != "undefined")
2753
+ return value;
2754
+ throw new ResolveError("Color", a);
2755
+ }
2756
+ AnyColor2.resolve = resolve;
2757
+ function resolveArgs(args, preferHSL = false) {
2758
+ if (checkNumberArray(args, 3) || checkNumberArray(args, 4))
2759
+ return resolve(args, preferHSL);
2760
+ return resolve(args[0], preferHSL);
2761
+ }
2762
+ AnyColor2.resolveArgs = resolveArgs;
2763
+ })(AnyColor || (AnyColor = {}));
2518
2764
 
2519
2765
  // source/quaternion.ts
2520
2766
  var Quaternion = class _Quaternion {
@@ -2531,16 +2777,23 @@ var Quaternion = class _Quaternion {
2531
2777
  return value;
2532
2778
  throw new ResolveError("Quaternion", a);
2533
2779
  }
2780
+ static resolveArgs(args) {
2781
+ if (checkNumberArray(args, 4))
2782
+ return new this(args[0], args[1], args[2], args[3]);
2783
+ return this.resolve(args[0]);
2784
+ }
2534
2785
  static cast(a) {
2535
2786
  if (a == null || typeof a == "undefined")
2536
2787
  return void 0;
2537
- if (check_number_array(a, 4))
2788
+ if (checkNumberArray(a, 4))
2538
2789
  return new this(a[0], a[1], a[2], a[3]);
2539
- if (has_property(a, "w", "number") && has_property(a, "x", "number") && has_property(a, "y", "number") && has_property(a, "z", "number"))
2790
+ if (hasProperty(a, "toQuaternion", "function"))
2791
+ return this.cast(a.toQuaternion());
2792
+ if (hasProperty(a, "w", "number") && hasProperty(a, "x", "number") && hasProperty(a, "y", "number") && hasProperty(a, "z", "number"))
2540
2793
  return new this(a.w, a.x, a.y, a.z);
2541
- if (check_string(a)) {
2794
+ if (checkString(a)) {
2542
2795
  const parts = a.replaceAll(" ", "").split("+");
2543
- if (check_string_array(parts, 4)) {
2796
+ if (checkStringArray(parts, 4)) {
2544
2797
  const [sw, sxi, syj, szk] = parts;
2545
2798
  if (sxi.endsWith("i") && syj.endsWith("j") && szk.endsWith("k"))
2546
2799
  return this.cast([
@@ -2553,7 +2806,9 @@ var Quaternion = class _Quaternion {
2553
2806
  }
2554
2807
  return void 0;
2555
2808
  }
2556
- static fromAxisAngle(axis, angle) {
2809
+ static fromAxisAngle(...args) {
2810
+ const axis = checkNumberArray(args, 4) ? new Vec3(args[0], args[1], args[2]) : Vec3.resolve(args[0]);
2811
+ const angle = checkNumberArray(args, 4) ? args[3] : args[1];
2557
2812
  const vec = Vec3.resolve(axis);
2558
2813
  const hangle = angle * 0.5;
2559
2814
  const sin2 = Math.sin(hangle);
@@ -2573,14 +2828,17 @@ var Quaternion = class _Quaternion {
2573
2828
  sx * sy * cz + sz * cx * cy
2574
2829
  );
2575
2830
  }
2576
- constructor(w = 0, x = 0, y = 0, z = 0) {
2577
- if (!check_number(w))
2831
+ static get zero() {
2832
+ return new _Quaternion(0, 0, 0, 0);
2833
+ }
2834
+ constructor(w, x, y, z) {
2835
+ if (!checkNumber(w))
2578
2836
  throw new TypeError("expected number for w");
2579
- if (!check_number(x))
2837
+ if (!checkNumber(x))
2580
2838
  throw new TypeError("expected number for x");
2581
- if (!check_number(y))
2839
+ if (!checkNumber(y))
2582
2840
  throw new TypeError("expected number for x");
2583
- if (!check_number(z))
2841
+ if (!checkNumber(z))
2584
2842
  throw new TypeError("expected number for w");
2585
2843
  this.w = w;
2586
2844
  this.x = x;
@@ -2593,6 +2851,12 @@ var Quaternion = class _Quaternion {
2593
2851
  toString() {
2594
2852
  return `${this.w} + ${this.x}i + ${this.y}j + ${this.z}k`;
2595
2853
  }
2854
+ get [Symbol.toStringTag]() {
2855
+ return "Quaternion";
2856
+ }
2857
+ [NodeJSCustomInspect]() {
2858
+ return `Quaternion <${this.toString()}>`;
2859
+ }
2596
2860
  toJSON() {
2597
2861
  return {
2598
2862
  w: this.w,
@@ -2604,8 +2868,8 @@ var Quaternion = class _Quaternion {
2604
2868
  clone() {
2605
2869
  return new _Quaternion(this.w, this.x, this.y, this.z);
2606
2870
  }
2607
- add(a) {
2608
- const quat = _Quaternion.resolve(a);
2871
+ add(...args) {
2872
+ const quat = _Quaternion.resolveArgs(args);
2609
2873
  return new _Quaternion(
2610
2874
  this.w + quat.w,
2611
2875
  this.x + quat.x,
@@ -2613,16 +2877,16 @@ var Quaternion = class _Quaternion {
2613
2877
  this.z + quat.z
2614
2878
  );
2615
2879
  }
2616
- offset(a) {
2617
- const quat = _Quaternion.resolve(a);
2880
+ offset(...args) {
2881
+ const quat = _Quaternion.resolveArgs(args);
2618
2882
  this.w += quat.w;
2619
2883
  this.x += quat.x;
2620
2884
  this.y += quat.y;
2621
2885
  this.z += quat.z;
2622
2886
  return this;
2623
2887
  }
2624
- subtract(a) {
2625
- const quat = _Quaternion.resolve(a);
2888
+ subtract(...args) {
2889
+ const quat = _Quaternion.resolveArgs(args);
2626
2890
  return new _Quaternion(
2627
2891
  this.w - quat.w,
2628
2892
  this.x - quat.x,
@@ -2640,12 +2904,12 @@ var Quaternion = class _Quaternion {
2640
2904
  normalize() {
2641
2905
  let length = this.length();
2642
2906
  if (length < EPSILON)
2643
- return new _Quaternion();
2907
+ return _Quaternion.zero;
2644
2908
  length = 1 / length;
2645
2909
  return new _Quaternion(this.w * length, this.x * length, this.y * length, this.z * length);
2646
2910
  }
2647
- multiply(a) {
2648
- const quat = _Quaternion.resolve(a);
2911
+ multiply(...args) {
2912
+ const quat = _Quaternion.resolveArgs(args);
2649
2913
  return new _Quaternion(
2650
2914
  this.w * quat.w - this.x * quat.x - this.y * quat.y - this.z * quat.z,
2651
2915
  this.w * quat.x + this.x * quat.w + this.y * quat.z - this.z * quat.y,
@@ -2668,21 +2932,21 @@ var Quaternion = class _Quaternion {
2668
2932
  scale(scalar) {
2669
2933
  return new _Quaternion(this.w * scalar, this.x * scalar, this.y * scalar, this.z * scalar);
2670
2934
  }
2671
- dot(a) {
2672
- const quat = _Quaternion.resolve(a);
2935
+ dot(...args) {
2936
+ const quat = _Quaternion.resolveArgs(args);
2673
2937
  return this.w * quat.w + this.x * quat.x + this.y * quat.y + this.z * quat.z;
2674
2938
  }
2675
2939
  inverse() {
2676
2940
  let length = this.length(false);
2677
2941
  if (length == 0)
2678
- return new _Quaternion();
2942
+ return _Quaternion.zero;
2679
2943
  length = 1 / length;
2680
2944
  return new _Quaternion(this.w * length, -this.x * length, -this.y * length, -this.z * length);
2681
2945
  }
2682
- divide(a) {
2683
- const quat = _Quaternion.resolve(a);
2946
+ divide(...args) {
2947
+ const quat = _Quaternion.resolveArgs(args);
2684
2948
  let length = quat.length(false);
2685
- if (length == 0) return new _Quaternion();
2949
+ if (length == 0) return _Quaternion.zero;
2686
2950
  length = 1 / length;
2687
2951
  return new _Quaternion(
2688
2952
  (this.w * quat.w + this.x * quat.x + this.y * quat.y + this.z * quat.z) * length,
@@ -2699,7 +2963,7 @@ var Quaternion = class _Quaternion {
2699
2963
  const exp = Math.exp(this.w);
2700
2964
  const scale = exp * Math.sin(length) / length;
2701
2965
  if (length == 0)
2702
- return new _Quaternion(exp);
2966
+ return new _Quaternion(exp, 0, 0, 0);
2703
2967
  return new _Quaternion(
2704
2968
  exp * Math.cos(length),
2705
2969
  this.x * scale,
@@ -2709,14 +2973,14 @@ var Quaternion = class _Quaternion {
2709
2973
  }
2710
2974
  log() {
2711
2975
  if (this.x == 0 && this.z == 0)
2712
- return new _Quaternion(log_hypot(this.w, this.x), Math.atan2(this.x, this.w));
2976
+ return new _Quaternion(logHypot(this.w, this.x), Math.atan2(this.x, this.w), 0, 0);
2713
2977
  const length = this.length(false);
2714
2978
  const length2 = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
2715
2979
  const scale = Math.atan2(length2, this.w) / length;
2716
2980
  return new _Quaternion(Math.log(length) * 0.5, this.x * scale, this.y * scale, this.z * scale);
2717
2981
  }
2718
- toVector() {
2719
- return new Vec3(this.x, this.y, this.z, this.w);
2982
+ toVec3() {
2983
+ return [this.x, this.y, this.z, this.w];
2720
2984
  }
2721
2985
  toAxisAngle() {
2722
2986
  const sin2 = 1 - this.w * this.w;
@@ -2727,17 +2991,17 @@ var Quaternion = class _Quaternion {
2727
2991
  return new Vec3(this.x * isin, this.y * isin, this.z * isin, angle);
2728
2992
  }
2729
2993
  toEuler() {
2730
- function asin(t) {
2994
+ function __asin__(t) {
2731
2995
  return t >= 1 ? Math.PI / 2 : t <= -1 ? -Math.PI / 2 : Math.asin(t);
2732
2996
  }
2733
2997
  return new Vec3(
2734
2998
  -Math.atan2(2 * (this.y * this.z - this.w * this.x), 1 - 2 * (this.x * this.x + this.y * this.y)),
2735
- asin(2 * (this.x * this.z + this.w * this.y)),
2999
+ __asin__(2 * (this.x * this.z + this.w * this.y)),
2736
3000
  -Math.atan2(2 * (this.x * this.y - this.w * this.z), 1 - 2 * (this.y * this.y + this.z * this.z))
2737
3001
  );
2738
3002
  }
2739
3003
  toMat3() {
2740
- return new Mat3([
3004
+ return [
2741
3005
  1 - 2 * (this.y * this.y + this.z * this.z),
2742
3006
  2 * (this.x * this.y - this.w * this.z),
2743
3007
  2 * (this.x * this.z + this.w * this.y),
@@ -2747,10 +3011,10 @@ var Quaternion = class _Quaternion {
2747
3011
  2 * (this.x * this.z - this.w * this.y),
2748
3012
  2 * (this.y * this.z + this.w * this.x),
2749
3013
  1 - 2 * (this.x * this.x + this.y * this.y)
2750
- ]);
3014
+ ];
2751
3015
  }
2752
3016
  toMat4() {
2753
- return new Mat4([
3017
+ return [
2754
3018
  1 - 2 * (this.y * this.y + this.z * this.z),
2755
3019
  2 * (this.x * this.y - this.w * this.z),
2756
3020
  2 * (this.x * this.z + this.w * this.y),
@@ -2767,89 +3031,205 @@ var Quaternion = class _Quaternion {
2767
3031
  0,
2768
3032
  0,
2769
3033
  1
2770
- ]);
3034
+ ];
2771
3035
  }
2772
3036
  };
2773
3037
 
2774
3038
  // source/transform.ts
2775
- var Transform = class {
3039
+ var Transform2D = class {
3040
+ constructor(position, rotation, scale, parent) {
3041
+ this.parent = parent;
3042
+ this.localPosition = Vec2.resolve(position);
3043
+ this.localRotation = rotation;
3044
+ this.localScale = Vec2.resolve(scale);
3045
+ }
3046
+ origin = Vec2.zero;
3047
+ localPosition;
3048
+ localRotation;
3049
+ get localRotationDegree() {
3050
+ return radianToDegree(this.localRotation);
3051
+ }
3052
+ set localRotationDegree(v) {
3053
+ this.localRotation = degreeToRadian(v);
3054
+ }
3055
+ localScale;
3056
+ get globalPosition() {
3057
+ let position = Vec2.zero;
3058
+ let transform = this;
3059
+ while (transform !== void 0) {
3060
+ position = position.add(transform.localPosition).add(transform.origin);
3061
+ transform = transform.parent;
3062
+ }
3063
+ return position;
3064
+ }
3065
+ get globalRotation() {
3066
+ let rotation = 0;
3067
+ let transform = this;
3068
+ while (transform !== void 0) {
3069
+ rotation += transform.localRotation;
3070
+ transform = transform.parent;
3071
+ }
3072
+ return rotation;
3073
+ }
3074
+ get globalRotationDegree() {
3075
+ return radianToDegree(this.globalRotation);
3076
+ }
3077
+ get globalScale() {
3078
+ let scale = Vec2.one;
3079
+ let transform = this;
3080
+ while (transform !== void 0) {
3081
+ scale = scale.naiveMultiply(transform.localScale);
3082
+ transform = transform.parent;
3083
+ }
3084
+ return scale;
3085
+ }
3086
+ toString() {
3087
+ return `${this.localPosition.toString()}|${this.localRotation}|${this.localScale.toString()}`;
3088
+ }
3089
+ get [Symbol.toStringTag]() {
3090
+ return "Transform2D";
3091
+ }
3092
+ [NodeJSCustomInspect]() {
3093
+ return `Transform2D <${this.toString()}>`;
3094
+ }
3095
+ toMat3() {
3096
+ return new Mat3().scale(this.localScale).rotate(this.localRotation).translate(this.localPosition);
3097
+ }
3098
+ toGlobalMat3() {
3099
+ let result = new Mat3();
3100
+ let transform = this;
3101
+ while (transform !== void 0) {
3102
+ result = result.multiply(transform.toMat3());
3103
+ transform = transform.parent;
3104
+ }
3105
+ return result;
3106
+ }
3107
+ };
3108
+ var Transform3D = class {
2776
3109
  /**
2777
- * The position of the object
3110
+ * Create a new transform with `position`, `rotation` and `scale`
3111
+ * @param position The position as a Vec3
3112
+ * @param rotation The rotation as a Quaternion
3113
+ * @param scale The scale as a Vec3
2778
3114
  */
2779
- position;
3115
+ constructor(position, rotation, scale, parent) {
3116
+ this.parent = parent;
3117
+ this.localPosition = Vec3.resolve(position);
3118
+ this.localRotation = Quaternion.resolve(rotation);
3119
+ this.localScale = Vec3.resolve(scale);
3120
+ }
3121
+ origin = Vec3.zero;
2780
3122
  /**
2781
- * The rotation of the object
3123
+ * The local position
2782
3124
  */
2783
- rotation;
3125
+ localPosition;
2784
3126
  /**
2785
- * The scale of the object
3127
+ * The local rotation
2786
3128
  */
2787
- scale;
3129
+ localRotation;
2788
3130
  /**
2789
- * Create a new transform with `position`, `rotation` and `scale`
2790
- * @param position The position as a Vec3
2791
- * @param rotation The rotation as a Quaternion
2792
- * @param scale The scale as a Vec3
3131
+ * The local scale
2793
3132
  */
2794
- constructor(position, rotation, scale) {
2795
- this.position = Vec3.resolve(position);
2796
- this.rotation = Quaternion.resolve(rotation);
2797
- this.scale = Vec3.resolve(scale);
3133
+ localScale;
3134
+ get globalPosition() {
3135
+ let position = Vec3.zero;
3136
+ let transform = this;
3137
+ while (transform !== void 0) {
3138
+ position = position.add(transform.localPosition).add(transform.origin);
3139
+ transform = transform.parent;
3140
+ }
3141
+ return position;
3142
+ }
3143
+ get globalRotation() {
3144
+ let rotation = Quaternion.zero;
3145
+ let transform = this;
3146
+ while (transform !== void 0) {
3147
+ rotation = rotation.add(transform.localRotation);
3148
+ transform = transform.parent;
3149
+ }
3150
+ return rotation;
3151
+ }
3152
+ get globalScale() {
3153
+ let scale = Vec3.one;
3154
+ let transform = this;
3155
+ while (transform !== void 0) {
3156
+ scale = scale.naiveMultiply(transform.localScale);
3157
+ transform = transform.parent;
3158
+ }
3159
+ return scale;
3160
+ }
3161
+ toString() {
3162
+ return `${this.localPosition.toString()}|${this.localRotation.toString()}|${this.localScale.toString()}`;
3163
+ }
3164
+ get [Symbol.toStringTag]() {
3165
+ return "Transform2D";
3166
+ }
3167
+ [NodeJSCustomInspect]() {
3168
+ return `Transform2D <${this.toString()}>`;
2798
3169
  }
2799
3170
  /**
2800
3171
  * Convert the transform into a 4x3 matrix
2801
3172
  * @returns A 4x4 matrix from the transform
2802
3173
  */
2803
3174
  toMat4() {
2804
- return new Mat4().translate(this.position).multiply(this.rotation.toMat4()).scale(this.scale);
3175
+ return new Mat4().scale(this.localScale).multiply(this.localRotation).translate(this.localPosition);
3176
+ }
3177
+ toGlobalMat4() {
3178
+ let result = new Mat4();
3179
+ let transform = this;
3180
+ while (transform !== void 0) {
3181
+ result = result.multiply(transform.toMat4());
3182
+ transform = transform.parent;
3183
+ }
3184
+ return result;
2805
3185
  }
2806
3186
  };
2807
3187
  export {
2808
- ATriangle,
3188
+ AnyColor,
2809
3189
  BoundingBox,
2810
3190
  Circle,
2811
3191
  DJB2_OFFSET,
2812
3192
  EPSILON,
2813
3193
  FNV1_OFFSET,
2814
3194
  FNV1_PRIME,
2815
- HSLColor,
3195
+ HSLA,
2816
3196
  LinearFunction,
2817
3197
  MAX_ANGLE_DEGREE,
2818
3198
  MD2,
2819
3199
  Mat3,
2820
3200
  Mat4,
2821
3201
  MathFunction,
3202
+ NodeJSCustomInspect,
2822
3203
  QuadFunction,
2823
3204
  Quaternion,
2824
- RGBAColor,
3205
+ RGBA,
2825
3206
  Rectangle,
2826
3207
  ResolveError,
2827
3208
  Size,
2828
- Transform,
3209
+ Transform2D,
3210
+ Transform3D,
3211
+ Triangle,
2829
3212
  Triangle2D,
2830
3213
  Triangle3D,
2831
3214
  Vec2,
2832
3215
  Vec3,
2833
- cap_angle_degree,
2834
- cap_angle_radian,
2835
- castColor,
2836
- check_array,
2837
- check_hex,
2838
- check_hex_digit,
2839
- check_number,
2840
- check_number_array,
2841
- check_string,
2842
- check_string_array,
3216
+ checkArray,
3217
+ checkHex,
3218
+ checkNumber,
3219
+ checkNumberArray,
3220
+ checkString,
3221
+ checkStringArray,
2843
3222
  clamp,
2844
- degree_to_radian,
3223
+ clampAngleDegree,
3224
+ clampAngleRadian,
3225
+ degreeToRadian,
2845
3226
  djb2,
2846
3227
  fnv1,
2847
- get_hex_part,
2848
- has_property,
2849
- log_hypot,
2850
- radian_to_degree,
2851
- resolveColor,
3228
+ getHexValue,
3229
+ hasProperty,
3230
+ lerp,
3231
+ logHypot,
3232
+ radianToDegree,
2852
3233
  sdbm,
2853
- sign_char,
2854
- stringify
3234
+ signCharacter
2855
3235
  };