@bitbybit-dev/base 1.3.2-rc.1 → 1.4.0-rc.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.
Files changed (77) hide show
  1. package/README.md +1 -1
  2. package/lib/api/GlobalCDNProvider.js +1 -1
  3. package/lib/api/index.d.ts +2 -0
  4. package/lib/api/index.js +2 -0
  5. package/lib/api/inputs/base-inputs.d.ts +10 -4
  6. package/lib/api/inputs/color-inputs.d.ts +24 -23
  7. package/lib/api/inputs/color-inputs.js +1 -0
  8. package/lib/api/inputs/dates-inputs.d.ts +16 -16
  9. package/lib/api/inputs/frame-inputs.d.ts +515 -0
  10. package/lib/api/inputs/frame-inputs.js +617 -0
  11. package/lib/api/inputs/index.d.ts +1 -0
  12. package/lib/api/inputs/index.js +1 -0
  13. package/lib/api/inputs/io-inputs.d.ts +3 -3
  14. package/lib/api/inputs/io-inputs.js +1 -1
  15. package/lib/api/inputs/lists-inputs.d.ts +23 -23
  16. package/lib/api/inputs/logic-inputs.d.ts +11 -11
  17. package/lib/api/inputs/math-inputs.d.ts +49 -49
  18. package/lib/api/inputs/math-inputs.js +4 -4
  19. package/lib/api/inputs/mesh-inputs.d.ts +3 -3
  20. package/lib/api/inputs/mesh-inputs.js +3 -3
  21. package/lib/api/inputs/point-inputs.d.ts +39 -38
  22. package/lib/api/inputs/point-inputs.js +6 -5
  23. package/lib/api/inputs/polyline-inputs.d.ts +5 -4
  24. package/lib/api/inputs/polyline-inputs.js +3 -3
  25. package/lib/api/inputs/text-inputs.d.ts +34 -33
  26. package/lib/api/inputs/text-inputs.js +15 -12
  27. package/lib/api/inputs/transforms-inputs.d.ts +16 -16
  28. package/lib/api/inputs/vector-inputs.d.ts +26 -25
  29. package/lib/api/inputs/vector-inputs.js +2 -1
  30. package/lib/api/kernel-calls/call-by-path.d.ts +12 -0
  31. package/lib/api/kernel-calls/call-by-path.js +36 -0
  32. package/lib/api/kernel-calls/constraints.d.ts +53 -0
  33. package/lib/api/kernel-calls/constraints.js +21 -0
  34. package/lib/api/kernel-calls/describe-failure.d.ts +32 -0
  35. package/lib/api/kernel-calls/describe-failure.js +164 -0
  36. package/lib/api/kernel-calls/errors.d.ts +55 -0
  37. package/lib/api/kernel-calls/errors.js +42 -0
  38. package/lib/api/kernel-calls/failure-message.d.ts +18 -0
  39. package/lib/api/kernel-calls/failure-message.js +36 -0
  40. package/lib/api/kernel-calls/index.d.ts +10 -0
  41. package/lib/api/kernel-calls/index.js +10 -0
  42. package/lib/api/kernel-calls/input-rules.d.ts +67 -0
  43. package/lib/api/kernel-calls/input-rules.js +135 -0
  44. package/lib/api/kernel-calls/input-validation.d.ts +130 -0
  45. package/lib/api/kernel-calls/input-validation.js +221 -0
  46. package/lib/api/kernel-calls/rehydrate.d.ts +16 -0
  47. package/lib/api/kernel-calls/rehydrate.js +38 -0
  48. package/lib/api/kernel-calls/resolve-dto.d.ts +59 -0
  49. package/lib/api/kernel-calls/resolve-dto.js +61 -0
  50. package/lib/api/kernel-calls/with-defaults.d.ts +16 -0
  51. package/lib/api/kernel-calls/with-defaults.js +53 -0
  52. package/lib/api/resolved-inputs/index.d.ts +304 -0
  53. package/lib/api/resolved-inputs/index.js +1 -0
  54. package/lib/api/services/color.js +43 -26
  55. package/lib/api/services/dates.js +53 -33
  56. package/lib/api/services/frame.d.ts +670 -0
  57. package/lib/api/services/frame.js +1040 -0
  58. package/lib/api/services/helpers/dxf/dxf-generator.d.ts +2 -3
  59. package/lib/api/services/helpers/dxf/dxf-generator.js +27 -37
  60. package/lib/api/services/helpers/dxf/dxf.js +10 -4
  61. package/lib/api/services/helpers/frame-axes.d.ts +36 -0
  62. package/lib/api/services/helpers/frame-axes.js +57 -0
  63. package/lib/api/services/helpers/matrices.d.ts +17 -0
  64. package/lib/api/services/helpers/matrices.js +51 -0
  65. package/lib/api/services/index.d.ts +1 -0
  66. package/lib/api/services/index.js +1 -0
  67. package/lib/api/services/line.js +15 -12
  68. package/lib/api/services/lists.js +174 -136
  69. package/lib/api/services/logic.js +44 -34
  70. package/lib/api/services/math.js +127 -82
  71. package/lib/api/services/mesh.js +20 -13
  72. package/lib/api/services/point.js +62 -46
  73. package/lib/api/services/polyline.js +22 -18
  74. package/lib/api/services/text.js +81 -46
  75. package/lib/api/services/transforms.js +38 -25
  76. package/lib/api/services/vector.js +37 -22
  77. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import * as Inputs from "../inputs";
