@constructorfleet/sketchforge-engine 0.0.0-stage → 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.
Files changed (279) hide show
  1. package/README.md +6 -2
  2. package/dist/alignShapes.d.ts +67 -0
  3. package/dist/alignShapes.d.ts.map +1 -0
  4. package/dist/alignShapes.js +81 -0
  5. package/dist/alignShapes.js.map +1 -0
  6. package/dist/booleanPrimitives.d.ts +20 -0
  7. package/dist/booleanPrimitives.d.ts.map +1 -0
  8. package/dist/booleanPrimitives.js +32 -0
  9. package/dist/booleanPrimitives.js.map +1 -0
  10. package/dist/cadBakeMetadata.d.ts +59 -0
  11. package/dist/cadBakeMetadata.d.ts.map +1 -0
  12. package/dist/cadBakeMetadata.js +209 -0
  13. package/dist/cadBakeMetadata.js.map +1 -0
  14. package/dist/cadMeasurements.d.ts +144 -0
  15. package/dist/cadMeasurements.d.ts.map +1 -0
  16. package/dist/cadMeasurements.js +134 -0
  17. package/dist/cadMeasurements.js.map +1 -0
  18. package/dist/cadModifierGroups.d.ts +2 -0
  19. package/dist/cadModifierGroups.d.ts.map +1 -0
  20. package/dist/cadModifierGroups.js +14 -0
  21. package/dist/cadModifierGroups.js.map +1 -0
  22. package/dist/cadSolids.d.ts +43 -0
  23. package/dist/cadSolids.d.ts.map +1 -0
  24. package/dist/cadSolids.js +393 -0
  25. package/dist/cadSolids.js.map +1 -0
  26. package/dist/cutterPadding.d.ts +129 -0
  27. package/dist/cutterPadding.d.ts.map +1 -0
  28. package/dist/cutterPadding.js +205 -0
  29. package/dist/cutterPadding.js.map +1 -0
  30. package/dist/distributeShapes.d.ts +60 -0
  31. package/dist/distributeShapes.d.ts.map +1 -0
  32. package/dist/distributeShapes.js +113 -0
  33. package/dist/distributeShapes.js.map +1 -0
  34. package/dist/domain/cadModifierTypes.d.ts +111 -0
  35. package/dist/domain/cadModifierTypes.d.ts.map +1 -0
  36. package/dist/domain/cadModifierTypes.js +2 -0
  37. package/dist/domain/cadModifierTypes.js.map +1 -0
  38. package/dist/domain/cameraProjection.d.ts +47 -0
  39. package/dist/domain/cameraProjection.d.ts.map +1 -0
  40. package/dist/domain/cameraProjection.js +59 -0
  41. package/dist/domain/cameraProjection.js.map +1 -0
  42. package/dist/domain/sketchforge.d.ts +293 -0
  43. package/dist/domain/sketchforge.d.ts.map +1 -0
  44. package/dist/domain/sketchforge.js +2 -0
  45. package/dist/domain/sketchforge.js.map +1 -0
  46. package/dist/editorHistory.d.ts +31 -0
  47. package/dist/editorHistory.d.ts.map +1 -0
  48. package/dist/editorHistory.js +327 -0
  49. package/dist/editorHistory.js.map +1 -0
  50. package/dist/engine.d.ts +281 -0
  51. package/dist/engine.d.ts.map +1 -0
  52. package/dist/engine.js +566 -0
  53. package/dist/engine.js.map +1 -0
  54. package/dist/exactBooleanParts.d.ts +73 -0
  55. package/dist/exactBooleanParts.d.ts.map +1 -0
  56. package/dist/exactBooleanParts.js +155 -0
  57. package/dist/exactBooleanParts.js.map +1 -0
  58. package/dist/exactBooleanSolids.d.ts +76 -0
  59. package/dist/exactBooleanSolids.d.ts.map +1 -0
  60. package/dist/exactBooleanSolids.js +121 -0
  61. package/dist/exactBooleanSolids.js.map +1 -0
  62. package/dist/gearProfile.d.ts +46 -0
  63. package/dist/gearProfile.d.ts.map +1 -0
  64. package/dist/gearProfile.js +76 -0
  65. package/dist/gearProfile.js.map +1 -0
  66. package/dist/index.d.ts +24 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +41 -0
  69. package/dist/index.js.map +1 -0
  70. package/dist/localIds.d.ts +2 -0
  71. package/dist/localIds.d.ts.map +1 -0
  72. package/dist/localIds.js +13 -0
  73. package/dist/localIds.js.map +1 -0
  74. package/dist/loftProfile.d.ts +49 -0
  75. package/dist/loftProfile.d.ts.map +1 -0
  76. package/dist/loftProfile.js +331 -0
  77. package/dist/loftProfile.js.map +1 -0
  78. package/dist/meshCoordinates.d.ts +6 -0
  79. package/dist/meshCoordinates.d.ts.map +1 -0
  80. package/dist/meshCoordinates.js +9 -0
  81. package/dist/meshCoordinates.js.map +1 -0
  82. package/dist/meshImport.d.ts +50 -0
  83. package/dist/meshImport.d.ts.map +1 -0
  84. package/dist/meshImport.js +86 -0
  85. package/dist/meshImport.js.map +1 -0
  86. package/dist/meshTransform.d.ts +17 -0
  87. package/dist/meshTransform.d.ts.map +1 -0
  88. package/dist/meshTransform.js +42 -0
  89. package/dist/meshTransform.js.map +1 -0
  90. package/dist/meshValidation.d.ts +10 -0
  91. package/dist/meshValidation.d.ts.map +1 -0
  92. package/dist/meshValidation.js +32 -0
  93. package/dist/meshValidation.js.map +1 -0
  94. package/dist/objImport.d.ts +3 -0
  95. package/dist/objImport.d.ts.map +1 -0
  96. package/dist/objImport.js +234 -0
  97. package/dist/objImport.js.map +1 -0
  98. package/dist/patternShapes.d.ts +79 -0
  99. package/dist/patternShapes.d.ts.map +1 -0
  100. package/dist/patternShapes.js +88 -0
  101. package/dist/patternShapes.js.map +1 -0
  102. package/dist/placementWorkplane.d.ts +43 -0
  103. package/dist/placementWorkplane.d.ts.map +1 -0
  104. package/dist/placementWorkplane.js +187 -0
  105. package/dist/placementWorkplane.js.map +1 -0
  106. package/dist/primitiveGeometry.d.ts +89 -0
  107. package/dist/primitiveGeometry.d.ts.map +1 -0
  108. package/dist/primitiveGeometry.js +241 -0
  109. package/dist/primitiveGeometry.js.map +1 -0
  110. package/dist/projectAssets.d.ts +11 -0
  111. package/dist/projectAssets.d.ts.map +1 -0
  112. package/dist/projectAssets.js +174 -0
  113. package/dist/projectAssets.js.map +1 -0
  114. package/dist/projectMeshes.d.ts +5 -0
  115. package/dist/projectMeshes.d.ts.map +1 -0
  116. package/dist/projectMeshes.js +38 -0
  117. package/dist/projectMeshes.js.map +1 -0
  118. package/dist/projectStore.d.ts +47 -0
  119. package/dist/projectStore.d.ts.map +1 -0
  120. package/dist/projectStore.js +34 -0
  121. package/dist/projectStore.js.map +1 -0
  122. package/dist/regularPolygonFootprint.d.ts +8 -0
  123. package/dist/regularPolygonFootprint.d.ts.map +1 -0
  124. package/dist/regularPolygonFootprint.js +25 -0
  125. package/dist/regularPolygonFootprint.js.map +1 -0
  126. package/dist/revolveRequests.d.ts +182 -0
  127. package/dist/revolveRequests.d.ts.map +1 -0
  128. package/dist/revolveRequests.js +317 -0
  129. package/dist/revolveRequests.js.map +1 -0
  130. package/dist/sceneExport.d.ts +22 -0
  131. package/dist/sceneExport.d.ts.map +1 -0
  132. package/dist/sceneExport.js +102 -0
  133. package/dist/sceneExport.js.map +1 -0
  134. package/dist/serverCadKernel.d.ts +36 -0
  135. package/dist/serverCadKernel.d.ts.map +1 -0
  136. package/dist/serverCadKernel.js +97 -0
  137. package/dist/serverCadKernel.js.map +1 -0
  138. package/dist/serverCadMeasure.d.ts +94 -0
  139. package/dist/serverCadMeasure.d.ts.map +1 -0
  140. package/dist/serverCadMeasure.js +158 -0
  141. package/dist/serverCadMeasure.js.map +1 -0
  142. package/dist/serverCadOperations.d.ts +128 -0
  143. package/dist/serverCadOperations.d.ts.map +1 -0
  144. package/dist/serverCadOperations.js +400 -0
  145. package/dist/serverCadOperations.js.map +1 -0
  146. package/dist/serverCadShell.d.ts +122 -0
  147. package/dist/serverCadShell.d.ts.map +1 -0
  148. package/dist/serverCadShell.js +312 -0
  149. package/dist/serverCadShell.js.map +1 -0
  150. package/dist/serverManifoldRuntime.d.ts +13 -0
  151. package/dist/serverManifoldRuntime.d.ts.map +1 -0
  152. package/dist/serverManifoldRuntime.js +29 -0
  153. package/dist/serverManifoldRuntime.js.map +1 -0
  154. package/dist/serverProjectDocument.d.ts +47 -0
  155. package/dist/serverProjectDocument.d.ts.map +1 -0
  156. package/dist/serverProjectDocument.js +115 -0
  157. package/dist/serverProjectDocument.js.map +1 -0
  158. package/dist/serverProjectFiles.d.ts +38 -0
  159. package/dist/serverProjectFiles.d.ts.map +1 -0
  160. package/dist/serverProjectFiles.js +144 -0
  161. package/dist/serverProjectFiles.js.map +1 -0
  162. package/dist/serverShapeBooleans.d.ts +68 -0
  163. package/dist/serverShapeBooleans.d.ts.map +1 -0
  164. package/dist/serverShapeBooleans.js +176 -0
  165. package/dist/serverShapeBooleans.js.map +1 -0
  166. package/dist/serverShapeGroups.d.ts +107 -0
  167. package/dist/serverShapeGroups.d.ts.map +1 -0
  168. package/dist/serverShapeGroups.js +454 -0
  169. package/dist/serverShapeGroups.js.map +1 -0
  170. package/dist/shapeBounds.d.ts +36 -0
  171. package/dist/shapeBounds.d.ts.map +1 -0
  172. package/dist/shapeBounds.js +51 -0
  173. package/dist/shapeBounds.js.map +1 -0
  174. package/dist/shapeCatalog.d.ts +22 -0
  175. package/dist/shapeCatalog.d.ts.map +1 -0
  176. package/dist/shapeCatalog.js +193 -0
  177. package/dist/shapeCatalog.js.map +1 -0
  178. package/dist/shapeRequests.d.ts +125 -0
  179. package/dist/shapeRequests.d.ts.map +1 -0
  180. package/dist/shapeRequests.js +384 -0
  181. package/dist/shapeRequests.js.map +1 -0
  182. package/dist/sketchRevolve.d.ts +45 -0
  183. package/dist/sketchRevolve.d.ts.map +1 -0
  184. package/dist/sketchRevolve.js +381 -0
  185. package/dist/sketchRevolve.js.map +1 -0
  186. package/dist/skfProject.d.ts +188 -0
  187. package/dist/skfProject.d.ts.map +1 -0
  188. package/dist/skfProject.js +1371 -0
  189. package/dist/skfProject.js.map +1 -0
  190. package/dist/sphereTessellation.d.ts +6 -0
  191. package/dist/sphereTessellation.d.ts.map +1 -0
  192. package/dist/sphereTessellation.js +9 -0
  193. package/dist/sphereTessellation.js.map +1 -0
  194. package/dist/stepExport.d.ts +20 -0
  195. package/dist/stepExport.d.ts.map +1 -0
  196. package/dist/stepExport.js +340 -0
  197. package/dist/stepExport.js.map +1 -0
  198. package/dist/stepImport.d.ts +4 -0
  199. package/dist/stepImport.d.ts.map +1 -0
  200. package/dist/stepImport.js +73 -0
  201. package/dist/stepImport.js.map +1 -0
  202. package/dist/stepImportKernel.d.ts +15 -0
  203. package/dist/stepImportKernel.d.ts.map +1 -0
  204. package/dist/stepImportKernel.js +134 -0
  205. package/dist/stepImportKernel.js.map +1 -0
  206. package/dist/stepProfiles.d.ts +65 -0
  207. package/dist/stepProfiles.d.ts.map +1 -0
  208. package/dist/stepProfiles.js +98 -0
  209. package/dist/stepProfiles.js.map +1 -0
  210. package/dist/stlImport.d.ts +5 -0
  211. package/dist/stlImport.d.ts.map +1 -0
  212. package/dist/stlImport.js +121 -0
  213. package/dist/stlImport.js.map +1 -0
  214. package/dist/support/cadModifierTypes.d.ts +111 -0
  215. package/dist/support/cadModifierTypes.d.ts.map +1 -0
  216. package/dist/support/cadModifierTypes.js +2 -0
  217. package/dist/support/cadModifierTypes.js.map +1 -0
  218. package/dist/support/i18n/LocalizedError.d.ts +28 -0
  219. package/dist/support/i18n/LocalizedError.d.ts.map +1 -0
  220. package/dist/support/i18n/LocalizedError.js +25 -0
  221. package/dist/support/i18n/LocalizedError.js.map +1 -0
  222. package/dist/support/i18n/locales/en/messages.json +1555 -0
  223. package/dist/support/i18n/locales.d.ts +7 -0
  224. package/dist/support/i18n/locales.d.ts.map +1 -0
  225. package/dist/support/i18n/locales.js +4 -0
  226. package/dist/support/i18n/locales.js.map +1 -0
  227. package/dist/support/i18n/translator.d.ts +2 -0
  228. package/dist/support/i18n/translator.d.ts.map +1 -0
  229. package/dist/support/i18n/translator.js +2 -0
  230. package/dist/support/i18n/translator.js.map +1 -0
  231. package/dist/support/lib/appTheme.d.ts +10 -0
  232. package/dist/support/lib/appTheme.d.ts.map +1 -0
  233. package/dist/support/lib/appTheme.js +39 -0
  234. package/dist/support/lib/appTheme.js.map +1 -0
  235. package/dist/support/lib/brepKernel.d.ts +4 -0
  236. package/dist/support/lib/brepKernel.d.ts.map +1 -0
  237. package/dist/support/lib/brepKernel.js +41 -0
  238. package/dist/support/lib/brepKernel.js.map +1 -0
  239. package/dist/support/lib/cameraProjection.d.ts +2 -0
  240. package/dist/support/lib/cameraProjection.d.ts.map +1 -0
  241. package/dist/support/lib/cameraProjection.js +2 -0
  242. package/dist/support/lib/cameraProjection.js.map +1 -0
  243. package/dist/support/lib/materialPresets.d.ts +89 -0
  244. package/dist/support/lib/materialPresets.d.ts.map +1 -0
  245. package/dist/support/lib/materialPresets.js +175 -0
  246. package/dist/support/lib/materialPresets.js.map +1 -0
  247. package/dist/support/lib/measurementUnits.d.ts +23 -0
  248. package/dist/support/lib/measurementUnits.d.ts.map +1 -0
  249. package/dist/support/lib/measurementUnits.js +106 -0
  250. package/dist/support/lib/measurementUnits.js.map +1 -0
  251. package/dist/support/lib/serverProjectStore.d.ts +69 -0
  252. package/dist/support/lib/serverProjectStore.d.ts.map +1 -0
  253. package/dist/support/lib/serverProjectStore.js +118 -0
  254. package/dist/support/lib/serverProjectStore.js.map +1 -0
  255. package/dist/support/lib/workplaneGrid.d.ts +71 -0
  256. package/dist/support/lib/workplaneGrid.d.ts.map +1 -0
  257. package/dist/support/lib/workplaneGrid.js +117 -0
  258. package/dist/support/lib/workplaneGrid.js.map +1 -0
  259. package/dist/svgImport.d.ts +34 -0
  260. package/dist/svgImport.d.ts.map +1 -0
  261. package/dist/svgImport.js +595 -0
  262. package/dist/svgImport.js.map +1 -0
  263. package/dist/svgMeshProjection.d.ts +6 -0
  264. package/dist/svgMeshProjection.d.ts.map +1 -0
  265. package/dist/svgMeshProjection.js +18 -0
  266. package/dist/svgMeshProjection.js.map +1 -0
  267. package/dist/threadCatalog.d.ts +73 -0
  268. package/dist/threadCatalog.d.ts.map +1 -0
  269. package/dist/threadCatalog.js +108 -0
  270. package/dist/threadCatalog.js.map +1 -0
  271. package/dist/workplaneSettings.d.ts +32 -0
  272. package/dist/workplaneSettings.d.ts.map +1 -0
  273. package/dist/workplaneSettings.js +215 -0
  274. package/dist/workplaneSettings.js.map +1 -0
  275. package/dist/workplaneShapes.d.ts +35 -0
  276. package/dist/workplaneShapes.d.ts.map +1 -0
  277. package/dist/workplaneShapes.js +309 -0
  278. package/dist/workplaneShapes.js.map +1 -0
  279. package/package.json +52 -4
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
- # Temporary Holding Version
1
+ # SketchForge engine
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The package owns SketchForge's shape model, project format, geometry operations, and filesystem-backed project store. The web app and local MCP both use this implementation.
4
+
5
+ Build it from the repository root with `npm run engine:build`. It emits Node ESM and TypeScript declarations under `dist/`. Node consumers need Node 20 or newer. Kernel modules load only when a CAD or STEP operation needs them; the package selects the staged browser kernel in a browser and the Node package loader in Node.
6
+
7
+ The package is published as `@constructorfleet/sketchforge-engine` from the repository release workflow and is used by the web editor, the server, and the local MCP client. It is licensed under AGPL-3.0-only.
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Bringing a selection onto one line.
3
+ *
4
+ * Distribute spaces objects along an axis; this puts an edge or a centre of
5
+ * each on the same coordinate. The editor has done it since there was an
6
+ * Alignment button, but the arithmetic lived inside `SketchForgeEditor.tsx`
7
+ * with the overlay that drives it, so neither the API nor a macro could reach
8
+ * it -- which is why this file exists and why it is shaped like
9
+ * `distributeShapes`: pure, and in terms of extents rather than shapes, so the
10
+ * editor can feed it mesh bounds and a test can feed it numbers.
11
+ *
12
+ * Two things do not move. An anchor is the object the caller nominated as the
13
+ * reference, and a locked object is one that cannot move at all -- so a locked
14
+ * object in the selection becomes the anchor whatever the caller asked for,
15
+ * which is what the editor does and the only reading under which a selection
16
+ * holding one can be aligned at all.
17
+ */
18
+ export type AlignAxis = "x" | "y" | "z";
19
+ export type AlignTarget = "min" | "center" | "max";
20
+ export type AlignEntry = {
21
+ id: string;
22
+ /** Lowest coordinate of the object along the axis being aligned. */
23
+ min: number;
24
+ /** Highest coordinate along that axis. */
25
+ max: number;
26
+ /** An object that cannot move: it anchors the alignment instead. */
27
+ locked?: boolean;
28
+ };
29
+ export type AlignShift = {
30
+ id: string;
31
+ /** How far this object moves along the axis. */
32
+ delta: number;
33
+ };
34
+ /**
35
+ * Half a thousandth of a millimetre, the editor's own alignment tolerance.
36
+ *
37
+ * Coordinates are stored rounded to four decimals, so anything smaller than
38
+ * this cannot be represented in the project and a shift of it would be written
39
+ * as no shift at all.
40
+ */
41
+ export declare const ALIGN_EPSILON = 0.0005;
42
+ /** The coordinate an entry's chosen edge or centre sits at. */
43
+ export declare function alignCoordinate(entry: Pick<AlignEntry, "min" | "max">, target: AlignTarget): number;
44
+ /**
45
+ * The entry everything else lines up against, or null for the selection's own box.
46
+ *
47
+ * A locked object wins over the requested anchor, and over a second locked one
48
+ * the first in the selection wins -- an arbitrary choice, but the alternative
49
+ * is refusing a selection with two locked objects in it, and aligning the rest
50
+ * to one of them is the more useful answer and the one the editor gives. A
51
+ * requested anchor that is not in the selection is ignored rather than
52
+ * refused, because the selection is what the caller is aligning.
53
+ */
54
+ export declare function effectiveAlignAnchorId(entries: readonly AlignEntry[], requestedAnchorId?: string | null): string | null;
55
+ /**
56
+ * How far each object should move to be aligned, in the order given.
57
+ *
58
+ * Objects already in place are left out rather than returned with a zero
59
+ * delta, so a caller can tell whether anything actually happened -- the same
60
+ * promise `distributeShifts` makes, and what lets an unchanged selection
61
+ * record no undo step.
62
+ *
63
+ * Fewer than two objects has nothing to align *to*: one object is already
64
+ * flush with itself.
65
+ */
66
+ export declare function alignShifts(entries: readonly AlignEntry[], target: AlignTarget, anchorId?: string | null): AlignShift[];
67
+ //# sourceMappingURL=alignShapes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alignShapes.d.ts","sourceRoot":"","sources":["../src/alignShapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACxC,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,UAI1F;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,iBAIvG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,MAAM,EAAE,WAAW,EACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GACvB,UAAU,EAAE,CAkBd"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Bringing a selection onto one line.
3
+ *
4
+ * Distribute spaces objects along an axis; this puts an edge or a centre of
5
+ * each on the same coordinate. The editor has done it since there was an
6
+ * Alignment button, but the arithmetic lived inside `SketchForgeEditor.tsx`
7
+ * with the overlay that drives it, so neither the API nor a macro could reach
8
+ * it -- which is why this file exists and why it is shaped like
9
+ * `distributeShapes`: pure, and in terms of extents rather than shapes, so the
10
+ * editor can feed it mesh bounds and a test can feed it numbers.
11
+ *
12
+ * Two things do not move. An anchor is the object the caller nominated as the
13
+ * reference, and a locked object is one that cannot move at all -- so a locked
14
+ * object in the selection becomes the anchor whatever the caller asked for,
15
+ * which is what the editor does and the only reading under which a selection
16
+ * holding one can be aligned at all.
17
+ */
18
+ /**
19
+ * Half a thousandth of a millimetre, the editor's own alignment tolerance.
20
+ *
21
+ * Coordinates are stored rounded to four decimals, so anything smaller than
22
+ * this cannot be represented in the project and a shift of it would be written
23
+ * as no shift at all.
24
+ */
25
+ export const ALIGN_EPSILON = 0.0005;
26
+ /** The coordinate an entry's chosen edge or centre sits at. */
27
+ export function alignCoordinate(entry, target) {
28
+ if (target === "min")
29
+ return entry.min;
30
+ if (target === "max")
31
+ return entry.max;
32
+ return (entry.min + entry.max) / 2;
33
+ }
34
+ /**
35
+ * The entry everything else lines up against, or null for the selection's own box.
36
+ *
37
+ * A locked object wins over the requested anchor, and over a second locked one
38
+ * the first in the selection wins -- an arbitrary choice, but the alternative
39
+ * is refusing a selection with two locked objects in it, and aligning the rest
40
+ * to one of them is the more useful answer and the one the editor gives. A
41
+ * requested anchor that is not in the selection is ignored rather than
42
+ * refused, because the selection is what the caller is aligning.
43
+ */
44
+ export function effectiveAlignAnchorId(entries, requestedAnchorId) {
45
+ const locked = entries.find((entry) => entry.locked);
46
+ if (locked)
47
+ return locked.id;
48
+ return requestedAnchorId && entries.some((entry) => entry.id === requestedAnchorId) ? requestedAnchorId : null;
49
+ }
50
+ /**
51
+ * How far each object should move to be aligned, in the order given.
52
+ *
53
+ * Objects already in place are left out rather than returned with a zero
54
+ * delta, so a caller can tell whether anything actually happened -- the same
55
+ * promise `distributeShifts` makes, and what lets an unchanged selection
56
+ * record no undo step.
57
+ *
58
+ * Fewer than two objects has nothing to align *to*: one object is already
59
+ * flush with itself.
60
+ */
61
+ export function alignShifts(entries, target, anchorId) {
62
+ if (entries.length < 2)
63
+ return [];
64
+ const anchor = anchorId ? entries.find((entry) => entry.id === anchorId) ?? null : null;
65
+ const reference = anchor ?? {
66
+ min: Math.min(...entries.map((entry) => entry.min)),
67
+ max: Math.max(...entries.map((entry) => entry.max)),
68
+ };
69
+ const targetValue = alignCoordinate(reference, target);
70
+ const shifts = [];
71
+ entries.forEach((entry) => {
72
+ if (entry.locked || entry.id === anchorId)
73
+ return;
74
+ const delta = targetValue - alignCoordinate(entry, target);
75
+ if (Math.abs(delta) <= ALIGN_EPSILON)
76
+ return;
77
+ shifts.push({ id: entry.id, delta });
78
+ });
79
+ return shifts;
80
+ }
81
+ //# sourceMappingURL=alignShapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alignShapes.js","sourceRoot":"","sources":["../src/alignShapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAqBH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAEpC,+DAA+D;AAC/D,MAAM,UAAU,eAAe,CAAC,KAAsC,EAAE,MAAmB;IACzF,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IACvC,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IACvC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA8B,EAAE,iBAAiC;IACtG,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,EAAE,CAAC;IAC7B,OAAO,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC;AACjH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACzB,OAA8B,EAC9B,MAAmB,EACnB,QAAwB;IAExB,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAElC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACxF,MAAM,SAAS,GAAG,MAAM,IAAI;QAC1B,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnD,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACpD,CAAC;IACF,MAAM,WAAW,GAAG,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAEvD,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,KAAK,QAAQ;YAAE,OAAO;QAClD,MAAM,KAAK,GAAG,WAAW,GAAG,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,aAAa;YAAE,OAAO;QAC7C,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { WorkplaneShape } from "./domain/sketchforge.js";
2
+ /**
3
+ * Whether a shape can stand in for an axis-aligned cuboid during a boolean.
4
+ *
5
+ * The fast boolean paths replace such a shape with a plain box built from its
6
+ * width, depth and height -- cuboid arithmetic, or a Manifold cube primitive.
7
+ * A tapered box is not a cuboid: its horizontal section changes with height, so
8
+ * substituting one silently discards the taper from the result.
9
+ */
10
+ export declare function isAxisAlignedBoxCutter(shape: WorkplaneShape): boolean;
11
+ /**
12
+ * Whether a shape's silhouette is fully described by width/depth/height, so a
13
+ * primitive solid can be built from those three numbers instead of meshing it.
14
+ *
15
+ * Taper is the exception every primitive builder here misses: cube, sphere,
16
+ * cylinder and cone all take a single size per axis. A tapered shape has to go
17
+ * the long way through its real mesh, which applies the taper per vertex.
18
+ */
19
+ export declare function canUsePrimitiveSolid(shape: WorkplaneShape): boolean;
20
+ //# sourceMappingURL=booleanPrimitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booleanPrimitives.d.ts","sourceRoot":"","sources":["../src/booleanPrimitives.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAO9D;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,WAM3D;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,WAEzD"}
@@ -0,0 +1,32 @@
1
+ import { normalizeDegrees, shapeHasTaper } from "./workplaneShapes.js";
2
+ function straightAngle(value) {
3
+ const angle = Math.abs(normalizeDegrees(value));
4
+ return angle < 0.001 || Math.abs(angle - 180) < 0.001 || Math.abs(angle - 360) < 0.001;
5
+ }
6
+ /**
7
+ * Whether a shape can stand in for an axis-aligned cuboid during a boolean.
8
+ *
9
+ * The fast boolean paths replace such a shape with a plain box built from its
10
+ * width, depth and height -- cuboid arithmetic, or a Manifold cube primitive.
11
+ * A tapered box is not a cuboid: its horizontal section changes with height, so
12
+ * substituting one silently discards the taper from the result.
13
+ */
14
+ export function isAxisAlignedBoxCutter(shape) {
15
+ return shape.kind === "box"
16
+ && straightAngle(shape.rotation)
17
+ && straightAngle(shape.rotationX ?? 0)
18
+ && straightAngle(shape.rotationZ ?? 0)
19
+ && !shapeHasTaper(shape);
20
+ }
21
+ /**
22
+ * Whether a shape's silhouette is fully described by width/depth/height, so a
23
+ * primitive solid can be built from those three numbers instead of meshing it.
24
+ *
25
+ * Taper is the exception every primitive builder here misses: cube, sphere,
26
+ * cylinder and cone all take a single size per axis. A tapered shape has to go
27
+ * the long way through its real mesh, which applies the taper per vertex.
28
+ */
29
+ export function canUsePrimitiveSolid(shape) {
30
+ return !shapeHasTaper(shape);
31
+ }
32
+ //# sourceMappingURL=booleanPrimitives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booleanPrimitives.js","sourceRoot":"","sources":["../src/booleanPrimitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGvE,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,OAAO,KAAK,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;AACzF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAqB;IAC1D,OAAO,KAAK,CAAC,IAAI,KAAK,KAAK;WACtB,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC;WAC7B,aAAa,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC;WACnC,aAAa,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC;WACnC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAqB;IACxD,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,59 @@
1
+ import * as THREE from "three";
2
+ import type { WorkplaneShape } from "./domain/sketchforge.js";
3
+ import type { CadModifierPrimitivePart } from "./support/cadModifierTypes.js";
4
+ export type BakedCadMetadataFrame = {
5
+ centerX: number;
6
+ minY: number;
7
+ centerZ: number;
8
+ width: number;
9
+ depth: number;
10
+ height: number;
11
+ yawDegrees: number;
12
+ };
13
+ export declare function cadTransformToMatrix(transform: number[] | undefined): THREE.Matrix4;
14
+ export declare function cadTransformFromMatrix(matrix: THREE.Matrix4): number[];
15
+ export declare function cadModifierPrimitiveForAnalyticBox(shape: WorkplaneShape): CadModifierPrimitivePart | null;
16
+ export declare function cadModifierPrimitiveForBakedShape(shape: WorkplaneShape): CadModifierPrimitivePart | null;
17
+ export declare function bakedBoxSelectionFrame(shape: WorkplaneShape): {
18
+ center: THREE.Vector3;
19
+ quaternion: THREE.Quaternion;
20
+ xAxis: THREE.Vector3;
21
+ yAxis: THREE.Vector3;
22
+ zAxis: THREE.Vector3;
23
+ width: number;
24
+ height: number;
25
+ depth: number;
26
+ } | null;
27
+ export declare function cadBrepTransformForShape(shape: WorkplaneShape): number[] | undefined;
28
+ export declare function bakeCadMetadataForShapeTransform(shape: WorkplaneShape, frame: BakedCadMetadataFrame): {
29
+ cadDisplayEdges: {
30
+ points: number[];
31
+ }[] | undefined;
32
+ cadDisplayEdgesVersion: 2 | undefined;
33
+ cadBrep: string | undefined;
34
+ cadBrepFrame: {
35
+ sourceTransform?: number[] | undefined;
36
+ x: number;
37
+ z: number;
38
+ elevation: number;
39
+ width: number;
40
+ depth: number;
41
+ height: number;
42
+ } | undefined;
43
+ cadPrimitiveFrame: {
44
+ kind: "box";
45
+ width: number;
46
+ depth: number;
47
+ height: number;
48
+ frame: {
49
+ sourceTransform?: number[] | undefined;
50
+ x: number;
51
+ z: number;
52
+ elevation: number;
53
+ width: number;
54
+ depth: number;
55
+ height: number;
56
+ };
57
+ } | undefined;
58
+ };
59
+ //# sourceMappingURL=cadBakeMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cadBakeMetadata.d.ts","sourceRoot":"","sources":["../src/cadBakeMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAG9E,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,iBAWnE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,YAO3D;AAWD,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,cAAc,GAAG,wBAAwB,GAAG,IAAI,CAkCzG;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,cAAc,GAAG,wBAAwB,GAAG,IAAI,CAmDxG;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc;;;;;;;;;SA+B3D;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,cAAc,wBAsB7D;AAqED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBnG"}
@@ -0,0 +1,209 @@
1
+ import * as THREE from "three";
2
+ import { mirrorSign, resizedImportedCoordinates, shapeDepth, shapeWidth } from "./workplaneShapes.js";
3
+ export function cadTransformToMatrix(transform) {
4
+ if (!transform || transform.length !== 12 || !transform.every(Number.isFinite)) {
5
+ return new THREE.Matrix4();
6
+ }
7
+ return new THREE.Matrix4().set(transform[0], transform[1], transform[2], transform[3], transform[4], transform[5], transform[6], transform[7], transform[8], transform[9], transform[10], transform[11], 0, 0, 0, 1);
8
+ }
9
+ export function cadTransformFromMatrix(matrix) {
10
+ const elements = matrix.elements;
11
+ return [
12
+ elements[0], elements[4], elements[8], elements[12],
13
+ elements[1], elements[5], elements[9], elements[13],
14
+ elements[2], elements[6], elements[10], elements[14],
15
+ ];
16
+ }
17
+ function isIdentityCadTransform(transform) {
18
+ const identity = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0];
19
+ return transform.every((value, index) => Math.abs(value - identity[index]) < 1e-9);
20
+ }
21
+ function allFinitePositive(values) {
22
+ return values.every((value) => Number.isFinite(value) && value > 0);
23
+ }
24
+ export function cadModifierPrimitiveForAnalyticBox(shape) {
25
+ if (shape.kind !== "box" || shape.importedMesh || shape.groupedShapes?.length) {
26
+ return null;
27
+ }
28
+ const width = shapeWidth(shape);
29
+ const depth = shapeDepth(shape);
30
+ const height = shape.height;
31
+ if (!allFinitePositive([width, depth, height])) {
32
+ return null;
33
+ }
34
+ const centerY = height / 2;
35
+ const matrix = new THREE.Matrix4()
36
+ .makeTranslation(shape.x, (shape.elevation ?? 0) + centerY, shape.z)
37
+ .multiply(new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(THREE.MathUtils.degToRad(shape.rotationX ?? 0), THREE.MathUtils.degToRad(shape.rotation ?? 0), THREE.MathUtils.degToRad(shape.rotationZ ?? 0), "XYZ")))
38
+ .multiply(new THREE.Matrix4().makeScale(mirrorSign(shape.mirrorX), mirrorSign(shape.mirrorY), mirrorSign(shape.mirrorZ)))
39
+ .multiply(new THREE.Matrix4().makeTranslation(0, -centerY, 0));
40
+ const transform = cadTransformFromMatrix(matrix);
41
+ return {
42
+ kind: "box",
43
+ width,
44
+ depth,
45
+ height,
46
+ transform: isIdentityCadTransform(transform) ? undefined : transform,
47
+ };
48
+ }
49
+ export function cadModifierPrimitiveForBakedShape(shape) {
50
+ const primitive = shape.cadPrimitiveFrame;
51
+ const frame = primitive?.frame;
52
+ if (!primitive || primitive.kind !== "box" || !frame) {
53
+ return null;
54
+ }
55
+ if (!allFinitePositive([
56
+ primitive.width,
57
+ primitive.depth,
58
+ primitive.height,
59
+ frame.width,
60
+ frame.depth,
61
+ frame.height,
62
+ shapeWidth(shape),
63
+ shapeDepth(shape),
64
+ shape.height,
65
+ ])) {
66
+ return null;
67
+ }
68
+ const centerY = shape.height / 2;
69
+ const scaleX = shapeWidth(shape) / frame.width;
70
+ const scaleY = shape.height / frame.height;
71
+ const scaleZ = shapeDepth(shape) / frame.depth;
72
+ const mirrorX = mirrorSign(shape.mirrorX);
73
+ const mirrorY = mirrorSign(shape.mirrorY);
74
+ const mirrorZ = mirrorSign(shape.mirrorZ);
75
+ const matrix = new THREE.Matrix4()
76
+ .makeTranslation(shape.x, (shape.elevation ?? 0) + centerY, shape.z)
77
+ .multiply(new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(THREE.MathUtils.degToRad(shape.rotationX ?? 0), THREE.MathUtils.degToRad(shape.rotation ?? 0), THREE.MathUtils.degToRad(shape.rotationZ ?? 0), "XYZ")))
78
+ .multiply(new THREE.Matrix4().makeTranslation(0, -mirrorY * centerY, 0))
79
+ .multiply(new THREE.Matrix4().makeScale(mirrorX * scaleX, mirrorY * scaleY, mirrorZ * scaleZ))
80
+ .multiply(new THREE.Matrix4().makeTranslation(-frame.x, -frame.elevation, -frame.z))
81
+ .multiply(cadTransformToMatrix(frame.sourceTransform));
82
+ const transform = cadTransformFromMatrix(matrix);
83
+ return {
84
+ kind: primitive.kind,
85
+ width: primitive.width,
86
+ depth: primitive.depth,
87
+ height: primitive.height,
88
+ transform: isIdentityCadTransform(transform) ? undefined : transform,
89
+ };
90
+ }
91
+ export function bakedBoxSelectionFrame(shape) {
92
+ const primitive = cadModifierPrimitiveForBakedShape(shape);
93
+ if (!primitive || primitive.kind !== "box") {
94
+ return null;
95
+ }
96
+ const matrix = cadTransformToMatrix(primitive.transform);
97
+ const xVector = new THREE.Vector3(primitive.width, 0, 0).applyMatrix3(new THREE.Matrix3().setFromMatrix4(matrix));
98
+ const yVector = new THREE.Vector3(0, primitive.height, 0).applyMatrix3(new THREE.Matrix3().setFromMatrix4(matrix));
99
+ const zVector = new THREE.Vector3(0, 0, primitive.depth).applyMatrix3(new THREE.Matrix3().setFromMatrix4(matrix));
100
+ const width = xVector.length();
101
+ const height = yVector.length();
102
+ const depth = zVector.length();
103
+ if (![width, height, depth].every((value) => Number.isFinite(value) && value > 0.001)) {
104
+ return null;
105
+ }
106
+ const xAxis = xVector.normalize();
107
+ const yAxis = yVector.normalize();
108
+ const zAxis = zVector.normalize();
109
+ const center = new THREE.Vector3(0, primitive.height / 2, 0).applyMatrix4(matrix);
110
+ const basis = new THREE.Matrix4().makeBasis(xAxis, yAxis, zAxis);
111
+ return {
112
+ center,
113
+ quaternion: new THREE.Quaternion().setFromRotationMatrix(basis),
114
+ xAxis,
115
+ yAxis,
116
+ zAxis,
117
+ width,
118
+ height,
119
+ depth,
120
+ };
121
+ }
122
+ export function cadBrepTransformForShape(shape) {
123
+ const frame = shape.cadBrepFrame;
124
+ if (!frame)
125
+ return undefined;
126
+ const oldCenter = new THREE.Vector3(frame.x, frame.elevation + frame.height / 2, frame.z);
127
+ const currentCenter = new THREE.Vector3(shape.x, (shape.elevation ?? 0) + shape.height / 2, shape.z);
128
+ const rotation = new THREE.Quaternion().setFromEuler(new THREE.Euler(THREE.MathUtils.degToRad(shape.rotationX ?? 0), THREE.MathUtils.degToRad(shape.rotation ?? 0), THREE.MathUtils.degToRad(shape.rotationZ ?? 0), "XYZ"));
129
+ const scale = new THREE.Vector3(shapeWidth(shape) / Math.max(0.001, frame.width) * mirrorSign(shape.mirrorX), shape.height / Math.max(0.001, frame.height) * mirrorSign(shape.mirrorY), shapeDepth(shape) / Math.max(0.001, frame.depth) * mirrorSign(shape.mirrorZ));
130
+ const matrix = new THREE.Matrix4()
131
+ .compose(currentCenter, rotation, scale)
132
+ .multiply(new THREE.Matrix4().makeTranslation(-oldCenter.x, -oldCenter.y, -oldCenter.z))
133
+ .multiply(cadTransformToMatrix(frame.sourceTransform));
134
+ const result = cadTransformFromMatrix(matrix);
135
+ return isIdentityCadTransform(result) ? undefined : result;
136
+ }
137
+ function bakeCadDisplayEdgesForShape(shape, frame) {
138
+ if (!shape.cadDisplayEdges?.length) {
139
+ return undefined;
140
+ }
141
+ const centerY = shape.height / 2;
142
+ const matrix = new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(THREE.MathUtils.degToRad(shape.rotationX ?? 0), THREE.MathUtils.degToRad(frame.yawDegrees), THREE.MathUtils.degToRad(shape.rotationZ ?? 0), "XYZ"));
143
+ const xMirror = mirrorSign(shape.mirrorX);
144
+ const yMirror = mirrorSign(shape.mirrorY);
145
+ const zMirror = mirrorSign(shape.mirrorZ);
146
+ const bakedEdges = shape.cadDisplayEdges.flatMap((edge) => {
147
+ if (edge.points.length < 6) {
148
+ return [];
149
+ }
150
+ const resizedPoints = resizedImportedCoordinates(shape, edge.points);
151
+ const points = [];
152
+ for (let index = 0; index + 2 < resizedPoints.length; index += 3) {
153
+ const vertex = new THREE.Vector3(resizedPoints[index] * xMirror, (resizedPoints[index + 1] - centerY) * yMirror, resizedPoints[index + 2] * zMirror).applyMatrix4(matrix);
154
+ const x = vertex.x + shape.x - frame.centerX;
155
+ const y = vertex.y + (shape.elevation ?? 0) + centerY - frame.minY;
156
+ const z = vertex.z + shape.z - frame.centerZ;
157
+ if ([x, y, z].every(Number.isFinite)) {
158
+ points.push(x, y, z);
159
+ }
160
+ }
161
+ return points.length >= 6 ? [{ points }] : [];
162
+ });
163
+ return bakedEdges.length > 0 ? bakedEdges : undefined;
164
+ }
165
+ function bakeCadPrimitiveFrameForShapeTransform(shape, frame) {
166
+ const primitive = cadModifierPrimitiveForBakedShape(shape) ?? cadModifierPrimitiveForAnalyticBox(shape);
167
+ if (!primitive) {
168
+ return undefined;
169
+ }
170
+ return {
171
+ kind: primitive.kind,
172
+ width: primitive.width,
173
+ depth: primitive.depth,
174
+ height: primitive.height,
175
+ frame: {
176
+ x: frame.centerX,
177
+ z: frame.centerZ,
178
+ elevation: frame.minY,
179
+ width: frame.width,
180
+ depth: frame.depth,
181
+ height: frame.height,
182
+ ...(primitive.transform ? { sourceTransform: primitive.transform } : {}),
183
+ },
184
+ };
185
+ }
186
+ export function bakeCadMetadataForShapeTransform(shape, frame) {
187
+ const cadDisplayEdges = bakeCadDisplayEdgesForShape(shape, frame);
188
+ const sourceTransform = cadBrepTransformForShape(shape);
189
+ const cadPrimitiveFrame = bakeCadPrimitiveFrameForShapeTransform(shape, frame);
190
+ const cadBrepFrame = shape.cadBrep && shape.cadBrepFrame
191
+ ? {
192
+ x: frame.centerX,
193
+ z: frame.centerZ,
194
+ elevation: frame.minY,
195
+ width: frame.width,
196
+ depth: frame.depth,
197
+ height: frame.height,
198
+ ...(sourceTransform ? { sourceTransform } : {}),
199
+ }
200
+ : undefined;
201
+ return {
202
+ cadDisplayEdges,
203
+ cadDisplayEdgesVersion: cadDisplayEdges ? 2 : undefined,
204
+ cadBrep: cadBrepFrame ? shape.cadBrep : undefined,
205
+ cadBrepFrame,
206
+ cadPrimitiveFrame,
207
+ };
208
+ }
209
+ //# sourceMappingURL=cadBakeMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cadBakeMetadata.js","sourceRoot":"","sources":["../src/cadBakeMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,0BAA0B,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAYtG,MAAM,UAAU,oBAAoB,CAAC,SAA+B;IAClE,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/E,O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