@bitbybit-dev/base 1.6.1 → 1.7.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 (192) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +36 -7
  3. package/lib/api/inputs/base-inputs.js +10 -0
  4. package/lib/api/inputs/color-inputs.d.ts +54 -1
  5. package/lib/api/inputs/color-inputs.js +73 -1
  6. package/lib/api/inputs/frame-inputs.d.ts +2 -1
  7. package/lib/api/inputs/frame-inputs.js +2 -1
  8. package/lib/api/inputs/io-inputs.d.ts +527 -59
  9. package/lib/api/inputs/io-inputs.js +432 -40
  10. package/lib/api/inputs/line-inputs.d.ts +17 -0
  11. package/lib/api/inputs/line-inputs.js +15 -0
  12. package/lib/api/inputs/math-inputs.d.ts +62 -0
  13. package/lib/api/inputs/math-inputs.js +82 -0
  14. package/lib/api/inputs/mesh-inputs.d.ts +16 -0
  15. package/lib/api/inputs/mesh-inputs.js +14 -0
  16. package/lib/api/inputs/transforms-inputs.d.ts +76 -0
  17. package/lib/api/inputs/transforms-inputs.js +85 -0
  18. package/lib/api/kernel-calls/index.d.ts +1 -0
  19. package/lib/api/kernel-calls/index.js +1 -0
  20. package/lib/api/kernel-calls/settings.d.ts +82 -0
  21. package/lib/api/kernel-calls/settings.js +123 -0
  22. package/lib/api/recipes/surface-mesh.d.ts +2 -1
  23. package/lib/api/recipes/surface-mesh.js +5 -3
  24. package/lib/api/resolved-inputs/index.d.ts +32 -2
  25. package/lib/api/services/base-bitbybit.d.ts +12 -0
  26. package/lib/api/services/base-bitbybit.js +19 -3
  27. package/lib/api/services/color.d.ts +36 -2
  28. package/lib/api/services/color.js +60 -11
  29. package/lib/api/services/helpers/color/color-forms.constants.d.ts +10 -0
  30. package/lib/api/services/helpers/color/color-forms.constants.js +10 -0
  31. package/lib/api/services/helpers/color/color-forms.d.ts +3 -0
  32. package/lib/api/services/helpers/color/color-forms.js +27 -0
  33. package/lib/api/services/helpers/color/css-colors.constants.d.ts +9 -0
  34. package/lib/api/services/helpers/color/css-colors.constants.js +158 -0
  35. package/lib/api/services/helpers/color/css-colors.d.ts +1 -0
  36. package/lib/api/services/helpers/color/css-colors.js +61 -0
  37. package/lib/api/services/helpers/curves/bezier-pieces.constants.d.ts +5 -0
  38. package/lib/api/services/helpers/curves/bezier-pieces.constants.js +5 -0
  39. package/lib/api/services/helpers/curves/bezier-pieces.d.ts +24 -0
  40. package/lib/api/services/helpers/curves/bezier-pieces.js +149 -0
  41. package/lib/api/services/helpers/curves/conic-arcs.constants.d.ts +5 -0
  42. package/lib/api/services/helpers/curves/conic-arcs.constants.js +5 -0
  43. package/lib/api/services/helpers/curves/conic-arcs.d.ts +24 -0
  44. package/lib/api/services/helpers/curves/conic-arcs.js +85 -0
  45. package/lib/api/services/helpers/curves/nurbs-forms.d.ts +20 -0
  46. package/lib/api/services/helpers/curves/nurbs-forms.js +112 -0
  47. package/lib/api/services/helpers/curves/nurbs.d.ts +4 -0
  48. package/lib/api/services/helpers/curves/nurbs.js +10 -9
  49. package/lib/api/services/helpers/files/drawing/drawing-budget.d.ts +3 -0
  50. package/lib/api/services/helpers/files/drawing/drawing-budget.js +24 -0
  51. package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +18 -0
  52. package/lib/api/services/helpers/files/drawing/drawing-geometry.js +84 -0
  53. package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +5 -0
  54. package/lib/api/services/helpers/files/drawing/drawing-model.js +252 -0
  55. package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +60 -0
  56. package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
  57. package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +28 -0
  58. package/lib/api/services/helpers/files/drawing/drawing.constants.js +29 -0
  59. package/lib/api/services/helpers/files/dxf/dxf-colors.d.ts +5 -0
  60. package/lib/api/services/helpers/files/dxf/dxf-colors.js +45 -0
  61. package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +17 -0
  62. package/lib/api/services/helpers/files/dxf/dxf-entities.js +193 -0
  63. package/lib/api/services/helpers/files/dxf/dxf-file-text.d.ts +1 -0
  64. package/lib/api/services/helpers/files/dxf/dxf-file-text.js +50 -0
  65. package/lib/api/services/helpers/files/dxf/dxf-generator.d.ts +2 -36
  66. package/lib/api/services/helpers/files/dxf/dxf-generator.js +81 -523
  67. package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.d.ts +6 -0
  68. package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +81 -0
  69. package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.d.ts +21 -0
  70. package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.js +67 -0
  71. package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +69 -0
  72. package/lib/api/services/helpers/files/dxf/dxf-reader-types.js +1 -0
  73. package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +71 -0
  74. package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +78 -0
  75. package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
  76. package/lib/api/services/helpers/files/dxf/dxf-reader.js +556 -0
  77. package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +27 -0
  78. package/lib/api/services/helpers/files/dxf/dxf-tables.js +247 -0
  79. package/lib/api/services/helpers/files/dxf/dxf-text.d.ts +26 -0
  80. package/lib/api/services/helpers/files/dxf/dxf-text.js +97 -0
  81. package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +9 -0
  82. package/lib/api/services/helpers/files/dxf/dxf-tokens.js +65 -0
  83. package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +32 -1
  84. package/lib/api/services/helpers/files/dxf/dxf.constants.js +34 -1
  85. package/lib/api/services/helpers/files/file-bytes.d.ts +1 -0
  86. package/lib/api/services/helpers/files/file-bytes.js +15 -0
  87. package/lib/api/services/helpers/files/ground-axes.d.ts +2 -0
  88. package/lib/api/services/helpers/files/ground-axes.js +4 -0
  89. package/lib/api/services/helpers/files/mesh-file-axes.d.ts +7 -0
  90. package/lib/api/services/helpers/files/mesh-file-axes.js +17 -0
  91. package/lib/api/services/helpers/files/stl-axes.d.ts +4 -0
  92. package/lib/api/services/helpers/files/stl-axes.js +22 -0
  93. package/lib/api/services/helpers/files/stl-types.d.ts +7 -0
  94. package/lib/api/services/helpers/files/stl-types.js +1 -0
  95. package/lib/api/services/helpers/files/stl.constants.d.ts +11 -0
  96. package/lib/api/services/helpers/files/stl.constants.js +11 -0
  97. package/lib/api/services/helpers/files/stl.d.ts +3 -0
  98. package/lib/api/services/helpers/files/stl.js +93 -0
  99. package/lib/api/services/helpers/files/svg/svg-css.d.ts +48 -0
  100. package/lib/api/services/helpers/files/svg/svg-css.js +444 -0
  101. package/lib/api/services/helpers/files/svg/svg-dash-patterns.d.ts +2 -0
  102. package/lib/api/services/helpers/files/svg/svg-dash-patterns.js +35 -0
  103. package/lib/api/services/helpers/files/svg/svg-document.d.ts +26 -0
  104. package/lib/api/services/helpers/files/svg/svg-document.js +89 -0
  105. package/lib/api/services/helpers/files/svg/svg-memo.d.ts +1 -0
  106. package/lib/api/services/helpers/files/svg/svg-memo.js +8 -0
  107. package/lib/api/services/helpers/files/svg/svg-normalizer.d.ts +6 -0
  108. package/lib/api/services/helpers/files/svg/svg-normalizer.js +433 -0
  109. package/lib/api/services/helpers/files/svg/svg-numbers.d.ts +15 -0
  110. package/lib/api/services/helpers/files/svg/svg-numbers.js +61 -0
  111. package/lib/api/services/helpers/files/svg/svg-path-data.constants.d.ts +8 -0
  112. package/lib/api/services/helpers/files/svg/svg-path-data.constants.js +10 -0
  113. package/lib/api/services/helpers/files/svg/svg-path-data.d.ts +9 -0
  114. package/lib/api/services/helpers/files/svg/svg-path-data.js +203 -0
  115. package/lib/api/services/helpers/files/svg/svg-path-types.d.ts +33 -0
  116. package/lib/api/services/helpers/files/svg/svg-path-types.js +1 -0
  117. package/lib/api/services/helpers/files/svg/svg-reader.constants.d.ts +35 -0
  118. package/lib/api/services/helpers/files/svg/svg-reader.constants.js +35 -0
  119. package/lib/api/services/helpers/files/svg/svg-reading.constants.d.ts +9 -0
  120. package/lib/api/services/helpers/files/svg/svg-reading.constants.js +9 -0
  121. package/lib/api/services/helpers/files/svg/svg-reading.d.ts +6 -0
  122. package/lib/api/services/helpers/files/svg/svg-reading.js +233 -0
  123. package/lib/api/services/helpers/files/svg/svg-scene-types.d.ts +54 -0
  124. package/lib/api/services/helpers/files/svg/svg-scene-types.js +1 -0
  125. package/lib/api/services/helpers/files/svg/svg-shapes.d.ts +6 -0
  126. package/lib/api/services/helpers/files/svg/svg-shapes.js +102 -0
  127. package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +38 -0
  128. package/lib/api/services/helpers/files/svg/svg-strokes.js +108 -0
  129. package/lib/api/services/helpers/files/svg/svg-style.d.ts +26 -0
  130. package/lib/api/services/helpers/files/svg/svg-style.js +211 -0
  131. package/lib/api/services/helpers/files/svg/svg-transform.d.ts +10 -0
  132. package/lib/api/services/helpers/files/svg/svg-transform.js +76 -0
  133. package/lib/api/services/helpers/files/svg/svg-writer.d.ts +16 -0
  134. package/lib/api/services/helpers/files/svg/svg-writer.js +153 -0
  135. package/lib/api/services/helpers/files/svg/svg-xml.d.ts +11 -0
  136. package/lib/api/services/helpers/files/svg/svg-xml.js +322 -0
  137. package/lib/api/services/helpers/files/svg/svg.constants.d.ts +13 -0
  138. package/lib/api/services/helpers/files/svg/svg.constants.js +13 -0
  139. package/lib/api/services/helpers/files/work-budget.d.ts +11 -0
  140. package/lib/api/services/helpers/files/work-budget.js +26 -0
  141. package/lib/api/services/helpers/geometry/affine2.d.ts +8 -0
  142. package/lib/api/services/helpers/geometry/affine2.js +18 -0
  143. package/lib/api/services/helpers/geometry/ellipse-arcs.d.ts +14 -0
  144. package/lib/api/services/helpers/geometry/ellipse-arcs.js +96 -0
  145. package/lib/api/services/helpers/geometry/frame-axes.d.ts +3 -1
  146. package/lib/api/services/helpers/geometry/polygon-nesting.constants.d.ts +6 -0
  147. package/lib/api/services/helpers/geometry/polygon-nesting.constants.js +6 -0
  148. package/lib/api/services/helpers/geometry/polygon-nesting.d.ts +31 -0
  149. package/lib/api/services/helpers/geometry/polygon-nesting.js +251 -0
  150. package/lib/api/services/helpers/geometry/quaternions.constants.d.ts +3 -0
  151. package/lib/api/services/helpers/geometry/quaternions.constants.js +3 -0
  152. package/lib/api/services/helpers/geometry/quaternions.d.ts +14 -0
  153. package/lib/api/services/helpers/geometry/quaternions.js +71 -0
  154. package/lib/api/services/helpers/geometry/scalars.constants.d.ts +1 -0
  155. package/lib/api/services/helpers/geometry/scalars.constants.js +1 -0
  156. package/lib/api/services/helpers/geometry/scalars.d.ts +3 -0
  157. package/lib/api/services/helpers/geometry/scalars.js +29 -1
  158. package/lib/api/services/helpers/geometry/vectors.d.ts +1 -0
  159. package/lib/api/services/helpers/geometry/vectors.js +6 -0
  160. package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +1 -0
  161. package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +1 -0
  162. package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +1 -0
  163. package/lib/api/services/helpers/mesh/mesh-proximity.js +40 -40
  164. package/lib/api/services/io/drawing.d.ts +170 -0
  165. package/lib/api/services/io/drawing.js +212 -0
  166. package/lib/api/services/io/dxf.d.ts +134 -0
  167. package/lib/api/services/io/dxf.js +167 -0
  168. package/lib/api/services/io/index.d.ts +4 -0
  169. package/lib/api/services/io/index.js +4 -0
  170. package/lib/api/services/io/io.d.ts +14 -0
  171. package/lib/api/services/io/io.js +15 -0
  172. package/lib/api/services/io/svg.d.ts +64 -0
  173. package/lib/api/services/io/svg.js +102 -0
  174. package/lib/api/services/line.d.ts +17 -0
  175. package/lib/api/services/line.js +20 -1
  176. package/lib/api/services/math.d.ts +35 -0
  177. package/lib/api/services/math.js +56 -1
  178. package/lib/api/services/mesh.d.ts +17 -0
  179. package/lib/api/services/mesh.js +27 -1
  180. package/lib/api/services/point.d.ts +4 -1
  181. package/lib/api/services/point.js +9 -4
  182. package/lib/api/services/recipes.d.ts +3 -0
  183. package/lib/api/services/recipes.js +4 -1
  184. package/lib/api/services/text.d.ts +4 -1
  185. package/lib/api/services/text.js +8 -3
  186. package/lib/api/services/transforms.d.ts +119 -1
  187. package/lib/api/services/transforms.js +158 -30
  188. package/package.json +1 -1
  189. package/lib/api/services/helpers/files/dxf/dxf.d.ts +0 -87
  190. package/lib/api/services/helpers/files/dxf/dxf.js +0 -111
  191. package/lib/api/services/io.d.ts +0 -9
  192. package/lib/api/services/io.js +0 -10
