@things-factory/figure-ui 10.1.129 → 10.1.142

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 (95) hide show
  1. package/client/modeller/align.ts +24 -18
  2. package/client/modeller/editor.ts +165 -253
  3. package/client/modeller/fasten-geometry.ts +12 -9
  4. package/client/modeller/figure-facts.ts +12 -14
  5. package/client/modeller/figure-links.ts +16 -12
  6. package/client/modeller/figure-preview.ts +13 -4
  7. package/client/modeller/figure-properties.ts +6 -5
  8. package/client/modeller/figure-verdict.ts +14 -8
  9. package/client/modeller/joint-fan.ts +15 -17
  10. package/client/modeller/links.ts +17 -23
  11. package/client/modeller/live.ts +6 -3
  12. package/client/modeller/motion-ends.ts +6 -7
  13. package/client/modeller/occupancy.ts +2 -3
  14. package/client/modeller/product-session.ts +15 -0
  15. package/client/modeller/revision.ts +66 -0
  16. package/client/pages/figure-modeller-page.ts +5 -18
  17. package/dist-client/modeller/align.d.ts +12 -7
  18. package/dist-client/modeller/align.js +21 -17
  19. package/dist-client/modeller/align.js.map +1 -1
  20. package/dist-client/modeller/editor.d.ts +8 -34
  21. package/dist-client/modeller/editor.js +175 -250
  22. package/dist-client/modeller/editor.js.map +1 -1
  23. package/dist-client/modeller/fasten-geometry.d.ts +3 -2
  24. package/dist-client/modeller/fasten-geometry.js +11 -9
  25. package/dist-client/modeller/fasten-geometry.js.map +1 -1
  26. package/dist-client/modeller/figure-facts.d.ts +9 -1
  27. package/dist-client/modeller/figure-facts.js +11 -15
  28. package/dist-client/modeller/figure-facts.js.map +1 -1
  29. package/dist-client/modeller/figure-links.d.ts +4 -5
  30. package/dist-client/modeller/figure-links.js +14 -13
  31. package/dist-client/modeller/figure-links.js.map +1 -1
  32. package/dist-client/modeller/figure-preview.d.ts +5 -2
  33. package/dist-client/modeller/figure-preview.js +13 -4
  34. package/dist-client/modeller/figure-preview.js.map +1 -1
  35. package/dist-client/modeller/figure-properties.d.ts +3 -2
  36. package/dist-client/modeller/figure-properties.js +6 -6
  37. package/dist-client/modeller/figure-properties.js.map +1 -1
  38. package/dist-client/modeller/figure-verdict.d.ts +4 -2
  39. package/dist-client/modeller/figure-verdict.js +12 -9
  40. package/dist-client/modeller/figure-verdict.js.map +1 -1
  41. package/dist-client/modeller/joint-fan.d.ts +8 -4
  42. package/dist-client/modeller/joint-fan.js +15 -16
  43. package/dist-client/modeller/joint-fan.js.map +1 -1
  44. package/dist-client/modeller/links.d.ts +6 -5
  45. package/dist-client/modeller/links.js +17 -24
  46. package/dist-client/modeller/links.js.map +1 -1
  47. package/dist-client/modeller/live.d.ts +3 -2
  48. package/dist-client/modeller/live.js +7 -3
  49. package/dist-client/modeller/live.js.map +1 -1
  50. package/dist-client/modeller/motion-ends.d.ts +2 -2
  51. package/dist-client/modeller/motion-ends.js +5 -6
  52. package/dist-client/modeller/motion-ends.js.map +1 -1
  53. package/dist-client/modeller/occupancy.d.ts +2 -2
  54. package/dist-client/modeller/occupancy.js +2 -3
  55. package/dist-client/modeller/occupancy.js.map +1 -1
  56. package/dist-client/modeller/product-session.d.ts +44 -39
  57. package/dist-client/modeller/product-session.js +17 -0
  58. package/dist-client/modeller/product-session.js.map +1 -1
  59. package/dist-client/modeller/revision.d.ts +37 -0
  60. package/dist-client/modeller/revision.js +39 -0
  61. package/dist-client/modeller/revision.js.map +1 -0
  62. package/dist-client/pages/figure-modeller-page.d.ts +0 -6
  63. package/dist-client/pages/figure-modeller-page.js +6 -14
  64. package/dist-client/pages/figure-modeller-page.js.map +1 -1
  65. package/dist-client/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +7 -7
  67. package/test/align.test.ts +14 -12
  68. package/test/browser/modeller-page.js +52 -4
  69. package/test/browser/modeller-revision.check.mjs +144 -0
  70. package/test/command-preview.test.ts +9 -8
  71. package/test/fasten-drawing.test.ts +1 -1
  72. package/test/fasten-geometry.test.ts +10 -9
  73. package/test/fields.test.ts +1 -1
  74. package/test/first-minute.test.ts +1 -1
  75. package/test/gizmo.test.ts +1 -1
  76. package/test/joint-fan.test.ts +30 -14
  77. package/test/joint-frames.test.ts +9 -8
  78. package/test/links.test.ts +13 -12
  79. package/test/live.test.ts +3 -3
  80. package/test/parts-wiring.test.ts +1 -1
  81. package/test/properties.test.ts +6 -5
  82. package/test/release-panel.test.ts +3 -3
  83. package/test/resize-with-placement.test.ts +8 -6
  84. package/test/revision-of.ts +22 -0
  85. package/test/revision.test.ts +172 -0
  86. package/test/section-editor.test.ts +4 -3
  87. package/test/section-panel.test.ts +5 -4
  88. package/test/verdict.test.ts +1 -1
  89. package/client/modeller/evaluated.ts +0 -47
  90. package/dist-client/modeller/evaluated.d.ts +0 -12
  91. package/dist-client/modeller/evaluated.js +0 -42
  92. package/dist-client/modeller/evaluated.js.map +0 -1
  93. package/dist-client/tsconfig.scratch.tsbuildinfo +0 -1
  94. package/test/evaluated.test.ts +0 -40
  95. package/test/mode-switch.test.ts +0 -43