2
2
  import { defaultsVectorParams } from "../models/simplex";
3
+ import { resolveDto } from "../kernel-calls";
3
4
  /**
4
5
  * Working with text: splitting, joining, searching, trimming, padding, changing case, regular
5
6
  * expressions and formatting with placeholders. `vectorChar` and `vectorText` turn text into line
@@ -21,7 +22,8 @@ export class TextBitByBit {
21
22
  * @drawable false
22
23
  */
23
24
  create(inputs) {
24
- return inputs.text;
25
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
26
+ return resolved.text;
25
27
  }
26
28
  /**
27
29
  * Cuts a text into pieces wherever a separator occurs; the separator itself is dropped.
@@ -38,7 +40,8 @@ export class TextBitByBit {
38
40
  * ```
39
41
  */
40
42
  split(inputs) {
41
- return inputs.text.split(inputs.separator);
43
+ const resolved = resolveDto(Inputs.Text.TextSplitDto, inputs);
44
+ return resolved.text.split(resolved.separator);
42
45
  }
43
46
  /**
44
47
  * Replaces every occurrence of a search text with another text.
@@ -55,7 +58,8 @@ export class TextBitByBit {
55
58
  * ```
56
59
  */
57
60
  replaceAll(inputs) {
58
- return inputs.text.split(inputs.search).join(inputs.replaceWith);
61
+ const resolved = resolveDto(Inputs.Text.TextReplaceDto, inputs);
62
+ return resolved.text.split(resolved.search).join(resolved.replaceWith);
59
63
  }
60
64
  /**
61
65
  * Joins a list of texts into one, with a separator between neighbors.
@@ -72,7 +76,8 @@ export class TextBitByBit {
72
76
  * ```
73
77
  */
74
78
  join(inputs) {
75
- return inputs.list.join(inputs.separator);
79
+ const resolved = resolveDto(Inputs.Text.TextJoinDto, inputs);
80
+ return resolved.list.join(resolved.separator);
76
81
  }
77
82
  /**
78
83
  * Turns any value into text, the way JavaScript prints it.
@@ -117,8 +122,9 @@ export class TextBitByBit {
117
122
  * ```
118
123
  */