@@ -47,6 +47,16 @@ export declare namespace Math {
47
47
  radToDeg = "radToDeg",
48
48
  degToRad = "degToRad"
49
49
  }
50
+ /**
51
+ * Which way a value moves to reach a step on the 1, 2, 5 scale: `up` to the smallest step at or
52
+ * above it, `down` to the largest at or below it, `nearest` to the closest by ratio. A value within
53
+ * a billionth of a step counts as that step.
54
+ */
55
+ enum niceStepDirectionEnum {
56
+ up = "up",
57
+ down = "down",
58
+ nearest = "nearest"
59
+ }
50
60
  /**
51
61
  * The easing curve applied when interpolating between two values, in the usual in/out/inOut
52
62
  * families - sine, quadratic, cubic, quartic, quintic, exponential and the rest. Governs how an
@@ -545,6 +555,58 @@ export declare namespace Math {
545
555
  */
546
556
  maxDelta?: number | undefined;
547
557
  }
558
+ /**
559
+ * Two angles and the size of a whole turn for `math.shortestAngle`.
560
+ */
561
+ class ShortestAngleDto {
562
+ constructor(from?: number, to?: number, fullTurn?: number);
563
+ /**
564
+ * The angle the turn starts from, in the unit `fullTurn` sets.
565
+ * @default 10
566
+ * @minimum -Infinity
567
+ * @maximum Infinity
568
+ * @step 1
569
+ */
570
+ from?: number | undefined;
571
+ /**
572
+ * The angle to arrive at, in the same unit as `from`; any number of whole turns may be added
573
+ * to it without changing the answer.
574
+ * @default 350
575
+ * @minimum -Infinity
576
+ * @maximum Infinity
577
+ * @step 1
578
+ */
579
+ to?: number | undefined;
580
+ /**
581
+ * How large a whole turn is in the unit the angles use: 360 for degrees, two pi for radians.
582
+ * @default 360
583
+ * @minimum 0
584
+ * @exclusiveMinimum true
585
+ * @maximum Infinity
586
+ * @step 1
587
+ */
588
+ fullTurn?: number | undefined;
589
+ }
590
+ /**
591
+ * A positive number and a direction for `math.niceStep`.
592
+ */
593
+ class NiceStepDto {
594
+ constructor(number?: number, direction?: niceStepDirectionEnum);
595
+ /**
596
+ * The rough size to turn into a step, such as a span divided by the number of ticks wanted.
597
+ * @default 0.37
598
+ * @minimum 0
599
+ * @exclusiveMinimum true
600
+ * @maximum Infinity
601
+ * @step 0.01
602
+ */
603
+ number?: number | undefined;
604
+ /**
605
+ * Whether the step may be larger than `number`, smaller, or whichever is closer.
606
+ * @default up
607
+ */
608
+ direction?: niceStepDirectionEnum | undefined;
609
+ }
548
610
  /**
549
611
  * An expression written as text for `math.evalArithmetic`.
550
612
  */