@@ -1,6 +1,7 @@
1
1
  import { figureOccupiedBoxesOf, figureWritersOf } from '@hatiolab/figure-model'
2
- import { evaluatedGeometryOf } from './evaluated.js'
3
- import type { FigureAsset, FigureInputChange, FigureWorldBox } from '@hatiolab/figure-model'
2
+ import type { FigureInputChange, FigureWorldBox } from '@hatiolab/figure-model'
3
+
4
+ import { derivedOf, type FigureRevision } from './revision.js'
4
5
 
5
6
  import type { GizmoReach } from './gizmo.js'
6
7
 
@@ -20,16 +21,21 @@ export type AlignTool = 'centre-x' | 'centre-z' | 'snap'
20
21
 
21
22
  const AXES = ['x', 'y', 'z'] as const
22
23
 
23
- /** `values`: the inputs the figure is drawn with, when the box is read as drawn; left out, the asset as it is saved. */
24
- export function boxOf(asset: FigureAsset, part: string, values?: Record<string, number>): FigureWorldBox | undefined {
25
- const geometry = evaluatedGeometryOf(asset, values)
26
- return figureOccupiedBoxesOf(geometry, figureWritersOf(asset)).find(box => box.part === part)
24
+ /**
25
+ * Every part's box at this version, as drawn: the pose set with the controls included, as the canvas shows it and as a
26
+ * command sees it (a fastening keeps a part where it is drawn).
27
+ */
28
+ export function boxesOf(revision: FigureRevision): FigureWorldBox[] {
29
+ return derivedOf(revision, 'boxes', () => figureOccupiedBoxesOf(revision.geometry, figureWritersOf(revision.asset)))
30
+ }
31
+
32
+ export function boxOf(revision: FigureRevision, part: string): FigureWorldBox | undefined {
33
+ return boxesOf(revision).find(box => box.part === part)
27
34
  }
28
35
 
29
36
  /** The snapping grid: about five steps across the figure, on 1 · 2 · 5 multiples. */
30
- export function gridStepOf(asset: FigureAsset): number {
31
- const geometry = evaluatedGeometryOf(asset)
32
- const boxes = figureOccupiedBoxesOf(geometry, figureWritersOf(asset))
37
+ export function gridStepOf(revision: FigureRevision): number {
38
+ const boxes = boxesOf(revision)
33
39
  if (!boxes.length) return 1
34
40
  const span = Math.max(
35
41
  ...AXES.map(axis => {
@@ -41,11 +47,11 @@ export function gridStepOf(asset: FigureAsset): number {
41
47
  return niceStep(span)
42
48
  }
43
49
 
44
- export function alignChanges(asset: FigureAsset, part: string, reach: GizmoReach, tool: AlignTool): FigureInputChange[] {
50
+ export function alignChanges(revision: FigureRevision, part: string, reach: GizmoReach, tool: AlignTool): FigureInputChange[] {
45
51
  if (!reach.translate) return []
46
- const box = boxOf(asset, part)
52
+ const box = boxOf(revision, part)
47
53
  if (!box) return []
48
- const value = (id: string) => asset.designInputs[id] ?? 0
54
+ const value = (id: string) => revision.asset.designInputs[id] ?? 0
49
55
  const set = (input: string, next: number): FigureInputChange => ({ kind: 'set-design', input, unit: 'mm', value: Math.round(next) })
50
56
  const at = (axis: 'x' | 'y' | 'z') => `${part}.position.${axis}`
51
57
  switch (tool) {
@@ -54,7 +60,7 @@ export function alignChanges(asset: FigureAsset, part: string, reach: GizmoReach
54
60
  case 'centre-z':
55
61
  return [set(at('z'), value(at('z')) - box.centre.z)]
56
62
  case 'snap': {
57
- const step = gridStepOf(asset)
63
+ const step = gridStepOf(revision)
58
64
  const round = (n: number) => Math.round(n / step) * step
59
65
  const changes = AXES.map(axis => set(at(axis), round(value(at(axis)))))
60
66
  /* A size never snaps to 0 — the part would look gone. */
@@ -69,16 +75,16 @@ export function alignChanges(asset: FigureAsset, part: string, reach: GizmoReach
69
75
  * Where a mirrored copy goes: the same distance on the other side of the centre plane. The copy is made by
70
76
  * `duplicate-part` first; this is the position the copy is then given.
71
77
  */
72
- export function mirrorChanges(asset: FigureAsset, part: string, copy: string, axis: 'x' | 'z'): FigureInputChange[] {
73
- const box = boxOf(asset, part)
78
+ export function mirrorChanges(revision: FigureRevision, part: string, copy: string, axis: 'x' | 'z'): FigureInputChange[] {
79
+ const box = boxOf(revision, part)
74
80
  if (!box) return []
75
81
  const id = `${part}.position.${axis}`
76
- return [{ kind: 'set-design', input: `${copy}.position.${axis}`, unit: 'mm', value: Math.round((asset.designInputs[id] ?? 0) - 2 * box.centre[axis]) }]
82
+ return [{ kind: 'set-design', input: `${copy}.position.${axis}`, unit: 'mm', value: Math.round((revision.asset.designInputs[id] ?? 0) - 2 * box.centre[axis]) }]
77
83
  }
78
84
 
79
85
  /** Mirroring a part that already sits on the centre plane would put the copy inside it, so it is refused. */
80
- export function canMirror(asset: FigureAsset, part: string, axis: 'x' | 'z', reach: GizmoReach): boolean {
81
- const box = reach.translate ? boxOf(asset, part) : undefined
86
+ export function canMirror(revision: FigureRevision, part: string, axis: 'x' | 'z', reach: GizmoReach): boolean {
87
+ const box = reach.translate ? boxOf(revision, part) : undefined
82
88
  return !!box && Math.abs(box.centre[axis]) >= 0.5
83
89
  }
84
90