@bitbybit-dev/base 1.6.2 → 1.8.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/NOTICE +24 -0
- package/README.md +3 -1
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/inputs/base-inputs.d.ts +40 -7
- package/lib/api/inputs/base-inputs.js +32 -0
- package/lib/api/inputs/io-inputs.d.ts +927 -59
- package/lib/api/inputs/io-inputs.js +769 -40
- package/lib/api/inputs/line-inputs.d.ts +17 -0
- package/lib/api/inputs/line-inputs.js +15 -0
- package/lib/api/inputs/mesh-inputs.d.ts +20 -1
- package/lib/api/inputs/mesh-inputs.js +23 -0
- package/lib/api/inputs/recipes-inputs.d.ts +13 -5
- package/lib/api/inputs/recipes-inputs.js +10 -5
- package/lib/api/kernel-calls/index.d.ts +2 -0
- package/lib/api/kernel-calls/index.js +2 -0
- package/lib/api/kernel-calls/resolve-dto.d.ts +3 -1
- package/lib/api/kernel-calls/resolve-dto.js +7 -2
- package/lib/api/kernel-calls/settings.d.ts +101 -0
- package/lib/api/kernel-calls/settings.js +123 -0
- package/lib/api/kernel-calls/up-axis-aliases.d.ts +25 -0
- package/lib/api/kernel-calls/up-axis-aliases.js +70 -0
- package/lib/api/models/simplex.d.ts +2 -0
- package/lib/api/models/simplex.js +10 -1
- package/lib/api/recipes/surface-mesh.d.ts +2 -1
- package/lib/api/recipes/surface-mesh.js +5 -3
- package/lib/api/resolved-inputs/index.d.ts +32 -3
- package/lib/api/services/base-bitbybit.d.ts +12 -0
- package/lib/api/services/base-bitbybit.js +19 -3
- package/lib/api/services/color.js +2 -3
- package/lib/api/services/helpers/color/color-forms.constants.d.ts +3 -0
- package/lib/api/services/helpers/color/color-forms.constants.js +3 -0
- package/lib/api/services/helpers/color/color-forms.d.ts +1 -0
- package/lib/api/services/helpers/color/color-forms.js +4 -1
- package/lib/api/services/helpers/color/css-colors.constants.d.ts +9 -0
- package/lib/api/services/helpers/color/css-colors.constants.js +158 -0
- package/lib/api/services/helpers/color/css-colors.d.ts +1 -0
- package/lib/api/services/helpers/color/css-colors.js +61 -0
- package/lib/api/services/helpers/curves/bezier-pieces.constants.d.ts +5 -0
- package/lib/api/services/helpers/curves/bezier-pieces.constants.js +5 -0
- package/lib/api/services/helpers/curves/bezier-pieces.d.ts +24 -0
- package/lib/api/services/helpers/curves/bezier-pieces.js +149 -0
- package/lib/api/services/helpers/curves/conic-arcs.constants.d.ts +5 -0
- package/lib/api/services/helpers/curves/conic-arcs.constants.js +5 -0
- package/lib/api/services/helpers/curves/conic-arcs.d.ts +26 -0
- package/lib/api/services/helpers/curves/conic-arcs.js +87 -0
- package/lib/api/services/helpers/curves/nurbs-forms.d.ts +20 -0
- package/lib/api/services/helpers/curves/nurbs-forms.js +112 -0
- package/lib/api/services/helpers/curves/nurbs.d.ts +4 -0
- package/lib/api/services/helpers/curves/nurbs.js +10 -9
- package/lib/api/services/helpers/files/drawing/drawing-budget.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-budget.js +34 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.d.ts +14 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.constants.js +14 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.d.ts +4 -0
- package/lib/api/services/helpers/files/drawing/drawing-dimension.js +271 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.d.ts +21 -0
- package/lib/api/services/helpers/files/drawing/drawing-geometry.js +101 -0
- package/lib/api/services/helpers/files/drawing/drawing-hatch.d.ts +10 -0
- package/lib/api/services/helpers/files/drawing/drawing-hatch.js +123 -0
- package/lib/api/services/helpers/files/drawing/drawing-loops.d.ts +3 -0
- package/lib/api/services/helpers/files/drawing/drawing-loops.js +91 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.d.ts +10 -0
- package/lib/api/services/helpers/files/drawing/drawing-model.js +336 -0
- package/lib/api/services/helpers/files/drawing/drawing-scale.d.ts +2 -0
- package/lib/api/services/helpers/files/drawing/drawing-scale.js +47 -0
- package/lib/api/services/helpers/files/drawing/drawing-text.d.ts +9 -0
- package/lib/api/services/helpers/files/drawing/drawing-text.js +25 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.d.ts +117 -0
- package/lib/api/services/helpers/files/drawing/drawing-types.js +1 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.d.ts +41 -0
- package/lib/api/services/helpers/files/drawing/drawing.constants.js +46 -0
- package/lib/api/services/helpers/files/dxf/dxf-annotations.d.ts +5 -0
- package/lib/api/services/helpers/files/dxf/dxf-annotations.js +96 -0
- package/lib/api/services/helpers/files/dxf/dxf-colors.d.ts +5 -0
- package/lib/api/services/helpers/files/dxf/dxf-colors.js +45 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.d.ts +21 -0
- package/lib/api/services/helpers/files/dxf/dxf-entities.js +196 -0
- package/lib/api/services/helpers/files/dxf/dxf-file-text.d.ts +1 -0
- package/lib/api/services/helpers/files/dxf/dxf-file-text.js +50 -0
- package/lib/api/services/helpers/files/dxf/dxf-generator.d.ts +2 -36
- package/lib/api/services/helpers/files/dxf/dxf-generator.js +97 -523
- package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-annotations.js +312 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.d.ts +6 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-dtos.js +115 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.d.ts +21 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-geometry.js +67 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-segments.d.ts +9 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-segments.js +151 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.d.ts +96 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader-types.js +1 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.d.ts +134 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.constants.js +95 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.d.ts +2 -0
- package/lib/api/services/helpers/files/dxf/dxf-reader.js +446 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.d.ts +29 -0
- package/lib/api/services/helpers/files/dxf/dxf-tables.js +248 -0
- package/lib/api/services/helpers/files/dxf/dxf-text.d.ts +26 -0
- package/lib/api/services/helpers/files/dxf/dxf-text.js +97 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.d.ts +11 -0
- package/lib/api/services/helpers/files/dxf/dxf-tokens.js +89 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +43 -1
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +47 -1
- package/lib/api/services/helpers/files/file-bytes.d.ts +1 -0
- package/lib/api/services/helpers/files/file-bytes.js +15 -0
- package/lib/api/services/helpers/files/ground-axes.d.ts +2 -0
- package/lib/api/services/helpers/files/ground-axes.js +4 -0
- package/lib/api/services/helpers/files/mesh-file-axes.d.ts +7 -0
- package/lib/api/services/helpers/files/mesh-file-axes.js +17 -0
- package/lib/api/services/helpers/files/stl-axes.d.ts +4 -0
- package/lib/api/services/helpers/files/stl-axes.js +22 -0
- package/lib/api/services/helpers/files/stl-types.d.ts +7 -0
- package/lib/api/services/helpers/files/stl-types.js +1 -0
- package/lib/api/services/helpers/files/stl.constants.d.ts +11 -0
- package/lib/api/services/helpers/files/stl.constants.js +11 -0
- package/lib/api/services/helpers/files/stl.d.ts +3 -0
- package/lib/api/services/helpers/files/stl.js +93 -0
- package/lib/api/services/helpers/files/svg/svg-css.d.ts +48 -0
- package/lib/api/services/helpers/files/svg/svg-css.js +444 -0
- package/lib/api/services/helpers/files/svg/svg-dash-patterns.d.ts +2 -0
- package/lib/api/services/helpers/files/svg/svg-dash-patterns.js +35 -0
- package/lib/api/services/helpers/files/svg/svg-document.d.ts +26 -0
- package/lib/api/services/helpers/files/svg/svg-document.js +89 -0
- package/lib/api/services/helpers/files/svg/svg-memo.d.ts +1 -0
- package/lib/api/services/helpers/files/svg/svg-memo.js +8 -0
- package/lib/api/services/helpers/files/svg/svg-normalizer.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-normalizer.js +433 -0
- package/lib/api/services/helpers/files/svg/svg-numbers.d.ts +15 -0
- package/lib/api/services/helpers/files/svg/svg-numbers.js +61 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.constants.d.ts +8 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.constants.js +10 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.d.ts +9 -0
- package/lib/api/services/helpers/files/svg/svg-path-data.js +203 -0
- package/lib/api/services/helpers/files/svg/svg-path-types.d.ts +33 -0
- package/lib/api/services/helpers/files/svg/svg-path-types.js +1 -0
- package/lib/api/services/helpers/files/svg/svg-reader.constants.d.ts +35 -0
- package/lib/api/services/helpers/files/svg/svg-reader.constants.js +35 -0
- package/lib/api/services/helpers/files/svg/svg-reading.constants.d.ts +9 -0
- package/lib/api/services/helpers/files/svg/svg-reading.constants.js +9 -0
- package/lib/api/services/helpers/files/svg/svg-reading.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-reading.js +233 -0
- package/lib/api/services/helpers/files/svg/svg-scene-types.d.ts +54 -0
- package/lib/api/services/helpers/files/svg/svg-scene-types.js +1 -0
- package/lib/api/services/helpers/files/svg/svg-shapes.d.ts +6 -0
- package/lib/api/services/helpers/files/svg/svg-shapes.js +102 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.d.ts +38 -0
- package/lib/api/services/helpers/files/svg/svg-strokes.js +132 -0
- package/lib/api/services/helpers/files/svg/svg-style.d.ts +26 -0
- package/lib/api/services/helpers/files/svg/svg-style.js +211 -0
- package/lib/api/services/helpers/files/svg/svg-transform.d.ts +10 -0
- package/lib/api/services/helpers/files/svg/svg-transform.js +76 -0
- package/lib/api/services/helpers/files/svg/svg-writer.d.ts +18 -0
- package/lib/api/services/helpers/files/svg/svg-writer.js +230 -0
- package/lib/api/services/helpers/files/svg/svg-xml.d.ts +11 -0
- package/lib/api/services/helpers/files/svg/svg-xml.js +322 -0
- package/lib/api/services/helpers/files/svg/svg.constants.d.ts +14 -0
- package/lib/api/services/helpers/files/svg/svg.constants.js +14 -0
- package/lib/api/services/helpers/files/work-budget.d.ts +11 -0
- package/lib/api/services/helpers/files/work-budget.js +26 -0
- package/lib/api/services/helpers/geometry/affine2.d.ts +8 -0
- package/lib/api/services/helpers/geometry/affine2.js +18 -0
- package/lib/api/services/helpers/geometry/ellipse-arcs.d.ts +14 -0
- package/lib/api/services/helpers/geometry/ellipse-arcs.js +96 -0
- package/lib/api/services/helpers/geometry/frame-axes.d.ts +3 -1
- package/lib/api/services/helpers/geometry/loop-fill.d.ts +2 -0
- package/lib/api/services/helpers/geometry/loop-fill.js +37 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.constants.d.ts +6 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.constants.js +6 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.d.ts +31 -0
- package/lib/api/services/helpers/geometry/polygon-nesting.js +251 -0
- package/lib/api/services/helpers/geometry/vectors.d.ts +1 -0
- package/lib/api/services/helpers/geometry/vectors.js +6 -0
- package/lib/api/services/helpers/helper-types.d.ts +33 -0
- package/lib/api/services/helpers/text/stroke-font.d.ts +6 -0
- package/lib/api/services/helpers/text/stroke-font.js +177 -0
- package/lib/api/services/helpers/text/stroke-letters.constants.d.ts +2 -0
- package/lib/api/services/helpers/text/stroke-letters.constants.js +18 -0
- package/lib/api/services/helpers/text/stroke-marks.constants.d.ts +14 -0
- package/lib/api/services/helpers/text/stroke-marks.constants.js +34 -0
- package/lib/api/services/io/drawing.d.ts +368 -0
- package/lib/api/services/io/drawing.js +454 -0
- package/lib/api/services/io/dxf.d.ts +134 -0
- package/lib/api/services/io/dxf.js +167 -0
- package/lib/api/services/io/index.d.ts +4 -0
- package/lib/api/services/io/index.js +4 -0
- package/lib/api/services/io/io.d.ts +14 -0
- package/lib/api/services/io/io.js +15 -0
- package/lib/api/services/io/svg.d.ts +66 -0
- package/lib/api/services/io/svg.js +105 -0
- package/lib/api/services/line.d.ts +17 -0
- package/lib/api/services/line.js +20 -1
- package/lib/api/services/mesh.d.ts +19 -0
- package/lib/api/services/mesh.js +40 -0
- package/lib/api/services/point.d.ts +4 -1
- package/lib/api/services/point.js +9 -4
- package/lib/api/services/recipes.d.ts +3 -0
- package/lib/api/services/recipes.js +6 -2
- package/lib/api/services/text.d.ts +7 -4
- package/lib/api/services/text.js +14 -27
- package/package.json +1 -1
- package/lib/api/services/helpers/files/dxf/dxf.d.ts +0 -87
- package/lib/api/services/helpers/files/dxf/dxf.js +0 -111
- package/lib/api/services/io.d.ts +0 -9
- package/lib/api/services/io.js +0 -10
|
@@ -228,6 +228,23 @@ export declare namespace Line {
|
|
|
228
228
|
*/
|
|
229
229
|
tolerance?: number | undefined;
|
|
230
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* A line and a point for `line.distanceToPoint`, which measures from the point to the nearest
|
|
233
|
+
* point of the line between its start and its end.
|
|
234
|
+
*/
|
|
235
|
+
class LinePointDistanceDto {
|
|
236
|
+
constructor(line?: LinePointsDto, point?: Base.Point3);
|
|
237
|
+
/**
|
|
238
|
+
* The line to measure to; nothing past its start or its end counts.
|
|
239
|
+
* @default undefined
|
|
240
|
+
*/
|
|
241
|
+
line: LinePointsDto;
|
|
242
|
+
/**
|
|
243
|
+
* The point to measure from.
|
|
244
|
+
* @default undefined
|
|
245
|
+
*/
|
|
246
|
+
point: Base.Point3;
|
|
247
|
+
}
|
|
231
248
|
/**
|
|
232
249
|
* A line and a fraction along it for `line.getPointOnLine`.
|
|
233
250
|
*/
|
|
@@ -242,6 +242,21 @@ export var Line;
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
Line.LineLineIntersectionDto = LineLineIntersectionDto;
|
|
245
|
+
/**
|
|
246
|
+
* A line and a point for `line.distanceToPoint`, which measures from the point to the nearest
|
|
247
|
+
* point of the line between its start and its end.
|
|
248
|
+
*/
|
|
249
|
+
class LinePointDistanceDto {
|
|
250
|
+
constructor(line, point) {
|
|
251
|
+
if (line !== undefined) {
|
|
252
|
+
this.line = line;
|
|
253
|
+
}
|
|
254
|
+
if (point !== undefined) {
|
|
255
|
+
this.point = point;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
Line.LinePointDistanceDto = LinePointDistanceDto;
|
|
245
260
|
/**
|
|
246
261
|
* A line and a fraction along it for `line.getPointOnLine`.
|
|
247
262
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Base } from "./base-inputs";
|
|
2
2
|
/**
|
|
3
3
|
* Parameters for polygonal mesh geometry: vertex, index and normal data, the options for building and
|
|
4
4
|
* inspecting a mesh, and the settings that control conversion between the mesh representations the
|
|
@@ -136,6 +136,25 @@ export declare namespace Mesh {
|
|
|
136
136
|
*/
|
|
137
137
|
holes?: Base.Point3[][] | undefined;
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Closed loops lying in one plane and the rule that decides what they enclose, for
|
|
141
|
+
* `mesh.triangulateLoops`.
|
|
142
|
+
*/
|
|
143
|
+
class TriangulateLoopsDto {
|
|
144
|
+
constructor(loops?: Base.Point3[][], fillRule?: Base.loopFillRuleEnum);
|
|
145
|
+
/**
|
|
146
|
+
* The loops, each a list of corners in one plane; the last need not repeat the first, and loops
|
|
147
|
+
* may run either way and nest.
|
|
148
|
+
* @default undefined
|
|
149
|
+
*/
|
|
150
|
+
loops: Base.Point3[][];
|
|
151
|
+
/**
|
|
152
|
+
* How the loops decide what is inside: `evenOdd` leaves every loop inside another open
|
|
153
|
+
* whichever way it runs, as letters are filled; `nonZero` lets their directions count.
|
|
154
|
+
* @default evenOdd
|
|
155
|
+
*/
|
|
156
|
+
fillRule?: Base.loopFillRuleEnum | undefined;
|
|
157
|
+
}
|
|
139
158
|
/**
|
|
140
159
|
* Two triangle meshes and how close they may come, for `mesh.meshesWithin`.
|
|
141
160
|
*/
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
import { Base } from "./base-inputs";
|
|
1
3
|
/**
|
|
2
4
|
* Parameters for polygonal mesh geometry: vertex, index and normal data, the options for building and
|
|
3
5
|
* inspecting a mesh, and the settings that control conversion between the mesh representations the
|
|
@@ -130,6 +132,27 @@ export var Mesh;
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
Mesh.PolygonWithHolesDto = PolygonWithHolesDto;
|
|
135
|
+
/**
|
|
136
|
+
* Closed loops lying in one plane and the rule that decides what they enclose, for
|
|
137
|
+
* `mesh.triangulateLoops`.
|
|
138
|
+
*/
|
|
139
|
+
class TriangulateLoopsDto {
|
|
140
|
+
constructor(loops, fillRule) {
|
|
141
|
+
/**
|
|
142
|
+
* How the loops decide what is inside: `evenOdd` leaves every loop inside another open
|
|
143
|
+
* whichever way it runs, as letters are filled; `nonZero` lets their directions count.
|
|
144
|
+
* @default evenOdd
|
|
145
|
+
*/
|
|
146
|
+
this.fillRule = Base.loopFillRuleEnum.evenOdd;
|
|
147
|
+
if (loops !== undefined) {
|
|
148
|
+
this.loops = loops;
|
|
149
|
+
}
|
|
150
|
+
if (fillRule !== undefined) {
|
|
151
|
+
this.fillRule = fillRule;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
Mesh.TriangulateLoopsDto = TriangulateLoopsDto;
|
|
133
156
|
/**
|
|
134
157
|
* Two triangle meshes and how close they may come, for `mesh.meshesWithin`.
|
|
135
158
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Base } from "./base-inputs";
|
|
2
2
|
/**
|
|
3
3
|
* Parameters for working with recipes without a CAD kernel: the recipe to check or read, the roots
|
|
4
4
|
* to draw as meshes, and the node to follow. Experimental: the recipe format may still change before
|
|
@@ -26,7 +26,7 @@ export declare namespace Recipes {
|
|
|
26
26
|
* @beta
|
|
27
27
|
*/
|
|
28
28
|
class RecipeSurfaceMeshesDto {
|
|
29
|
-
constructor(recipe?: Base.Recipe, roots?: number[], adjustZtoY?: boolean);
|
|
29
|
+
constructor(recipe?: Base.Recipe, roots?: number[], adjustZtoY?: boolean, upAxis?: Base.upAxisConversionEnum);
|
|
30
30
|
/**
|
|
31
31
|
* The recipe: steps such as polygons, extrusions and triangle meshes, and the roots to build
|
|
32
32
|
* from them.
|
|
@@ -40,9 +40,17 @@ export declare namespace Recipes {
|
|
|
40
40
|
*/
|
|
41
41
|
roots?: number[] | undefined;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @default
|
|
43
|
+
* Whether the meshes turn: `zUpToYUp` turns each a quarter turn about X, as a kernel's recipe
|
|
44
|
+
* build does, so `(x, y, z)` becomes `(x, z, -y)`; `keep` leaves them. `yUpToZUp` is refused.
|
|
45
|
+
* @default keep
|
|
46
|
+
*/
|
|
47
|
+
upAxis?: Base.upAxisConversionEnum | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* When true, the meshes turn as `upAxis` `zUpToYUp` turns them; false, its old default, decides
|
|
50
|
+
* nothing. True wins over `upAxis` at its default; beside another chosen turn it is refused.
|
|
51
|
+
* @deprecated Give `upAxis` instead; this flag goes in the next major version.
|
|
52
|
+
* @default undefined
|
|
53
|
+
* @optional true
|
|
46
54
|
*/
|
|
47
55
|
adjustZtoY?: boolean | undefined;
|
|
48
56
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
import { Base } from "./base-inputs";
|
|
1
3
|
/**
|
|
2
4
|
* Parameters for working with recipes without a CAD kernel: the recipe to check or read, the roots
|
|
3
5
|
* to draw as meshes, and the node to follow. Experimental: the recipe format may still change before
|
|
@@ -25,13 +27,13 @@ export var Recipes;
|
|
|
25
27
|
* @beta
|
|
26
28
|
*/
|
|
27
29
|
class RecipeSurfaceMeshesDto {
|
|
28
|
-
constructor(recipe, roots, adjustZtoY) {
|
|
30
|
+
constructor(recipe, roots, adjustZtoY, upAxis) {
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @default
|
|
32
|
+
* Whether the meshes turn: `zUpToYUp` turns each a quarter turn about X, as a kernel's recipe
|
|
33
|
+
* build does, so `(x, y, z)` becomes `(x, z, -y)`; `keep` leaves them. `yUpToZUp` is refused.
|
|
34
|
+
* @default keep
|
|
33
35
|
*/
|
|
34
|
-
this.
|
|
36
|
+
this.upAxis = Base.upAxisConversionEnum.keep;
|
|
35
37
|
if (recipe !== undefined) {
|
|
36
38
|
this.recipe = recipe;
|
|
37
39
|
}
|
|
@@ -41,6 +43,9 @@ export var Recipes;
|
|
|
41
43
|
if (adjustZtoY !== undefined) {
|
|
42
44
|
this.adjustZtoY = adjustZtoY;
|
|
43
45
|
}
|
|
46
|
+
if (upAxis !== undefined) {
|
|
47
|
+
this.upAxis = upAxis;
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
Recipes.RecipeSurfaceMeshesDto = RecipeSurfaceMeshesDto;
|
|
@@ -35,11 +35,13 @@ export type WithDefaults<T, K extends keyof T> = Omit<T, K> & {
|
|
|
35
35
|
* that passed nothing gets the defaults alone. The result is a new plain object - a DTO carries data
|
|
36
36
|
* and no behaviour, and a plain object is what crosses a worker boundary and what a walk over the
|
|
37
37
|
* inputs treats as data - and the caller's object is never changed. Properties named in `nested`
|
|
38
|
-
* hold a DTO of their own and get its defaults the same way.
|
|
38
|
+
* hold a DTO of their own and get its defaults the same way. On a DTO with an `upAxis` default, the
|
|
39
|
+
* deprecated `adjustZtoY` and `adjustYtoZ` flags a caller gives are laid onto `upAxis` and dropped.
|
|
39
40
|
* @param Dto - The DTO class whose initializers are the defaults
|
|
40
41
|
* @param inputs - What the caller passed, usually an object literal
|
|
41
42
|
* @param nested - The properties that hold a DTO, and its class
|
|
42
43
|
* @returns A new plain object holding every default the caller did not override
|
|
44
|
+
* @throws InputError when a deprecated up-axis flag asks for another turn than `upAxis` or the other flag
|
|
43
45
|
*/
|
|
44
46
|
export declare function resolveDto<T extends object>(Dto: DtoConstructor<T>, inputs: unknown, nested?: Readonly<Record<string, DtoConstructor>>): T;
|
|
45
47
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isRecord } from "./unknown-values";
|
|
2
|
+
import { layUpAxisFlags } from "./up-axis-aliases";
|
|
2
3
|
/**
|
|
3
4
|
* Builds the DTO a service reads from what a caller passed: the defaults a new `Dto` holds, with the
|
|
4
5
|
* caller's properties laid over them. A property the caller set to undefined keeps its default, and
|
|
@@ -9,15 +10,18 @@ import { isRecord } from "./unknown-values";
|
|
|
9
10
|
* that passed nothing gets the defaults alone. The result is a new plain object - a DTO carries data
|
|
10
11
|
* and no behaviour, and a plain object is what crosses a worker boundary and what a walk over the
|
|
11
12
|
* inputs treats as data - and the caller's object is never changed. Properties named in `nested`
|
|
12
|
-
* hold a DTO of their own and get its defaults the same way.
|
|
13
|
+
* hold a DTO of their own and get its defaults the same way. On a DTO with an `upAxis` default, the
|
|
14
|
+
* deprecated `adjustZtoY` and `adjustYtoZ` flags a caller gives are laid onto `upAxis` and dropped.
|
|
13
15
|
* @param Dto - The DTO class whose initializers are the defaults
|
|
14
16
|
* @param inputs - What the caller passed, usually an object literal
|
|
15
17
|
* @param nested - The properties that hold a DTO, and its class
|
|
16
18
|
* @returns A new plain object holding every default the caller did not override
|
|
19
|
+
* @throws InputError when a deprecated up-axis flag asks for another turn than `upAxis` or the other flag
|
|
17
20
|
*/
|
|
18
21
|
export function resolveDto(Dto, inputs, nested) {
|
|
19
22
|
const resolved = {};
|
|
20
|
-
Object.assign(
|
|
23
|
+
const defaults = Object.assign({}, new Dto());
|
|
24
|
+
Object.assign(resolved, defaults);
|
|
21
25
|
const hasDefault = (key) => Object.prototype.hasOwnProperty.call(resolved, key) && resolved[key] !== undefined;
|
|
22
26
|
const isUnset = (key, value) => value === undefined
|
|
23
27
|
|| (value === null && hasDefault(key))
|
|
@@ -28,6 +32,7 @@ export function resolveDto(Dto, inputs, nested) {
|
|
|
28
32
|
resolved[key] = value;
|
|
29
33
|
}
|
|
30
34
|
}
|
|
35
|
+
layUpAxisFlags(resolved, inputs, defaults);
|
|
31
36
|
}
|
|
32
37
|
if (nested) {
|
|
33
38
|
for (const [key, NestedDto] of Object.entries(nested)) {
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
* One change a conventions level makes, told in words: the level that makes it, the operations
|
|
72
|
+
* whose results it changes and what changes in them. An entry is a dotted path as a script writes
|
|
73
|
+
* it after `bitbybit.`, and one that ends in a dot stands for everything under it.
|
|
74
|
+
*/
|
|
75
|
+
export interface ConventionChange {
|
|
76
|
+
/**
|
|
77
|
+
* The conventions level that makes the change, from 1
|
|
78
|
+
*/
|
|
79
|
+
readonly level: number;
|
|
80
|
+
/**
|
|
81
|
+
* The operations whose results it changes
|
|
82
|
+
*/
|
|
83
|
+
readonly entries: readonly string[];
|
|
84
|
+
/**
|
|
85
|
+
* What changes, in one sentence that starts with what it is about
|
|
86
|
+
*/
|
|
87
|
+
readonly change: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The settings that content saved with a conventions level runs by. Content carries one whole
|
|
91
|
+
* number instead of the settings themselves, since the right settings depend on the engine that runs it:
|
|
92
|
+
* 0, or no level at all, is the behaviour from before settings existed, and 1 and above are the
|
|
93
|
+
* engine's own settings. Levels only add, so one newer than this version knows runs by the newest
|
|
94
|
+
* it has.
|
|
95
|
+
*
|
|
96
|
+
* Anything but a whole number from 0 is refused as an `InputError`.
|
|
97
|
+
* @param level - The level the content was saved with, or nothing for content saved without one
|
|
98
|
+
* @param engineSettings - The settings that fit the engine, as a renderer's `engineSettings` gives them
|
|
99
|
+
* @returns The settings to run the content by
|
|
100
|
+
*/
|
|
101
|
+
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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Base } from "../inputs/base-inputs";
|
|
2
|
+
/**
|
|
3
|
+
* Lays the deprecated `adjustZtoY` and `adjustYtoZ` flags of a caller's inputs onto the `upAxis`
|
|
4
|
+
* of a DTO whose defaults carry one, and drops them. A flag at its released default (true where the
|
|
5
|
+
* DTO's `upAxis` defaults to the flag's turn, false elsewhere) decides nothing, as an old example or
|
|
6
|
+
* an old positional constructor spells it. Set the other way it decides: true chooses the flag's
|
|
7
|
+
* turn, false `keep`. A deciding flag wins over an `upAxis` equal to its default, since an editor
|
|
8
|
+
* passes every input and an explicit default cannot be told from one laid; it is refused beside an
|
|
9
|
+
* `upAxis` that chooses another turn, or beside the other flag deciding another one. An `upAxis`
|
|
10
|
+
* that is no turn is left for the method to refuse.
|
|
11
|
+
* @param resolved - The inputs over the DTO's defaults, changed in place
|
|
12
|
+
* @param given - The inputs as the caller passed them
|
|
13
|
+
* @param defaults - The DTO's defaults
|
|
14
|
+
* @throws InputError when the flags and `upAxis` ask for different turns, naming both
|
|
15
|
+
*/
|
|
16
|
+
export declare function layUpAxisFlags(resolved: Record<string, unknown>, given: Readonly<Record<string, unknown>>, defaults: Readonly<Record<string, unknown>>): void;
|
|
17
|
+
/**
|
|
18
|
+
* The turn an operation was asked for, among the ones it can make: an operation that reads Z-up
|
|
19
|
+
* files takes `keep` and `zUpToYUp`, one that writes for Z-up tools `keep` and `yUpToZUp`.
|
|
20
|
+
* @param value - The `upAxis` the operation received
|
|
21
|
+
* @param accepted - The turns the operation makes
|
|
22
|
+
* @returns The turn, typed
|
|
23
|
+
* @throws InputError when the value is not among `accepted`, naming the turns that are
|
|
24
|
+
*/
|
|
25
|
+
export declare function checkedUpAxis(value: unknown, accepted: readonly Base.upAxisConversionEnum[]): Base.upAxisConversionEnum;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Base } from "../inputs/base-inputs";
|
|
2
|
+
import { InputError } from "./errors";
|
|
3
|
+
const UP_AXIS = "upAxis";
|
|
4
|
+
const FLAG_TURNS = [
|
|
5
|
+
["adjustZtoY", Base.upAxisConversionEnum.zUpToYUp],
|
|
6
|
+
["adjustYtoZ", Base.upAxisConversionEnum.yUpToZUp],
|
|
7
|
+
];
|
|
8
|
+
const UP_AXIS_VALUES = Object.values(Base.upAxisConversionEnum);
|
|
9
|
+
function refused(by, flag, given) {
|
|
10
|
+
const said = by === UP_AXIS ? "`upAxis` chooses another turn" : `\`${by}\` asks for another turn`;
|
|
11
|
+
return new InputError(`\`${flag}\` is ${String(given)}, but ${said}: give \`upAxis\` alone, since \`${flag}\` is deprecated.`, flag);
|
|
12
|
+
}
|
|
13
|
+
function decidedBy(given, axis, fallback) {
|
|
14
|
+
var _a;
|
|
15
|
+
let decided = { value: axis, by: axis === fallback ? undefined : UP_AXIS };
|
|
16
|
+
for (const [flag, turn] of FLAG_TURNS) {
|
|
17
|
+
const value = given[flag];
|
|
18
|
+
if (typeof value !== "boolean" || value === (turn === fallback)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const asked = value ? turn : Base.upAxisConversionEnum.keep;
|
|
22
|
+
if (decided.by !== undefined && decided.value !== asked) {
|
|
23
|
+
throw refused(decided.by, flag, value);
|
|
24
|
+
}
|
|
25
|
+
decided = { value: asked, by: (_a = decided.by) !== null && _a !== void 0 ? _a : flag };
|
|
26
|
+
}
|
|
27
|
+
return decided;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Lays the deprecated `adjustZtoY` and `adjustYtoZ` flags of a caller's inputs onto the `upAxis`
|
|
31
|
+
* of a DTO whose defaults carry one, and drops them. A flag at its released default (true where the
|
|
32
|
+
* DTO's `upAxis` defaults to the flag's turn, false elsewhere) decides nothing, as an old example or
|
|
33
|
+
* an old positional constructor spells it. Set the other way it decides: true chooses the flag's
|
|
34
|
+
* turn, false `keep`. A deciding flag wins over an `upAxis` equal to its default, since an editor
|
|
35
|
+
* passes every input and an explicit default cannot be told from one laid; it is refused beside an
|
|
36
|
+
* `upAxis` that chooses another turn, or beside the other flag deciding another one. An `upAxis`
|
|
37
|
+
* that is no turn is left for the method to refuse.
|
|
38
|
+
* @param resolved - The inputs over the DTO's defaults, changed in place
|
|
39
|
+
* @param given - The inputs as the caller passed them
|
|
40
|
+
* @param defaults - The DTO's defaults
|
|
41
|
+
* @throws InputError when the flags and `upAxis` ask for different turns, naming both
|
|
42
|
+
*/
|
|
43
|
+
export function layUpAxisFlags(resolved, given, defaults) {
|
|
44
|
+
const fallback = defaults[UP_AXIS];
|
|
45
|
+
if (!UP_AXIS_VALUES.includes(fallback) || !FLAG_TURNS.some(([flag]) => typeof given[flag] === "boolean")) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const axis = resolved[UP_AXIS];
|
|
49
|
+
if (UP_AXIS_VALUES.includes(axis)) {
|
|
50
|
+
resolved[UP_AXIS] = decidedBy(given, axis, fallback).value;
|
|
51
|
+
}
|
|
52
|
+
for (const [flag] of FLAG_TURNS) {
|
|
53
|
+
delete resolved[flag];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The turn an operation was asked for, among the ones it can make: an operation that reads Z-up
|
|
58
|
+
* files takes `keep` and `zUpToYUp`, one that writes for Z-up tools `keep` and `yUpToZUp`.
|
|
59
|
+
* @param value - The `upAxis` the operation received
|
|
60
|
+
* @param accepted - The turns the operation makes
|
|
61
|
+
* @returns The turn, typed
|
|
62
|
+
* @throws InputError when the value is not among `accepted`, naming the turns that are
|
|
63
|
+
*/
|
|
64
|
+
export function checkedUpAxis(value, accepted) {
|
|
65
|
+
if (!accepted.includes(value)) {
|
|
66
|
+
const takes = accepted.map(turn => `\`${turn}\``).join(" or ");
|
|
67
|
+
throw new InputError(`\`${UP_AXIS}\` is \`${String(value)}\`, which this method does not take: it takes ${takes}.`, UP_AXIS);
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Keys are code points, not indices, so the map is sparse and reaches past ASCII: 176 is the degree
|
|
13
13
|
* symbol. A code point the font does not carry has no entry, which is why lookups are optional.
|
|
14
|
+
* An accented Latin letter has no entry either: the text service composes it from its letter's
|
|
15
|
+
* entry and a mark it holds for every font.
|
|
14
16
|
*/
|
|
15
17
|
export type VectorFont = {
|
|
16
18
|
height: number;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Hershey vector font data, taken from http://paulbourke.net/dataformats/hershey/ by way of the
|
|
3
3
|
* OpenJSCAD project (https://github.com/jscad/OpenJSCAD.org), which publishes it under the MIT
|
|
4
|
-
* License. The
|
|
4
|
+
* License. The Hershey Fonts may be used by anyone for any purpose, provided that these
|
|
5
|
+
* acknowledgements are distributed with the font data, and that the data is not converted into the
|
|
6
|
+
* format distributed by the U.S. NTIS:
|
|
7
|
+
*
|
|
8
|
+
* - The Hershey Fonts were originally created by Dr. A. V. Hershey while working at the
|
|
9
|
+
* U. S. National Bureau of Standards.
|
|
10
|
+
* - The format of the Font data in this distribution was originally created by James Hurt,
|
|
11
|
+
* Cognition, Inc., 900 Technology Park Drive, Billerica, MA 01821 (mit-eddie!ci-dandelion!hurt).
|
|
12
|
+
*
|
|
13
|
+
* The package's NOTICE carries the same.
|
|
5
14
|
*/
|
|
6
15
|
export const simplex = {
|
|
7
16
|
height: 21,
|
|
@@ -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
|
|
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
|
}
|