@@ -51,6 +51,17 @@ export var Math;
51
51
  mathOneNrOperatorEnum["radToDeg"] = "radToDeg";
52
52
  mathOneNrOperatorEnum["degToRad"] = "degToRad";
53
53
  })(mathOneNrOperatorEnum = Math.mathOneNrOperatorEnum || (Math.mathOneNrOperatorEnum = {}));
54
+ /**
55
+ * Which way a value moves to reach a step on the 1, 2, 5 scale: `up` to the smallest step at or
56
+ * above it, `down` to the largest at or below it, `nearest` to the closest by ratio. A value within
57
+ * a billionth of a step counts as that step.
58
+ */
59
+ let niceStepDirectionEnum;
60
+ (function (niceStepDirectionEnum) {
61
+ niceStepDirectionEnum["up"] = "up";
62
+ niceStepDirectionEnum["down"] = "down";
63
+ niceStepDirectionEnum["nearest"] = "nearest";
64
+ })(niceStepDirectionEnum = Math.niceStepDirectionEnum || (Math.niceStepDirectionEnum = {}));
54
65
  /**
55
66
  * The easing curve applied when interpolating between two values, in the usual in/out/inOut
56
67
  * families - sine, quadratic, cubic, quartic, quintic, exponential and the rest. Governs how an
@@ -702,6 +713,77 @@ export var Math;
702
713
  }
703
714
  }
704
715
  Math.MoveTowardsDto = MoveTowardsDto;
716
+ /**
717
+ * Two angles and the size of a whole turn for `math.shortestAngle`.
718
+ */
719
+ class ShortestAngleDto {
720
+ constructor(from, to, fullTurn) {
721
+ /**
722
+ * The angle the turn starts from, in the unit `fullTurn` sets.
723
+ * @default 10
724
+ * @minimum -Infinity
725
+ * @maximum Infinity
726
+ * @step 1
727
+ */
728
+ this.from = 10;
729
+ /**
730
+ * The angle to arrive at, in the same unit as `from`; any number of whole turns may be added
731
+ * to it without changing the answer.
732
+ * @default 350
733
+ * @minimum -Infinity
734
+ * @maximum Infinity
735
+ * @step 1
736
+ */
737
+ this.to = 350;
738
+ /**
739
+ * How large a whole turn is in the unit the angles use: 360 for degrees, two pi for radians.
740
+ * @default 360
741
+ * @minimum 0
742
+ * @exclusiveMinimum true
743
+ * @maximum Infinity
744
+ * @step 1
745
+ */
746
+ this.fullTurn = 360;
747
+ if (from !== undefined) {
748
+ this.from = from;
749
+ }
750
+ if (to !== undefined) {
751
+ this.to = to;
752
+ }
753
+ if (fullTurn !== undefined) {
754
+ this.fullTurn = fullTurn;
755
+ }
756
+ }
757
+ }
758
+ Math.ShortestAngleDto = ShortestAngleDto;
759
+ /**
760
+ * A positive number and a direction for `math.niceStep`.
761
+ */
762
+ class NiceStepDto {
763
+ constructor(number, direction) {
764
+ /**
765
+ * The rough size to turn into a step, such as a span divided by the number of ticks wanted.
766
+ * @default 0.37
767
+ * @minimum 0
768
+ * @exclusiveMinimum true
769
+ * @maximum Infinity
770
+ * @step 0.01
771
+ */
772
+ this.number = 0.37;
773
+ /**
774
+ * Whether the step may be larger than `number`, smaller, or whichever is closer.
775
+ * @default up
776
+ */
777
+ this.direction = niceStepDirectionEnum.up;
778
+ if (number !== undefined) {
779
+ this.number = number;
780
+ }
781
+ if (direction !== undefined) {
782
+ this.direction = direction;
783
+ }
784
+ }
785
+ }
786
+ Math.NiceStepDto = NiceStepDto;
705
787
  /**
706
788
  * An expression written as text for `math.evalArithmetic`.
707
789
  */