119
124
  format(inputs) {
120
- return inputs.text.replace(/{(\d+)}/g, (match, number) => {
121
- return typeof inputs.values[number] !== "undefined" ? inputs.values[number] : match;
125
+ const resolved = resolveDto(Inputs.Text.TextFormatDto, inputs);
126
+ return resolved.text.replace(/{(\d+)}/g, (match, number) => {
127
+ return typeof resolved.values[number] !== "undefined" ? resolved.values[number] : match;
122
128
  });
123
129
  }
124
130
  /**
@@ -136,7 +142,8 @@ export class TextBitByBit {
136
142
  * ```
137
143
  */
138
144
  includes(inputs) {
139
- return inputs.text.includes(inputs.search);
145
+ const resolved = resolveDto(Inputs.Text.TextSearchDto, inputs);
146
+ return resolved.text.includes(resolved.search);
140
147
  }
141
148
  /**
142
149
  * Tells whether a text begins with a search text.
@@ -153,7 +160,8 @@ export class TextBitByBit {
153
160
  * ```
154
161
  */
155
162
  startsWith(inputs) {
156
- return inputs.text.startsWith(inputs.search);
163
+ const resolved = resolveDto(Inputs.Text.TextSearchDto, inputs);
164
+ return resolved.text.startsWith(resolved.search);
157
165
  }
158
166
  /**
159
167
  * Tells whether a text ends with a search text.
@@ -170,7 +178,8 @@ export class TextBitByBit {
170
178
  * ```
171
179
  */
172
180
  endsWith(inputs) {
173
- return inputs.text.endsWith(inputs.search);
181
+ const resolved = resolveDto(Inputs.Text.TextSearchDto, inputs);
182
+ return resolved.text.endsWith(resolved.search);
174
183
  }
175
184
  /**
176
185
  * Finds where a search text first occurs, counting characters from 0, or -1 when it does not
@@ -188,7 +197,8 @@ export class TextBitByBit {
188
197
  * ```
189
198
  */
190
199
  indexOf(inputs) {
191
- return inputs.text.indexOf(inputs.search);
200
+ const resolved = resolveDto(Inputs.Text.TextSearchDto, inputs);
201
+ return resolved.text.indexOf(resolved.search);
192
202
  }
193
203
  /**
194
204
  * Finds where a search text last occurs, counting characters from 0, or -1 when it does not
@@ -206,7 +216,8 @@ export class TextBitByBit {
206
216
  * ```
207
217
  */
208
218
  lastIndexOf(inputs) {
209
- return inputs.text.lastIndexOf(inputs.search);
219
+ const resolved = resolveDto(Inputs.Text.TextSearchDto, inputs);
220
+ return resolved.text.lastIndexOf(resolved.search);
210
221
  }
211
222
  /**
212
223
  * Takes the characters from a start position up to, but not including, an end position.
@@ -224,7 +235,8 @@ export class TextBitByBit {
224
235
  * ```
225
236
  */
226
237
  substring(inputs) {
227
- return inputs.text.substring(inputs.start, inputs.end);
238
+ const resolved = resolveDto(Inputs.Text.TextSubstringDto, inputs);
239
+ return resolved.text.substring(resolved.start, resolved.end);
228
240
  }
229
241
  /**
230
242
  * Takes the characters from a start position up to, but not including, an end position.
@@ -242,7 +254,8 @@ export class TextBitByBit {
242
254
  * ```
243
255
  */
244
256
  slice(inputs) {
245
- return inputs.text.slice(inputs.start, inputs.end);
257
+ const resolved = resolveDto(Inputs.Text.TextSubstringDto, inputs);
258
+ return resolved.text.slice(resolved.start, resolved.end);
246
259
  }
247
260
  /**
248
261
  * Reads the character at a position, counting from 0.
@@ -259,7 +272,8 @@ export class TextBitByBit {
259
272
  * ```
260
273
  */
261
274
  charAt(inputs) {
262
- return inputs.text.charAt(inputs.index);
275
+ const resolved = resolveDto(Inputs.Text.TextIndexDto, inputs);
276
+ return resolved.text.charAt(resolved.index);
263
277
  }
264
278
  /**
265
279
  * Removes spaces, tabs and line breaks from both ends of a text.
@@ -272,7 +286,8 @@ export class TextBitByBit {
272
286
  * @drawable false
273
287
  */
274
288
  trim(inputs) {
275
- return inputs.text.trim();
289
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
290
+ return resolved.text.trim();
276
291
  }
277
292
  /**
278
293
  * Removes spaces, tabs and line breaks from the start of a text.
@@ -285,7 +300,8 @@ export class TextBitByBit {
285
300
  * @drawable false
286
301
  */
287
302
  trimStart(inputs) {
288
- return inputs.text.trimStart();
303
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
304
+ return resolved.text.trimStart();
289
305
  }
290
306
  /**
291
307
  * Removes spaces, tabs and line breaks from the end of a text.
@@ -298,7 +314,8 @@ export class TextBitByBit {
298
314
  * @drawable false
299
315
  */
300
316
  trimEnd(inputs) {
301
- return inputs.text.trimEnd();
317
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
318
+ return resolved.text.trimEnd();
302
319
  }
303
320
  /**
304
321
  * Adds a filler text in front until the text reaches a length; a text already that long is left
@@ -316,7 +333,8 @@ export class TextBitByBit {
316
333
  * ```
317
334
  */
318
335
  padStart(inputs) {
319
- return inputs.text.padStart(inputs.length, inputs.padString);
336
+ const resolved = resolveDto(Inputs.Text.TextPadDto, inputs);
337
+ return resolved.text.padStart(resolved.length, resolved.padString);
320
338
  }
321
339
  /**
322
340
  * Adds a filler text behind until the text reaches a length; a text already that long is left
@@ -334,7 +352,8 @@ export class TextBitByBit {
334
352
  * ```
335
353
  */
336
354
  padEnd(inputs) {
337
- return inputs.text.padEnd(inputs.length, inputs.padString);
355
+ const resolved = resolveDto(Inputs.Text.TextPadDto, inputs);
356
+ return resolved.text.padEnd(resolved.length, resolved.padString);
338
357
  }
339
358
  /**
340
359
  * Turns every letter into a capital.
@@ -347,7 +366,8 @@ export class TextBitByBit {
347
366
  * @drawable false
348
367
  */
349
368
  toUpperCase(inputs) {
350
- return inputs.text.toUpperCase();
369
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
370
+ return resolved.text.toUpperCase();
351
371
  }
352
372
  /**
353
373
  * Turns every letter into lower case.
@@ -360,7 +380,8 @@ export class TextBitByBit {
360
380
  * @drawable false
361
381
  */
362
382
  toLowerCase(inputs) {
363
- return inputs.text.toLowerCase();
383
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
384
+ return resolved.text.toLowerCase();
364
385
  }
365
386
  /**
366
387
  * Turns the first character into a capital and leaves the rest as it is.
@@ -373,9 +394,10 @@ export class TextBitByBit {
373
394
  * @drawable false
374
395
  */
375
396
  toUpperCaseFirst(inputs) {
376
- if (!inputs.text)
377
- return inputs.text;
378
- return inputs.text.charAt(0).toUpperCase() + inputs.text.slice(1);
397
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
398
+ if (!resolved.text)
399
+ return resolved.text;
400
+ return resolved.text.charAt(0).toUpperCase() + resolved.text.slice(1);
379
401
  }
380
402
  /**
381
403
  * Turns the first character into lower case and leaves the rest as it is.
@@ -388,9 +410,10 @@ export class TextBitByBit {
388
410
  * @drawable false
389
411
  */
390
412
  toLowerCaseFirst(inputs) {
391
- if (!inputs.text)
392
- return inputs.text;
393
- return inputs.text.charAt(0).toLowerCase() + inputs.text.slice(1);
413
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
414
+ if (!resolved.text)
415
+ return resolved.text;
416
+ return resolved.text.charAt(0).toLowerCase() + resolved.text.slice(1);
394
417
  }
395
418
  /**
396
419
  * Repeats a text a number of times, end to end.
@@ -407,7 +430,8 @@ export class TextBitByBit {
407
430
  * ```
408
431
  */
409
432
  repeat(inputs) {
410
- return inputs.text.repeat(inputs.count);
433
+ const resolved = resolveDto(Inputs.Text.TextRepeatDto, inputs);
434
+ return resolved.text.repeat(resolved.count);
411
435
  }
412
436
  /**
413
437
  * Reverses the order of the characters.
@@ -420,7 +444,8 @@ export class TextBitByBit {
420
444
  * @drawable false
421
445
  */
422
446
  reverse(inputs) {
423
- return inputs.text.split("").reverse().join("");
447
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
448
+ return resolved.text.split("").reverse().join("");
424
449
  }
425
450
  /**
426
451
  * Counts the characters in a text.
@@ -433,7 +458,8 @@ export class TextBitByBit {
433
458
  * @drawable false
434
459
  */
435
460
  length(inputs) {
436
- return inputs.text.length;
461
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
462
+ return resolved.text.length;
437
463
  }
438
464
  /**
439
465
  * Tells whether a text is empty or holds only whitespace.
@@ -446,7 +472,8 @@ export class TextBitByBit {
446
472
  * @drawable false
447
473
  */
448
474
  isEmpty(inputs) {
449
- return !inputs.text || inputs.text.trim().length === 0;
475
+ const resolved = resolveDto(Inputs.Text.TextDto, inputs);
476
+ return !resolved.text || resolved.text.trim().length === 0;
450
477
  }
451
478
  /**
452
479
  * Joins several texts into one with nothing between them.
@@ -463,7 +490,8 @@ export class TextBitByBit {
463
490
  * ```
464
491
  */
465
492
  concat(inputs) {
466
- return inputs.texts.join("");
493
+ const resolved = resolveDto(Inputs.Text.TextConcatDto, inputs);
494
+ return resolved.texts.join("");
467
495
  }
468
496
  /**
469
497
  * Tells whether a regular expression matches somewhere in a text.
@@ -480,8 +508,9 @@ export class TextBitByBit {
480
508
  * ```
481
509
  */
482
510
  regexTest(inputs) {
483
- const regex = new RegExp(inputs.pattern, inputs.flags);
484
- return regex.test(inputs.text);
511
+ const resolved = resolveDto(Inputs.Text.TextRegexDto, inputs);
512
+ const regex = new RegExp(resolved.pattern, resolved.flags);
513
+ return regex.test(resolved.text);
485
514
  }
486
515
  /**
487
516
  * Finds the parts of a text that a regular expression matches.
@@ -500,8 +529,9 @@ export class TextBitByBit {
500
529
  * ```
501
530
  */
502
531
  regexMatch(inputs) {
503
- const regex = new RegExp(inputs.pattern, inputs.flags);
504
- const result = inputs.text.match(regex);
532
+ const resolved = resolveDto(Inputs.Text.TextRegexDto, inputs);
533
+ const regex = new RegExp(resolved.pattern, resolved.flags);
534
+ const result = resolved.text.match(regex);
505
535
  return result ? Array.from(result) : null;
506
536
  }
507
537
  /**
@@ -520,8 +550,9 @@ export class TextBitByBit {
520
550
  * ```
521
551
  */
522
552
  regexReplace(inputs) {
523
- const regex = new RegExp(inputs.pattern, inputs.flags);
524
- return inputs.text.replace(regex, inputs.replaceWith);
553
+ const resolved = resolveDto(Inputs.Text.TextRegexReplaceDto, inputs);
554
+ const regex = new RegExp(resolved.pattern, resolved.flags);
555
+ return resolved.text.replace(regex, resolved.replaceWith);
525
556
  }
526
557
  /**
527
558
  * Finds where a regular expression first matches, counting characters from 0, or -1 when it
@@ -539,8 +570,9 @@ export class TextBitByBit {
539
570
  * ```
540
571
  */
541
572
  regexSearch(inputs) {
542
- const regex = new RegExp(inputs.pattern, inputs.flags);
543
- return inputs.text.search(regex);
573
+ const resolved = resolveDto(Inputs.Text.TextRegexDto, inputs);
574
+ const regex = new RegExp(resolved.pattern, resolved.flags);
575
+ return resolved.text.search(regex);
544
576
  }
545
577
  /**
546
578
  * Cuts a text into pieces wherever a regular expression matches; the matches themselves are
@@ -558,8 +590,9 @@ export class TextBitByBit {
558
590
  * ```
559
591
  */
560
592
  regexSplit(inputs) {
561
- const regex = new RegExp(inputs.pattern, inputs.flags);
562
- return inputs.text.split(regex);
593
+ const resolved = resolveDto(Inputs.Text.TextRegexDto, inputs);
594
+ const regex = new RegExp(resolved.pattern, resolved.flags);
595
+ return resolved.text.split(regex);
563
596
  }
564
597
  /**
565
598
  * Draws one character as line paths with a simple stroke font.
@@ -579,7 +612,8 @@ export class TextBitByBit {
579
612
  * ```
580
613
  */
581
614
  vectorChar(inputs) {
582
- const { xOffset, yOffset, font, input, height, extrudeOffset } = this.vectorParamsChar(inputs);
615
+ const resolved = resolveDto(Inputs.Text.VectorCharDto, inputs);
616
+ const { xOffset, yOffset, font, input, height, extrudeOffset } = this.vectorParamsChar(resolved);
583
617
  let code = input.charCodeAt(0);
584
618
  if (!code || !font[code]) {
585
619
  code = 63;
@@ -629,8 +663,9 @@ export class TextBitByBit {
629
663
  * ```
630
664
  */
631
665
  vectorText(inputs) {
632
- const { xOffset, yOffset, height, align, extrudeOffset, lineSpacing, letterSpacing } = Object.assign({}, defaultsVectorParams, inputs);
633
- const text = inputs.text;
666
+ const resolved = resolveDto(Inputs.Text.VectorTextDto, inputs);
667
+ const { xOffset, yOffset, height, align, extrudeOffset, lineSpacing, letterSpacing } = Object.assign({}, defaultsVectorParams, resolved);
668
+ const text = resolved.text;
634
669
  if (typeof text !== "string")
635
670
  throw new Error("text must be a string");
636
671
  const extraLetterSpacing = (height * letterSpacing);
@@ -678,7 +713,7 @@ export class TextBitByBit {
678
713
  return line;
679
714
  }
680
715
  });
681
- if (inputs.centerOnOrigin) {
716
+ if (resolved.centerOnOrigin) {
682
717
  const pointsFlat = [];
683
718
  lines.forEach((line) => {
684
719
  line.chars.forEach((vchar) => {
@@ -1,3 +1,5 @@
1
+ import * as Inputs from "../inputs";
2
+ import { resolveDto } from "../kernel-calls";
1
3
  /**
2
4
  * Builds transformation matrices for moving, rotating, scaling and stretching geometry. A
3
5
  * transformation is a 4x4 matrix as 16 numbers in column-major order; most methods return a short
@@ -30,10 +32,11 @@ export class Transforms {
30
32
  * ```
31
33
  */
32
34
  rotationCenterAxis(inputs) {
35
+ const resolved = resolveDto(Inputs.Transforms.RotationCenterAxisDto, inputs);
33
36
  return [
34
- this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
35
- this.rotationAxis(inputs.axis, this.math.degToRad({ number: inputs.angle })),
36
- this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
37
+ this.translation(-resolved.center[0], -resolved.center[1], -resolved.center[2]),
38
+ this.rotationAxis(resolved.axis, this.math.degToRad({ number: resolved.angle })),
39
+ this.translation(resolved.center[0], resolved.center[1], resolved.center[2]),
37
40
  ];
38
41
  }
39
42
  /**
@@ -54,10 +57,11 @@ export class Transforms {
54
57
  * ```
55
58
  */
56
59
  rotationCenterX(inputs) {
60
+ const resolved = resolveDto(Inputs.Transforms.RotationCenterDto, inputs);
57
61
  return [
58
- this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
59
- this.rotationX(this.math.degToRad({ number: inputs.angle })),
60
- this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
62
+ this.translation(-resolved.center[0], -resolved.center[1], -resolved.center[2]),
63
+ this.rotationX(this.math.degToRad({ number: resolved.angle })),
64
+ this.translation(resolved.center[0], resolved.center[1], resolved.center[2]),
61
65
  ];
62
66
  }
63
67
  /**
@@ -78,10 +82,11 @@ export class Transforms {
78
82
  * ```
79
83
  */
80
84
  rotationCenterY(inputs) {
85
+ const resolved = resolveDto(Inputs.Transforms.RotationCenterDto, inputs);
81
86
  return [
82
- this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
83
- this.rotationY(this.math.degToRad({ number: inputs.angle })),
84
- this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
87
+ this.translation(-resolved.center[0], -resolved.center[1], -resolved.center[2]),
88
+ this.rotationY(this.math.degToRad({ number: resolved.angle })),
89
+ this.translation(resolved.center[0], resolved.center[1], resolved.center[2]),
85
90
  ];
86
91
  }
87
92
  /**
@@ -102,10 +107,11 @@ export class Transforms {
102
107
  * ```
103
108
  */
104
109
  rotationCenterZ(inputs) {
110
+ const resolved = resolveDto(Inputs.Transforms.RotationCenterDto, inputs);
105
111
  return [
106
- this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
107
- this.rotationZ(this.math.degToRad({ number: inputs.angle })),
108
- this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
112
+ this.translation(-resolved.center[0], -resolved.center[1], -resolved.center[2]),
113
+ this.rotationZ(this.math.degToRad({ number: resolved.angle })),
114
+ this.translation(resolved.center[0], resolved.center[1], resolved.center[2]),
109
115
  ];
110
116
  }
111
117
  /**
@@ -126,10 +132,11 @@ export class Transforms {
126
132
  * ```
127
133
  */
128
134
  rotationCenterYawPitchRoll(inputs) {
135
+ const resolved = resolveDto(Inputs.Transforms.RotationCenterYawPitchRollDto, inputs);
129
136
  return [
130
- this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
131
- this.rotationYawPitchRoll(this.math.degToRad({ number: inputs.yaw }), this.math.degToRad({ number: inputs.pitch }), this.math.degToRad({ number: inputs.roll })),
132
- this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
137
+ this.translation(-resolved.center[0], -resolved.center[1], -resolved.center[2]),
138
+ this.rotationYawPitchRoll(this.math.degToRad({ number: resolved.yaw }), this.math.degToRad({ number: resolved.pitch }), this.math.degToRad({ number: resolved.roll })),
139
+ this.translation(resolved.center[0], resolved.center[1], resolved.center[2]),
133
140
  ];
134
141
  }
135
142
  /**
@@ -150,10 +157,11 @@ export class Transforms {
150
157
  * ```
151
158
  */
152
159
  scaleCenterXYZ(inputs) {
160
+ const resolved = resolveDto(Inputs.Transforms.ScaleCenterXYZDto, inputs);
153
161
  return [
154
- this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
155
- this.scaling(inputs.scaleXyz[0], inputs.scaleXyz[1], inputs.scaleXyz[2]),
156
- this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
162
+ this.translation(-resolved.center[0], -resolved.center[1], -resolved.center[2]),
163
+ this.scaling(resolved.scaleXyz[0], resolved.scaleXyz[1], resolved.scaleXyz[2]),
164
+ this.translation(resolved.center[0], resolved.center[1], resolved.center[2]),
157
165
  ];
158
166
  }
159
167
  /**
@@ -171,7 +179,8 @@ export class Transforms {
171
179
  * ```
172
180
  */
173
181
  scaleXYZ(inputs) {
174
- return [this.scaling(inputs.scaleXyz[0], inputs.scaleXyz[1], inputs.scaleXyz[2])];
182
+ const resolved = resolveDto(Inputs.Transforms.ScaleXYZDto, inputs);
183
+ return [this.scaling(resolved.scaleXyz[0], resolved.scaleXyz[1], resolved.scaleXyz[2])];
175
184
  }
176
185
  /**
177
186
  * Builds a stretch along one direction, measured from a center point; distances across that
@@ -192,7 +201,8 @@ export class Transforms {
192
201
  * ```
193
202
  */
194
203
  stretchDirFromCenter(inputs) {
195
- const { center = [0, 0, 0], direction = [0, 0, 1], scale = 2 } = inputs;
204
+ const resolved = resolveDto(Inputs.Transforms.StretchDirCenterDto, inputs);
205
+ const { center, direction, scale } = resolved;
196
206
  return [
197
207
  this.translation(-center[0], -center[1], -center[2]),
198
208
  this.stretchDirection(direction, scale),
@@ -214,7 +224,8 @@ export class Transforms {
214
224
  * ```
215
225
  */
216
226
  uniformScale(inputs) {
217
- return [this.scaling(inputs.scale, inputs.scale, inputs.scale)];
227
+ const resolved = resolveDto(Inputs.Transforms.UniformScaleDto, inputs);
228
+ return [this.scaling(resolved.scale, resolved.scale, resolved.scale)];
218
229
  }
219
230
  /**
220
231
  * Builds a scale by the same factor on every axis, measured from a center point that stays in
@@ -234,10 +245,11 @@ export class Transforms {
234
245
  * ```
235
246
  */
236
247
  uniformScaleFromCenter(inputs) {
248
+ const resolved = resolveDto(Inputs.Transforms.UniformScaleFromCenterDto, inputs);
237
249
  return [
238
- this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
239
- this.scaling(inputs.scale, inputs.scale, inputs.scale),
240
- this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
250
+ this.translation(-resolved.center[0], -resolved.center[1], -resolved.center[2]),
251
+ this.scaling(resolved.scale, resolved.scale, resolved.scale),
252
+ this.translation(resolved.center[0], resolved.center[1], resolved.center[2]),
241
253
  ];
242
254
  }
243
255
  /**
@@ -255,7 +267,8 @@ export class Transforms {
255
267
  * ```
256
268
  */
257
269
  translationXYZ(inputs) {
258
- return [this.translation(inputs.translation[0], inputs.translation[1], inputs.translation[2])];
270
+ const resolved = resolveDto(Inputs.Transforms.TranslationXYZDto, inputs);
271
+ return [this.translation(resolved.translation[0], resolved.translation[1], resolved.translation[2])];
259
272
  }
260
273
  /**
261
274
  * Builds one move per vector, for transforming many points each by its own vector.
@@ -1,3 +1,5 @@
1
+ import * as Inputs from "../inputs";
2
+ import { resolveDto } from "../kernel-calls";
1
3
  /**
2
4
  * Vector maths on plain number arrays. A vector is an array of numbers; in 3D it is `[x, y, z]`
3
5
  * with Y pointing up, the same shape as a point, so the two can be passed to each other's methods.
@@ -27,7 +29,8 @@ export class Vector {
27
29
  * ```
28
30
  */
29
31
  removeAllDuplicateVectors(inputs) {
30
- return this.geometryHelper.removeAllDuplicateVectors(inputs.vectors, inputs.tolerance);
32
+ const resolved = resolveDto(Inputs.Vector.RemoveAllDuplicateVectorsDto, inputs);
33
+ return this.geometryHelper.removeAllDuplicateVectors(resolved.vectors, resolved.tolerance);
31
34
  }
32
35
  /**
33
36
  * Removes a vector when it repeats the one right before it; the same vector further away is
@@ -51,7 +54,8 @@ export class Vector {
51
54
  * ```
52
55
  */
53
56
  removeConsecutiveDuplicateVectors(inputs) {
54
- return this.geometryHelper.removeConsecutiveVectorDuplicates(inputs.vectors, inputs.checkFirstAndLast, inputs.tolerance);
57
+ const resolved = resolveDto(Inputs.Vector.RemoveConsecutiveDuplicateVectorsDto, inputs);
58
+ return this.geometryHelper.removeConsecutiveVectorDuplicates(resolved.vectors, resolved.checkFirstAndLast, resolved.tolerance);
55
59
  }
56
60
  /**
57
61
  * Tells whether two vectors are the same within a tolerance, entry by entry.
@@ -69,7 +73,8 @@ export class Vector {
69
73
  * ```
70
74
  */
71
75
  vectorsTheSame(inputs) {
72
- return this.geometryHelper.vectorsTheSame(inputs.vec1, inputs.vec2, inputs.tolerance);
76
+ const resolved = resolveDto(Inputs.Vector.VectorsTheSameDto, inputs);
77
+ return this.geometryHelper.vectorsTheSame(resolved.vec1, resolved.vec2, resolved.tolerance);
73
78
  }
74
79
  /**
75
80
  * Measures the angle between two vectors in degrees, always between 0 and 180.
@@ -274,9 +279,10 @@ export class Vector {
274
279
  * ```
275
280
  */
276
281
  div(inputs) {
282
+ const resolved = resolveDto(Inputs.Vector.VectorScalarDto, inputs);
277
283
  const res = [];
278
- for (let i = 0; i < inputs.vector.length; i++) {
279
- res.push(inputs.vector[i] / inputs.scalar);
284
+ for (let i = 0; i < resolved.vector.length; i++) {
285
+ res.push(resolved.vector[i] / resolved.scalar);
280
286
  }
281
287
  return res;
282
288
  }
@@ -370,9 +376,10 @@ export class Vector {
370
376
  * ```
371
377
  */
372
378
  lerp(inputs) {
379
+ const resolved = resolveDto(Inputs.Vector.FractionTwoVectorsDto, inputs);
373
380
  return this.add({
374
- first: this.mul({ vector: inputs.first, scalar: inputs.fraction }),
375
- second: this.mul({ vector: inputs.second, scalar: 1.0 - inputs.fraction })
381
+ first: this.mul({ vector: resolved.first, scalar: resolved.fraction }),
382
+ second: this.mul({ vector: resolved.second, scalar: 1.0 - resolved.fraction })
376
383
  });
377
384
  }
378
385
  /**
@@ -424,9 +431,10 @@ export class Vector {
424
431
  * ```
425
432
  */
426
433
  mul(inputs) {
434
+ const resolved = resolveDto(Inputs.Vector.VectorScalarDto, inputs);
427
435
  const res = [];
428
- for (let i = 0; i < inputs.vector.length; i++) {
429
- res.push(inputs.vector[i] * inputs.scalar);
436
+ for (let i = 0; i < resolved.vector.length; i++) {
437
+ res.push(resolved.vector[i] * resolved.scalar);
430
438
  }
431
439
  return res;
432
440
  }
@@ -525,7 +533,8 @@ export class Vector {
525
533
  * ```
526
534
  */
527
535
  onRay(inputs) {
528
- return this.add({ first: inputs.point, second: this.mul({ vector: inputs.vector, scalar: inputs.distance }) });
536
+ const resolved = resolveDto(Inputs.Vector.RayPointDto, inputs);
537
+ return this.add({ first: resolved.point, second: this.mul({ vector: resolved.vector, scalar: resolved.distance }) });
529
538
  }
530
539
  /**
531
540
  * Builds a 3D vector from its x, y and z values.
@@ -542,7 +551,8 @@ export class Vector {
542
551
  * ```
543
552
  */
544
553
  vectorXYZ(inputs) {
545
- return [inputs.x, inputs.y, inputs.z];
554
+ const resolved = resolveDto(Inputs.Vector.VectorXYZDto, inputs);
555
+ return [resolved.x, resolved.y, resolved.z];
546
556
  }
547
557
  /**
548
558
  * Builds a 2D vector from its x and y values.
@@ -559,7 +569,8 @@ export class Vector {
559
569
  * ```
560
570
  */
561
571
  vectorXY(inputs) {
562
- return [inputs.x, inputs.y];
572
+ const resolved = resolveDto(Inputs.Vector.VectorXYDto, inputs);
573
+ return [resolved.x, resolved.y];
563
574
  }
564
575
  /**
565
576
  * Lists the whole numbers from 0 up to, but not including, `max`.
@@ -576,8 +587,9 @@ export class Vector {
576
587
  * ```
577
588
  */
578
589
  range(inputs) {
590
+ const resolved = resolveDto(Inputs.Vector.RangeMaxDto, inputs);
579
591
  const res = [];
580
- for (let i = 0; i < inputs.max; i++) {
592
+ for (let i = 0; i < resolved.max; i++) {
581
593
  res.push(i);
582
594
  }
583
595
  return res;
@@ -628,8 +640,9 @@ export class Vector {
628
640
  * ```
629
641
  */
630
642
  span(inputs) {
643
+ const resolved = resolveDto(Inputs.Vector.SpanDto, inputs);
631
644
  const res = [];
632
- for (let i = inputs.min; i <= inputs.max; i += inputs.step) {
645
+ for (let i = resolved.min; i <= resolved.max; i += resolved.step) {
633
646
  res.push(i);
634
647
  }
635
648
  return res;
@@ -652,12 +665,13 @@ export class Vector {
652
665
  * ```
653
666
  */
654
667
  spanEaseItems(inputs) {
668
+ const resolved = resolveDto(Inputs.Vector.SpanEaseItemsDto, inputs);
655
669
  const res = [];
656
- for (let i = 0; i < inputs.nrItems; i++) {
657
- const x = i * 1 / (inputs.nrItems - 1);
658
- res.push(this.math.ease({ x: x, ease: inputs.ease, min: inputs.min, max: inputs.max }));
670
+ for (let i = 0; i < resolved.nrItems; i++) {
671
+ const x = i * 1 / (resolved.nrItems - 1);
672
+ res.push(this.math.ease({ x: x, ease: resolved.ease, min: resolved.min, max: resolved.max }));
659
673
  }
660
- if (inputs.intervals) {
674
+ if (resolved.intervals) {
661
675
  return res.map((v, i, a) => i === 0 ? v : v - a[i - 1]);
662
676
  }
663
677
  return res;
@@ -677,11 +691,12 @@ export class Vector {
677
691
  * ```
678
692
  */
679
693
  spanLinearItems(inputs) {
694
+ const resolved = resolveDto(Inputs.Vector.SpanLinearItemsDto, inputs);
680
695
  const res = [];
681
- const dist = (inputs.max - inputs.min);
682
- for (let i = 0; i < inputs.nrItems; i++) {
683
- const x = dist * i / (inputs.nrItems - 1);
684
- res.push(x + inputs.min);
696
+ const dist = (resolved.max - resolved.min);
697
+ for (let i = 0; i < resolved.nrItems; i++) {
698
+ const x = dist * i / (resolved.nrItems - 1);
699
+ res.push(x + resolved.min);
685
700
  }
686
701
  return res;
687
702
  }