@things-factory/figure-ui 10.1.128 → 10.1.141
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/client/modeller/align.ts +24 -18
- package/client/modeller/editor.ts +165 -253
- package/client/modeller/fasten-geometry.ts +12 -9
- package/client/modeller/figure-facts.ts +12 -14
- package/client/modeller/figure-links.ts +16 -12
- package/client/modeller/figure-preview.ts +13 -4
- package/client/modeller/figure-properties.ts +6 -5
- package/client/modeller/figure-verdict.ts +14 -8
- package/client/modeller/joint-fan.ts +15 -17
- package/client/modeller/links.ts +17 -23
- package/client/modeller/live.ts +6 -3
- package/client/modeller/motion-ends.ts +6 -7
- package/client/modeller/occupancy.ts +2 -3
- package/client/modeller/product-session.ts +15 -0
- package/client/modeller/revision.ts +66 -0
- package/client/pages/figure-modeller-page.ts +5 -18
- package/dist-client/modeller/align.d.ts +12 -7
- package/dist-client/modeller/align.js +21 -17
- package/dist-client/modeller/align.js.map +1 -1
- package/dist-client/modeller/editor.d.ts +8 -34
- package/dist-client/modeller/editor.js +175 -250
- package/dist-client/modeller/editor.js.map +1 -1
- package/dist-client/modeller/fasten-geometry.d.ts +3 -2
- package/dist-client/modeller/fasten-geometry.js +11 -9
- package/dist-client/modeller/fasten-geometry.js.map +1 -1
- package/dist-client/modeller/figure-facts.d.ts +9 -1
- package/dist-client/modeller/figure-facts.js +11 -15
- package/dist-client/modeller/figure-facts.js.map +1 -1
- package/dist-client/modeller/figure-links.d.ts +4 -5
- package/dist-client/modeller/figure-links.js +14 -13
- package/dist-client/modeller/figure-links.js.map +1 -1
- package/dist-client/modeller/figure-preview.d.ts +5 -2
- package/dist-client/modeller/figure-preview.js +13 -4
- package/dist-client/modeller/figure-preview.js.map +1 -1
- package/dist-client/modeller/figure-properties.d.ts +3 -2
- package/dist-client/modeller/figure-properties.js +6 -6
- package/dist-client/modeller/figure-properties.js.map +1 -1
- package/dist-client/modeller/figure-verdict.d.ts +4 -2
- package/dist-client/modeller/figure-verdict.js +12 -9
- package/dist-client/modeller/figure-verdict.js.map +1 -1
- package/dist-client/modeller/joint-fan.d.ts +8 -4
- package/dist-client/modeller/joint-fan.js +15 -16
- package/dist-client/modeller/joint-fan.js.map +1 -1
- package/dist-client/modeller/links.d.ts +6 -5
- package/dist-client/modeller/links.js +17 -24
- package/dist-client/modeller/links.js.map +1 -1
- package/dist-client/modeller/live.d.ts +3 -2
- package/dist-client/modeller/live.js +7 -3
- package/dist-client/modeller/live.js.map +1 -1
- package/dist-client/modeller/motion-ends.d.ts +2 -2
- package/dist-client/modeller/motion-ends.js +5 -6
- package/dist-client/modeller/motion-ends.js.map +1 -1
- package/dist-client/modeller/occupancy.d.ts +2 -2
- package/dist-client/modeller/occupancy.js +2 -3
- package/dist-client/modeller/occupancy.js.map +1 -1
- package/dist-client/modeller/product-session.d.ts +44 -39
- package/dist-client/modeller/product-session.js +17 -0
- package/dist-client/modeller/product-session.js.map +1 -1
- package/dist-client/modeller/revision.d.ts +37 -0
- package/dist-client/modeller/revision.js +39 -0
- package/dist-client/modeller/revision.js.map +1 -0
- package/dist-client/pages/figure-modeller-page.d.ts +0 -6
- package/dist-client/pages/figure-modeller-page.js +6 -14
- package/dist-client/pages/figure-modeller-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/test/align.test.ts +14 -12
- package/test/browser/modeller-page.js +52 -4
- package/test/browser/modeller-revision.check.mjs +144 -0
- package/test/command-preview.test.ts +9 -8
- package/test/fasten-drawing.test.ts +1 -1
- package/test/fasten-geometry.test.ts +10 -9
- package/test/fields.test.ts +1 -1
- package/test/first-minute.test.ts +1 -1
- package/test/gizmo.test.ts +1 -1
- package/test/joint-fan.test.ts +30 -14
- package/test/joint-frames.test.ts +9 -8
- package/test/links.test.ts +13 -12
- package/test/live.test.ts +3 -3
- package/test/parts-wiring.test.ts +1 -1
- package/test/properties.test.ts +6 -5
- package/test/release-panel.test.ts +3 -3
- package/test/resize-with-placement.test.ts +8 -6
- package/test/revision-of.ts +22 -0
- package/test/revision.test.ts +172 -0
- package/test/section-editor.test.ts +4 -3
- package/test/section-panel.test.ts +5 -4
- package/test/verdict.test.ts +1 -1
- package/client/modeller/evaluated.ts +0 -47
- package/dist-client/modeller/evaluated.d.ts +0 -12
- package/dist-client/modeller/evaluated.js +0 -42
- package/dist-client/modeller/evaluated.js.map +0 -1
- package/dist-client/tsconfig.scratch.tsbuildinfo +0 -1
- package/test/evaluated.test.ts +0 -40
- package/test/mode-switch.test.ts +0 -43
package/client/modeller/align.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { figureOccupiedBoxesOf, figureWritersOf } from '@hatiolab/figure-model'
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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(
|
|
31
|
-
const
|
|
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(
|
|
50
|
+
export function alignChanges(revision: FigureRevision, part: string, reach: GizmoReach, tool: AlignTool): FigureInputChange[] {
|
|
45
51
|
if (!reach.translate) return []
|
|
46
|
-
const box = boxOf(
|
|
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(
|
|
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(
|
|
73
|
-
const box = boxOf(
|
|
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(
|
|
81
|
-
const box = reach.translate ? boxOf(
|
|
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
|
|