@@ -33,6 +33,22 @@ export declare namespace Mesh {
33
33
  */
34
34
  triangle: Base.Triangle3;
35
35
  }
36
+ /**
37
+ * A point and a triangle for `mesh.closestPointOnTriangle`.
38
+ */
39
+ class PointTriangleDto {
40
+ constructor(point?: Base.Point3, triangle?: Base.Triangle3);
41
+ /**
42
+ * The point to measure from.
43
+ * @default undefined
44
+ */
45
+ point: Base.Point3;
46
+ /**
47
+ * The corners to search between, in the order the weights come back in.
48
+ * @default undefined
49
+ */
50
+ triangle: Base.Triangle3;
51
+ }
36
52
  /**
37
53
  * A triangle and a tolerance for `mesh.calculateTrianglePlane`.
38
54
  */
@@ -30,6 +30,20 @@ export var Mesh;
30
30
  }
31
31
  }
32
32
  Mesh.TriangleDto = TriangleDto;
33
+ /**
34
+ * A point and a triangle for `mesh.closestPointOnTriangle`.
35
+ */
36
+ class PointTriangleDto {
37
+ constructor(point, triangle) {
38
+ if (point !== undefined) {
39
+ this.point = point;
40
+ }
41
+ if (triangle !== undefined) {
42
+ this.triangle = triangle;
43
+ }
44
+ }
45
+ }
46
+ Mesh.PointTriangleDto = PointTriangleDto;
33
47
  /**
34
48
  * A triangle and a tolerance for `mesh.calculateTrianglePlane`.
35
49
  */
@@ -233,4 +233,80 @@ export declare namespace Transforms {
233
233
  */
234
234
  tolerance?: number | undefined;
235
235
  }
236
+ /**
237
+ * An axis and an angle for `transforms.quaternionFromAxisAngle`.
238
+ */
239
+ class AxisAngleDto {
240
+ constructor(axis?: Base.Vector3, angle?: number);
241
+ /**
242
+ * The direction to turn about; any length but 0.
243
+ * @default [0, 0, 1]
244
+ */
245
+ axis?: Base.Vector3 | undefined;
246
+ /**
247
+ * How far to turn, in degrees; positive is counter-clockwise when the axis points toward
248
+ * you.
249
+ * @default 90
250
+ * @minimum -Infinity
251
+ * @maximum Infinity
252
+ * @step 1
253
+ */
254
+ angle?: number | undefined;
255
+ }
256
+ /**
257
+ * Three angles in degrees, about X, Y and Z in turn, for `transforms.quaternionFromEuler`.
258
+ */
259
+ class EulerAnglesDto {
260
+ constructor(angles?: Base.Vector3);
261
+ /**
262
+ * The turns in degrees about the X, Y and Z axes, applied in that order about the fixed
263
+ * world axes.
264
+ * @default [0, 0, 0]
265
+ */
266
+ angles?: Base.Vector3 | undefined;
267
+ }
268
+ /**
269
+ * A rotation held as a quaternion, for `transforms.quaternionToEuler` and
270
+ * `transforms.quaternionToMatrix`.
271
+ */
272
+ class QuaternionDto {
273
+ constructor(quaternion?: Base.Quaternion);
274
+ /**
275
+ * The rotation as [x, y, z, w]; any length but 0 is scaled to 1.
276
+ * @default undefined
277
+ */
278
+ quaternion: Base.Quaternion;
279
+ }
280
+ /**
281
+ * Two rotations, applied one after the other, for `transforms.quaternionCombine`.
282
+ */
283
+ class TwoQuaternionsDto {
284
+ constructor(first?: Base.Quaternion, second?: Base.Quaternion);
285
+ /**
286
+ * The rotation applied first, as [x, y, z, w].
287
+ * @default undefined
288
+ */
289
+ first: Base.Quaternion;
290
+ /**
291
+ * The rotation applied after it, as [x, y, z, w].
292
+ * @default undefined
293
+ */
294
+ second: Base.Quaternion;
295
+ }
296
+ /**
297
+ * A rotation and a vector for `transforms.quaternionRotateVector`.
298
+ */
299
+ class QuaternionVectorDto {
300
+ constructor(quaternion?: Base.Quaternion, vector?: Base.Vector3);
301
+ /**
302
+ * The rotation as [x, y, z, w].
303
+ * @default undefined
304
+ */
305
+ quaternion: Base.Quaternion;
306
+ /**
307
+ * The vector or point to turn about the origin.
308
+ * @default undefined
309
+ */
310
+ vector: Base.Vector3;
311
+ }
236
312
  }
@@ -309,4 +309,89 @@ export var Transforms;
309
309
  }
310
310
  }
311
311
  Transforms.TransformationToleranceDto = TransformationToleranceDto;
312
+ /**
313
+ * An axis and an angle for `transforms.quaternionFromAxisAngle`.
314
+ */
315
+ class AxisAngleDto {
316
+ constructor(axis, angle) {
317
+ /**
318
+ * The direction to turn about; any length but 0.
319
+ * @default [0, 0, 1]
320
+ */
321
+ this.axis = [0, 0, 1];
322
+ /**
323
+ * How far to turn, in degrees; positive is counter-clockwise when the axis points toward
324
+ * you.
325
+ * @default 90
326
+ * @minimum -Infinity
327
+ * @maximum Infinity
328
+ * @step 1
329
+ */
330
+ this.angle = 90;
331
+ if (axis !== undefined) {
332
+ this.axis = axis;
333
+ }
334
+ if (angle !== undefined) {
335
+ this.angle = angle;
336
+ }
337
+ }
338
+ }
339
+ Transforms.AxisAngleDto = AxisAngleDto;
340
+ /**
341
+ * Three angles in degrees, about X, Y and Z in turn, for `transforms.quaternionFromEuler`.
342
+ */
343
+ class EulerAnglesDto {
344
+ constructor(angles) {
345
+ /**
346
+ * The turns in degrees about the X, Y and Z axes, applied in that order about the fixed
347
+ * world axes.
348
+ * @default [0, 0, 0]
349
+ */
350
+ this.angles = [0, 0, 0];
351
+ if (angles !== undefined) {
352
+ this.angles = angles;
353
+ }
354
+ }
355
+ }
356
+ Transforms.EulerAnglesDto = EulerAnglesDto;
357
+ /**
358
+ * A rotation held as a quaternion, for `transforms.quaternionToEuler` and
359
+ * `transforms.quaternionToMatrix`.
360
+ */
361
+ class QuaternionDto {
362
+ constructor(quaternion) {
363
+ if (quaternion !== undefined) {
364
+ this.quaternion = quaternion;
365
+ }
366
+ }
367
+ }
368
+ Transforms.QuaternionDto = QuaternionDto;
369
+ /**
370
+ * Two rotations, applied one after the other, for `transforms.quaternionCombine`.
371
+ */
372
+ class TwoQuaternionsDto {
373
+ constructor(first, second) {
374
+ if (first !== undefined) {
375
+ this.first = first;
376
+ }
377
+ if (second !== undefined) {
378
+ this.second = second;
379
+ }
380
+ }
381
+ }
382
+ Transforms.TwoQuaternionsDto = TwoQuaternionsDto;
383
+ /**
384
+ * A rotation and a vector for `transforms.quaternionRotateVector`.
385
+ */
386
+ class QuaternionVectorDto {
387
+ constructor(quaternion, vector) {
388
+ if (quaternion !== undefined) {
389
+ this.quaternion = quaternion;
390
+ }
391
+ if (vector !== undefined) {
392
+ this.vector = vector;
393
+ }
394
+ }
395
+ }
396
+ Transforms.QuaternionVectorDto = QuaternionVectorDto;
312
397
  })(Transforms || (Transforms = {}));
@@ -11,3 +11,4 @@ export * from "./with-defaults";
11
11
  export * from "./hashing";
12
12
  export * from "./unknown-values";
13
13
  export * from "./kernel-steps";
14
+ export * from "./settings";
@@ -11,3 +11,4 @@ export * from "./with-defaults";
11
11
  export * from "./hashing";
12
12
  export * from "./unknown-values";
13
13
  export * from "./kernel-steps";
14
+ export * from "./settings";
@@ -0,0 +1,82 @@
1
+ import { Base } from "../inputs/base-inputs";
2
+ /**
3
+ * The settings one bitbybit instance works by: choices made once for a whole app, not per call.
4
+ * The renderer holds them for its scene, each worker is told them once and keeps them, and a
5
+ * program that runs a kernel itself sets them on that kernel. A setting left out keeps the
6
+ * behaviour the libraries had before it existed.
7
+ */
8
+ export interface BitbybitSettings {
9
+ /**
10
+ * The coordinate system the model's numbers are in: left-handed for a default Babylon.js scene,
11
+ * right-handed for three.js, PlayCanvas and a program without a scene. Files, drawings and text
12
+ * map by it. Left out, they map as they did before the choice existed.
13
+ */
14
+ coordinateSystem?: Base.coordinateSystemEnum | undefined;
15
+ }
16
+ /**
17
+ * Checks settings that arrived from outside - a worker message, a file, a caller's object - and
18
+ * returns them as a new plain object holding only what was set, its keys in a fixed order.
19
+ *
20
+ * A name that is no setting and a value its setting does not take are refused as an `InputError`
21
+ * naming the property, so a misspelt setting is never silently ignored. Nothing, or an empty
22
+ * object, gives no settings.
23
+ * @param given - The settings as they arrived
24
+ * @returns The settings that were set
25
+ */
26
+ export declare function checkedSettings(given: unknown): BitbybitSettings;
27
+ /**
28
+ * The settings as a worker keeps its results apart by them: nothing when none are set, so a result
29
+ * made with no settings is found under the key it had before settings existed.
30
+ * @param settings - The settings the worker works by
31
+ * @returns The settings, or nothing when none are set
32
+ */
33
+ export declare function settingsCacheKey(settings: BitbybitSettings): BitbybitSettings | undefined;
34
+ /**
35
+ * Keeps the settings a kernel worker manager is given and tells its worker them: what the OCCT,
36
+ * JSCAD and Manifold managers share. Settings are checked where they arrive, so a refused one
37
+ * rejects and changes nothing, whether a worker is set or not. Accepted ones are sent at once, as a
38
+ * call of their own, to the worker set now and to every worker set after it. Nothing waits for the
39
+ * worker's answer: a worker answers calls in the order they came, holding those that arrive before
40
+ * its kernel is ready, so every call made after the settings works by them. A worker that refuses
41
+ * them all the same, one built before a setting existed, is reported through `refused`.
42
+ */
43
+ export declare class SettingsRelay {
44
+ private readonly send;
45
+ private readonly refused;
46
+ private kept;
47
+ /**
48
+ * @param send - Sends settings to the worker as a call of their own, settled by its answer
49
+ * @param refused - Told what a worker answered when it refused the settings it was sent
50
+ */
51
+ constructor(send: (settings: BitbybitSettings) => Promise<unknown>, refused: (reason: unknown) => void);
52
+ /**
53
+ * Checks the settings, keeps them, and sends them to the worker when one is set.
54
+ * @param settings - The settings as they arrived
55
+ * @param toWorker - True when a worker is set to send them to now
56
+ * @returns The settings kept; a refusal rejects and keeps the earlier ones
57
+ */
58
+ set(settings: unknown, toWorker: boolean): Promise<BitbybitSettings>;
59
+ /**
60
+ * Sends the settings kept to a worker just set, when any were ever given.
61
+ */
62
+ workerSet(): void;
63
+ private tell;
64
+ }
65
+ /**
66
+ * The newest conventions level these libraries know: 1, where a model's numbers are in the
67
+ * engine's own coordinate system. Content made today is saved with it.
68
+ */
69
+ export declare const CURRENT_CONVENTIONS = 1;
70
+ /**
71
+ * The settings that content saved with a conventions level runs by. Content carries one whole
72
+ * number instead of the settings themselves, since the right settings depend on the engine that runs it:
73
+ * 0, or no level at all, is the behaviour from before settings existed, and 1 and above are the
74
+ * engine's own settings. Levels only add, so one newer than this version knows runs by the newest
75
+ * it has.
76
+ *
77
+ * Anything but a whole number from 0 is refused as an `InputError`.
78
+ * @param level - The level the content was saved with, or nothing for content saved without one
79
+ * @param engineSettings - The settings that fit the engine, as a renderer's `engineSettings` gives them
80
+ * @returns The settings to run the content by
81
+ */
82
+ export declare function settingsOfConventions(level: unknown, engineSettings: BitbybitSettings): BitbybitSettings;
@@ -0,0 +1,123 @@
1
+ import { Base } from "../inputs/base-inputs";
2
+ import { InputError } from "./errors";
3
+ const COORDINATE_SYSTEMS = Object.values(Base.coordinateSystemEnum);
4
+ const REFUSALS = new Map([
5
+ ["coordinateSystem", value => (COORDINATE_SYSTEMS.includes(value) ? undefined : `it is ${COORDINATE_SYSTEMS.join(", ")} or left out`)],
6
+ ]);
7
+ /**
8
+ * Checks settings that arrived from outside - a worker message, a file, a caller's object - and
9
+ * returns them as a new plain object holding only what was set, its keys in a fixed order.
10
+ *
11
+ * A name that is no setting and a value its setting does not take are refused as an `InputError`
12
+ * naming the property, so a misspelt setting is never silently ignored. Nothing, or an empty
13
+ * object, gives no settings.
14
+ * @param given - The settings as they arrived
15
+ * @returns The settings that were set
16
+ */
17
+ export function checkedSettings(given) {
18
+ if (given === undefined || given === null) {
19
+ return {};
20
+ }
21
+ if (typeof given !== "object" || Array.isArray(given)) {
22
+ throw new InputError("The settings are an object of setting names and values.", "settings");
23
+ }
24
+ const entries = given;
25
+ const unknown = Object.keys(entries).find(name => !REFUSALS.has(name));
26
+ if (unknown !== undefined) {
27
+ throw new InputError(`\`${unknown}\` is not a setting; the settings are ${[...REFUSALS.keys()].join(", ")}.`, unknown);
28
+ }
29
+ const settings = {};
30
+ REFUSALS.forEach((refusalOf, name) => {
31
+ const value = entries[name];
32
+ if (value === undefined || value === null) {
33
+ return;
34
+ }
35
+ const refusal = refusalOf(value);
36
+ if (refusal !== undefined) {
37
+ throw new InputError(`\`${name}\` is ${JSON.stringify(value)}; ${refusal}.`, name);
38
+ }
39
+ settings[name] = value;
40
+ });
41
+ return settings;
42
+ }
43
+ /**
44
+ * The settings as a worker keeps its results apart by them: nothing when none are set, so a result
45
+ * made with no settings is found under the key it had before settings existed.
46
+ * @param settings - The settings the worker works by
47
+ * @returns The settings, or nothing when none are set
48
+ */
49
+ export function settingsCacheKey(settings) {
50
+ return Object.keys(settings).length === 0 ? undefined : settings;
51
+ }
52
+ /**
53
+ * Keeps the settings a kernel worker manager is given and tells its worker them: what the OCCT,
54
+ * JSCAD and Manifold managers share. Settings are checked where they arrive, so a refused one
55
+ * rejects and changes nothing, whether a worker is set or not. Accepted ones are sent at once, as a
56
+ * call of their own, to the worker set now and to every worker set after it. Nothing waits for the
57
+ * worker's answer: a worker answers calls in the order they came, holding those that arrive before
58
+ * its kernel is ready, so every call made after the settings works by them. A worker that refuses
59
+ * them all the same, one built before a setting existed, is reported through `refused`.
60
+ */
61
+ export class SettingsRelay {
62
+ /**
63
+ * @param send - Sends settings to the worker as a call of their own, settled by its answer
64
+ * @param refused - Told what a worker answered when it refused the settings it was sent
65
+ */
66
+ constructor(send, refused) {
67
+ this.send = send;
68
+ this.refused = refused;
69
+ }
70
+ /**
71
+ * Checks the settings, keeps them, and sends them to the worker when one is set.
72
+ * @param settings - The settings as they arrived
73
+ * @param toWorker - True when a worker is set to send them to now
74
+ * @returns The settings kept; a refusal rejects and keeps the earlier ones
75
+ */
76
+ set(settings, toWorker) {
77
+ return new Promise((resolve) => {
78
+ const checked = checkedSettings(settings);
79
+ this.kept = checked;
80
+ if (toWorker) {
81
+ this.tell(checked);
82
+ }
83
+ resolve(Object.assign({}, checked));
84
+ });
85
+ }
86
+ /**
87
+ * Sends the settings kept to a worker just set, when any were ever given.
88
+ */
89
+ workerSet() {
90
+ if (this.kept !== undefined) {
91
+ this.tell(this.kept);
92
+ }
93
+ }
94
+ tell(settings) {
95
+ this.send(Object.assign({}, settings)).catch(this.refused);
96
+ }
97
+ }
98
+ /**
99
+ * The newest conventions level these libraries know: 1, where a model's numbers are in the
100
+ * engine's own coordinate system. Content made today is saved with it.
101
+ */
102
+ export const CURRENT_CONVENTIONS = 1;
103
+ /**
104
+ * The settings that content saved with a conventions level runs by. Content carries one whole
105
+ * number instead of the settings themselves, since the right settings depend on the engine that runs it:
106
+ * 0, or no level at all, is the behaviour from before settings existed, and 1 and above are the
107
+ * engine's own settings. Levels only add, so one newer than this version knows runs by the newest
108
+ * it has.
109
+ *
110
+ * Anything but a whole number from 0 is refused as an `InputError`.
111
+ * @param level - The level the content was saved with, or nothing for content saved without one
112
+ * @param engineSettings - The settings that fit the engine, as a renderer's `engineSettings` gives them
113
+ * @returns The settings to run the content by
114
+ */
115
+ export function settingsOfConventions(level, engineSettings) {
116
+ if (level === undefined || level === null) {
117
+ return {};
118
+ }
119
+ if (typeof level !== "number" || !Number.isSafeInteger(level) || level < 0) {
120
+ throw new InputError(`A conventions level is a whole number from 0, got ${JSON.stringify(level)}.`, "conventions");
121
+ }
122
+ return level === 0 ? {} : checkedSettings(engineSettings);
123
+ }
@@ -1,2 +1,3 @@
1
+ import { Base } from "../inputs/base-inputs";
1
2
  import type { RecipeSurfaceMesh } from "./recipe-types";
2
- export declare function recipeSurfaceMeshes(value: unknown, roots?: readonly number[], adjustZtoY?: boolean): (RecipeSurfaceMesh | undefined)[];
3
+ export declare function recipeSurfaceMeshes(value: unknown, roots?: readonly number[], adjustZtoY?: boolean, coordinateSystem?: Base.coordinateSystemEnum): (RecipeSurfaceMesh | undefined)[];
@@ -1,9 +1,10 @@
1
+ import { Base } from "../inputs/base-inputs";
1
2
  import { InputError } from "../kernel-calls/errors";
2
3
  import { followedBy, linearDeterminant, movedCoordinate } from "../services/helpers/geometry/matrices";
4
+ import { meshMatrixInModel } from "../services/helpers/files/mesh-file-axes";
3
5
  import { POINT3_SIZE, TRIANGLE_CORNERS } from "./limits.constants";
4
6
  import { toRecipe } from "./validate";
5
7
  import { isIndexBelow } from "./checks";
6
- const Z_TO_Y = [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1];
7
8
  const X = 0;
8
9
  const Y = 1;
9
10
  const Z = 2;
@@ -57,7 +58,7 @@ function meshOfPieces(buffers, pieces) {
57
58
  }
58
59
  return { positions, indices };
59
60
  }
60
- export function recipeSurfaceMeshes(value, roots, adjustZtoY = false) {
61
+ export function recipeSurfaceMeshes(value, roots, adjustZtoY = false, coordinateSystem) {
61
62
  const recipe = toRecipe(value);
62
63
  const asked = roots !== null && roots !== void 0 ? roots : recipe.roots.map((_, index) => index);
63
64
  const bad = asked.find((index) => !isIndexBelow(index, recipe.roots.length));
@@ -67,7 +68,8 @@ export function recipeSurfaceMeshes(value, roots, adjustZtoY = false) {
67
68
  return asked.map((index) => {
68
69
  const root = recipe.roots[index];
69
70
  const pieces = [];
70
- const placement = adjustZtoY ? followedBy(root.matrix, Z_TO_Y) : root.matrix;
71
+ const turn = meshMatrixInModel(coordinateSystem !== null && coordinateSystem !== void 0 ? coordinateSystem : Base.coordinateSystemEnum.rightHanded, adjustZtoY);
72
+ const placement = turn === undefined ? root.matrix : followedBy(root.matrix, turn);
71
73
  return collectPieces(recipe.nodes, root.node, placement, pieces) ? meshOfPieces(recipe.buffers, pieces) : undefined;
72
74
  });
73
75
  }