@things-factory/figure-ui 10.1.270 → 10.1.271

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 (53) hide show
  1. package/client/graphql/index.ts +2 -0
  2. package/client/modeller/data-interface.ts +14 -0
  3. package/client/modeller/editor-styles.ts +11 -0
  4. package/client/modeller/editor.ts +39 -11
  5. package/client/modeller/fasten-form.ts +6 -1
  6. package/client/modeller/fasten-geometry.ts +11 -1
  7. package/client/modeller/figure-fasten-drawing.ts +2 -3
  8. package/client/modeller/figure-preview.ts +9 -1
  9. package/client/modeller/palette.ts +27 -0
  10. package/client/modeller/product-session.ts +5 -1
  11. package/client/types.ts +2 -0
  12. package/dist-client/graphql/index.js +2 -0
  13. package/dist-client/graphql/index.js.map +1 -1
  14. package/dist-client/modeller/clips.d.ts +4 -4
  15. package/dist-client/modeller/data-interface.d.ts +5 -0
  16. package/dist-client/modeller/data-interface.js +15 -0
  17. package/dist-client/modeller/data-interface.js.map +1 -1
  18. package/dist-client/modeller/editor-styles.js +11 -0
  19. package/dist-client/modeller/editor-styles.js.map +1 -1
  20. package/dist-client/modeller/editor.d.ts +6 -0
  21. package/dist-client/modeller/editor.js +35 -11
  22. package/dist-client/modeller/editor.js.map +1 -1
  23. package/dist-client/modeller/fasten-form.js +6 -2
  24. package/dist-client/modeller/fasten-form.js.map +1 -1
  25. package/dist-client/modeller/fasten-geometry.d.ts +6 -0
  26. package/dist-client/modeller/fasten-geometry.js +10 -1
  27. package/dist-client/modeller/fasten-geometry.js.map +1 -1
  28. package/dist-client/modeller/figure-fasten-drawing.js +2 -3
  29. package/dist-client/modeller/figure-fasten-drawing.js.map +1 -1
  30. package/dist-client/modeller/figure-preview.js +9 -1
  31. package/dist-client/modeller/figure-preview.js.map +1 -1
  32. package/dist-client/modeller/links.d.ts +1 -1
  33. package/dist-client/modeller/palette.d.ts +14 -0
  34. package/dist-client/modeller/palette.js +23 -0
  35. package/dist-client/modeller/palette.js.map +1 -1
  36. package/dist-client/modeller/product-session.js +6 -2
  37. package/dist-client/modeller/product-session.js.map +1 -1
  38. package/dist-client/route.d.ts +1 -1
  39. package/dist-client/tsconfig.tsbuildinfo +1 -1
  40. package/dist-client/types.d.ts +2 -0
  41. package/dist-client/types.js.map +1 -1
  42. package/package.json +5 -5
  43. package/test/data-motion.test.ts +8 -0
  44. package/test/fasten-form.test.ts +13 -0
  45. package/test/fasten-geometry.test.ts +25 -1
  46. package/test/first-part-on-plane.test.ts +52 -0
  47. package/test/save-landed.test.ts +20 -1
  48. package/translations/en.json +1 -0
  49. package/translations/es.json +1 -0
  50. package/translations/ja.json +1 -0
  51. package/translations/ko.json +1 -0
  52. package/translations/ms.json +1 -0
  53. package/translations/zh.json +1 -0
@@ -1,6 +1,7 @@
1
1
  import { FIGURE_FACES, figureFastenKeptGapOf, figureFastenTargetAt, figurePlaneFacingOf, figureSurfaceKeptPlaceOf } from '@hatiolab/figure-model';
2
2
  import { faceViewOf, facesAsDrawnOf } from './fasten-geometry.js';
3
3
  import { alignOf, alignRowsOf, canFasten, facesOf, fasteningOf, fastenGapOf, hangsFrom, heldBy, mountingPlaneOf, placeKeptOf, surfaceOf } from './links.js';
4
+ import { standsWhereAdded } from './palette.js';
4
5
  import { ownerOf } from './fields.js';
5
6
  /*
6
7
  * A fastening as it is chosen, before it is done: to what, which face, how, where across the face. The fastening window
@@ -23,8 +24,11 @@ export const freshFasten = () => ({
23
24
  /** The part's own fastening as a form, or a fresh one: a window opens on what the part has (walk 1, 2026-09-26). */
24
25
  export function fastenFormOf(revision, part) {
25
26
  const own = fasteningOf(revision, part);
26
- if (!own || own.atOrigin)
27
- return freshFasten();
27
+ if (!own || own.atOrigin) {
28
+ /* A part still where it was added was put nowhere by the author: fastened, it goes on the face, no gap to keep. */
29
+ const pose = revision.geometry.find(g => g.id === part)?.pose;
30
+ return !own && standsWhereAdded(pose) ? { ...freshFasten(), gapFrom: 'pressed' } : freshFasten();
31
+ }
28
32
  /* A gap the record works out is the author's; a number is where the part stands, so aiming again keeps it there. */
29
33
  return { ...freshFasten(), ...own, gapFrom: own.gapKept !== undefined ? 'typed' : 'kept' };
30
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fasten-form.js","sourceRoot":"","sources":["../../client/modeller/fasten-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AAGjJ,OAAO,EAAE,UAAU,EAAE,cAAc,EAAqD,MAAM,sBAAsB,CAAA;AAEpH,OAAO,EACL,OAAO,EACP,WAAW,EACX,SAAS,EACT,OAAO,EACP,WAAW,EACX,WAAW,EACX,SAAS,EACT,MAAM,EACN,eAAe,EACf,WAAW,EACX,SAAS,EAGV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC;;;;GAIG;AAEH,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAiB,CAAA;AAwBvD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAe,EAAE,CAAC,CAAC;IAC5C,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,MAAM;IACd,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,EAAE;CACf,CAAC,CAAA;AAEF,oHAAoH;AACpH,MAAM,UAAU,YAAY,CAAC,QAAwB,EAAE,IAAY;IACjE,MAAM,GAAG,GAAG,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IACvC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ;QAAE,OAAO,WAAW,EAAE,CAAA;IAC9C,oHAAoH;IACpH,OAAO,EAAE,GAAG,WAAW,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AO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACvK,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5D,CAAC","sourcesContent":["import { FIGURE_FACES, figureFastenKeptGapOf, figureFastenTargetAt, figurePlaneFacingOf, figureSurfaceKeptPlaceOf } from '@hatiolab/figure-model'\nimport type { FigureAuthoringAction, FigureFace, FigureSurfacePlace } from '@hatiolab/figure-model'\n\nimport { faceViewOf, facesAsDrawnOf, type FaceView, type FastenMode, type FastenTarget } from './fasten-geometry.js'\nimport type { FastenChange } from './figure-fasten-drawing.js'\nimport {\n alignOf,\n alignRowsOf,\n canFasten,\n facesOf,\n fasteningOf,\n fastenGapOf,\n hangsFrom,\n heldBy,\n mountingPlaneOf,\n placeKeptOf,\n surfaceOf,\n type Alignment,\n type Axis\n} from './links.js'\nimport type { FigureRevision } from './revision.js'\nimport { ownerOf } from './fields.js'\n\n/*\n * A fastening as it is chosen, before it is done: to what, which face, how, where across the face. The fastening window\n * (`figure-fasten-dialog.ts`) holds one and changes it as the author chooses; the attach command is worked out from it\n * only here, so the window, its preview and the panel's 「정렬 고치기」 send the same command for the same choice.\n */\n\nconst FACES = Object.keys(FIGURE_FACES) as FigureFace[]\n\nexport interface FastenForm {\n toPlane: boolean\n target: string\n targetFace: FigureFace\n /** How it meets the face: its near end on it, its far end on it (flush), or its middle (ADR-0140 3.11). */\n facing: FastenMode\n gap: number\n /** The record's gap when it is worked out (a length that follows something): kept until a number is typed. */\n gapKept: unknown\n /**\n * Where the gap came from (ADR-0140 stage 4, 「현재 상태로 붙이기」): `kept` -- the distance the part stands at, worked\n * out again whenever where or how it is fastened changes, so fastening does not move it; `typed` -- the author's\n * number, left as it is; `pressed` -- 0, the part put where the canvas was pressed.\n */\n gapFrom: 'kept' | 'typed' | 'pressed'\n align: Partial<Record<Axis, Alignment>>\n alignMm: Partial<Record<Axis, number>>\n alignInput: Partial<Record<Axis, string>>\n /** On a point of the target's curved surface instead of a face (ADR-0140 3.9): where, as the record says it. */\n surface?: FigureSurfacePlace\n}\n\nexport const freshFasten = (): FastenForm => ({\n toPlane: false,\n target: '',\n targetFace: 'top',\n facing: 'meet',\n gap: 0,\n gapKept: undefined,\n gapFrom: 'kept',\n align: {},\n alignMm: {},\n alignInput: {}\n})\n\n/** The part's own fastening as a form, or a fresh one: a window opens on what the part has (walk 1, 2026-09-26). */\nexport function fastenFormOf(revision: FigureRevision, part: string): FastenForm {\n const own = fasteningOf(revision, part)\n if (!own || own.atOrigin) return freshFasten()\n /* A gap the record works out is the author's; a number is where the part stands, so aiming again keeps it there. */\n return { ...freshFasten(), ...own, gapFrom: own.gapKept !== undefined ? 'typed' : 'kept' } as FastenForm\n}\n\n/** What a part may be fastened to: every other part that can be, each said whether it would close a loop. */\nexport function fastenTargetsOf(revision: FigureRevision, part: string): Array<{ part: string; loops: boolean }> {\n const asset = revision.asset\n return (\n asset.appearance\n .map(look => look.target)\n .filter(one => one !== part && canFasten(asset, one))\n /* Not a part that hangs from this one: fastening a frame to its own roller would close a loop. */\n .map(one => ({ part: one, loops: hangsFrom(asset, one, part) }))\n )\n}\n\n/**\n * The point of a target's curved surface on the side the part stands on now (ADR-0140 3.9): the kernel's\n * (`figureSurfaceKeptPlaceOf`), or, the part standing on its axis, the surface's first point.\n */\nexport function surfaceKeptOf(revision: FigureRevision, part: string, target: string): FigureSurfacePlace | undefined {\n const surface = surfaceOf(revision.asset, target)\n if (!surface) return undefined\n return (\n figureSurfaceKeptPlaceOf(revision.asset, part, target, { ...revision.inputs }) ??\n (surface.form === 'around' ? { around: 0, along: 'centre' } : { toward: { x: 0, y: 1, z: 0 } })\n )\n}\n\n/**\n * A new aim: the plane, another part, another face of the same part, or a point of its curved surface. Where on the\n * face -- or the surface -- is filled in as where the part stands now, so fastening it keeps it there (`placeKeptOf`,\n * `surfaceKeptOf`); the author changes it from there. A part aimed at a sphere, or beside a cylinder's side within its\n * length, is aimed at the surface: it is fastened as it stands (ADR-0140 3.6).\n */\nexport function aimFasten(\n revision: FigureRevision,\n part: string,\n form: FastenForm,\n to: { plane: true } | { part: string } | { targetFace: FigureFace } | { surface: true }\n): FastenForm {\n if ('surface' in to) return { ...form, surface: surfaceKeptOf(revision, part, form.target), align: {}, alignMm: {}, alignInput: {} }\n if ('part' in to) {\n /* Beside its curved surface -- a sphere's anywhere, a cylinder's side within its length -- or with no face at all. */\n const beside = figureSurfaceKeptPlaceOf(revision.asset, part, to.part, { ...revision.inputs })\n const kept = beside ?? (!facesOf(revision.asset, to.part).length ? surfaceKeptOf(revision, part, to.part) : undefined)\n if (kept) return { ...form, toPlane: false, target: to.part, surface: kept, align: {}, alignMm: {}, alignInput: {} }\n }\n form = { ...form, surface: undefined }\n /* Aimed at the plane, it meets it toward the side the placement uses -- below a ceiling -- until the author says (ADR-0140 3.11). */\n const f: FastenForm =\n 'plane' in to\n ? { ...form, toPlane: true, target: '', facing: form.toPlane ? form.facing : (figurePlaneFacingOf(revision.asset) ?? form.facing) }\n : 'part' in to\n ? { ...form, toPlane: false, target: to.part }\n : { ...form, targetFace: to.targetFace }\n const theirFaces = f.target ? facesOf(revision.asset, f.target) : FACES\n const targetFace = (theirFaces.includes(f.targetFace) ? f.targetFace : theirFaces[0]) as FigureFace\n const aim: FastenTarget | undefined = f.toPlane\n ? 'plane'\n : f.target\n ? { part: f.target, face: targetFace }\n : undefined\n return { ...f, ...(aim ? placeKeptOf(revision, part, aim) : { align: {}, alignMm: {}, alignInput: {} }) }\n}\n\n/** A change the drawing asks: a face, a way, a gap or a place across the face. */\nexport function fastenChanged(\n revision: FigureRevision,\n part: string,\n form: FastenForm,\n change: FastenChange\n): FastenForm {\n const f = form\n if ('targetFace' in change) return keptGapOf(revision, part, aimFasten(revision, part, f, { targetFace: change.targetFace as FigureFace }))\n if ('onSurface' in change) return keptGapOf(revision, part, aimFasten(revision, part, f, { surface: true }))\n if ('surface' in change) return keptGapOf(revision, part, { ...f, surface: change.surface })\n if ('mode' in change) return keptGapOf(revision, part, { ...f, facing: change.mode })\n if ('gap' in change) return { ...f, gap: change.gap, gapKept: undefined, gapFrom: 'typed' }\n return {\n ...f,\n align: { ...f.align, [change.axis]: change.how },\n alignMm: change.how === 'mm' ? { ...f.alignMm, [change.axis]: change.mm ?? 0 } : f.alignMm\n }\n}\n\n/**\n * The form with the gap that keeps the part where it stands (ADR-0140 stage 4, user 2026-10-20 「현재 상태로 붙이기」):\n * figure-model's `figureFastenKeptGapOf` for what it is aimed at and how it meets it. A gap the author typed, or the 0 a\n * canvas press puts, is left as it is. Nothing aimed at yet, the form is as it was.\n */\nexport function keptGapOf(revision: FigureRevision, part: string, form: FastenForm): FastenForm {\n if (form.gapFrom !== 'kept') return form\n const asset = revision.asset\n const theirFaces = form.target ? facesOf(asset, form.target) : FACES\n const targetFace = (theirFaces.includes(form.targetFace) ? form.targetFace : theirFaces[0]) as FigureFace\n const planeWay = figurePlaneFacingOf(asset)\n const mode: FastenMode = form.toPlane ? (mountingPlaneOf(asset).facings.includes(form.facing) ? form.facing : (planeWay ?? 'meet')) : form.facing\n const to = form.toPlane\n ? ('plane' as const)\n : form.target && form.surface && surfaceOf(asset, form.target)\n ? { part: form.target, surface: form.surface }\n : form.target\n ? { part: form.target, face: targetFace }\n : undefined\n if (!to) return form\n return { ...form, gap: figureFastenKeptGapOf(asset, part, to, mode, { ...revision.inputs }), gapKept: undefined }\n}\n\n/** What a form comes to: the face aimed at, the way, the drawing of the face and the command. */\nexport interface FastenPlan {\n /** Nothing is aimed at until a part or the plane is chosen. */\n aim?: FastenTarget\n theirFaces: string[]\n targetFace: FigureFace\n mode: FastenMode\n view?: FaceView\n /** The axes across the face asked in rows: where the drawing cannot set the place. */\n alignRows: { axis: Axis; edges: boolean }[]\n action?: FigureAuthoringAction\n /** The face the command would meet, lit on the canvas while it is tried. */\n face?: { part: string; face: string }\n /** On a point of the target's curved surface: which surface, about which axis, and where (ADR-0140 3.9). */\n surface?: { form: 'around' | 'toward'; axis: Axis; place: FigureSurfacePlace }\n /** The target's own face at each of the drawing's places, as the target is drawn (\\`facesAsDrawnOf\\`). */\n drawnFaces?: Record<FigureFace, FigureFace>\n}\n\nexport function fastenPlanOf(revision: FigureRevision, part: string, f: FastenForm): FastenPlan {\n const plan = fastenPlanWithout(revision, part, f)\n return f.target && !f.toPlane ? { ...plan, drawnFaces: facesAsDrawnOf(revision, f.target) } : plan\n}\n\nfunction fastenPlanWithout(revision: FigureRevision, part: string, f: FastenForm): FastenPlan {\n const asset = revision.asset\n const theirFaces = f.target ? facesOf(asset, f.target) : FACES\n const targetFace = (theirFaces.includes(f.targetFace) ? f.targetFace : theirFaces[0]) as FigureFace\n const aim: FastenTarget | undefined = f.toPlane\n ? 'plane'\n : f.target\n ? { part: f.target, face: targetFace }\n : undefined\n /* The plane takes a part standing on it or hanging below it, a wall only one standing out of it (ADR-0140 3.11). */\n const planeWay = figurePlaneFacingOf(asset)\n const mode: FastenMode = f.toPlane ? (mountingPlaneOf(asset).facings.includes(f.facing) ? f.facing : (planeWay ?? 'meet')) : f.facing\n const surface = !f.toPlane && f.target && f.surface ? surfaceOf(asset, f.target) : undefined\n if (surface) {\n /* On the surface: where is the surface's own words, so no alignment goes with it (ADR-0140 3.9). */\n const action = {\n kind: 'attach',\n part,\n to: { part: f.target, surface: f.surface },\n facing: mode,\n ...fastenGapOf(f),\n replace: !!heldBy(asset, part)\n } as FigureAuthoringAction\n return { theirFaces, targetFace, mode, alignRows: [], action, surface: { ...surface, place: f.surface! } }\n }\n if (!aim) return { theirFaces, targetFace, mode, alignRows: [] }\n const align = alignOf(asset, aim, f.align, f.alignMm, f.alignInput)\n const view = faceViewOf(revision, part, aim, mode)\n const action = {\n kind: 'attach',\n part,\n to: f.toPlane ? { plane: 'mounting-plane' } : { part: f.target, face: targetFace },\n /* On the plane the kernel takes the placement's way when none is said: only another way is said. */\n ...(f.toPlane ? (mode === planeWay ? {} : { facing: mode }) : { facing: mode }),\n ...fastenGapOf(f),\n ...(align ? { align } : {}),\n replace: !!heldBy(asset, part)\n } as FigureAuthoringAction\n return {\n aim,\n theirFaces,\n targetFace,\n mode,\n view,\n alignRows: alignRowsOf(asset, aim, view, f.alignInput),\n action,\n ...(f.toPlane ? {} : { face: { part: f.target, face: targetFace } })\n }\n}\n\ntype Say = (key: string, params?: Record<string, string>) => string\n\n/** 「bin의 윗면에 올려놓기」: what the fastening is, in one line -- the part is the one the window is open on, not named again. */\nexport function fastenSentenceOf(\n form: FastenForm,\n plan: FastenPlan,\n planeWord: string,\n say: Say\n): string {\n const where = plan.surface ? say('figure.label.surface-' + plan.surface.form) : say('figure.label.face-' + plan.targetFace)\n const to = form.toPlane ? planeWord : `${form.target}의 ${where}`\n return say(`figure.text.fasten-sentence-${plan.mode}`, { to })\n}\n\n/**\n * What the folded details hold that is not their default, said while folded; nothing for the default. The gap's default\n * is the one it starts at -- the distance the part stands at, or 0 where the canvas was pressed -- so only a number typed\n * is said.\n */\nexport function fastenDetailWordsOf(form: FastenForm, say: Say): string[] {\n return [\n ...(form.gapKept !== undefined\n ? [say('figure.text.fasten-summary-gap-worked-out')]\n : form.gapFrom === 'typed' && form.gap\n ? [say('figure.text.fasten-summary-gap', { mm: String(form.gap) })]\n : [])\n ]\n}\n\n/**\n * A part pressed on the canvas while the window is open (ADR-0140 stage 4): aimed at, on the face or the point pressed,\n * its middle where it was pressed -- the kernel's reading of the press (`figureFastenTargetAt`), the point and normal brought into that part's own\n * frame by the pose its body is drawn at (`at.id`, a row's copy too). The part itself, one hanging from it, or one with\n * nothing to fasten to is not aimed at; a press on a curve there is no fastening to aims at the part alone. Each says\n * why, by its words' key.\n */\n/* Put where the canvas was pressed: on the face or the surface there, with no gap (ADR-0140 stage 4). */\nconst PRESSED = { gap: 0, gapKept: undefined, gapFrom: 'pressed' as const }\n\nexport function aimFastenAt(\n revision: FigureRevision,\n part: string,\n form: FastenForm,\n at: { id: string; point?: readonly number[]; normal?: readonly number[] }\n): { form?: FastenForm; note?: 'aim-self' | 'aim-cannot' | 'target-would-loop' | 'aim-not-here'; part: string } {\n const target = ownerOf(at.id)\n const offered = fastenTargetsOf(revision, part).find(t => t.part === target)\n if (target === part) return { note: 'aim-self', part: target }\n if (!offered) return { note: 'aim-cannot', part: target }\n if (offered.loops) return { note: 'target-would-loop', part: target }\n const aimed = aimFasten(revision, part, form, { part: target })\n const pose = (revision.geometry as Array<{ id: string; pose?: { r: number[][]; t: number[] } }>).find(g => g.id === at.id)?.pose\n if (!pose || !at.point || !at.normal) return { form: aimed, part: target }\n /* Into the part's own frame: rᵀ (p − t), and the normal by rᵀ. */\n const own = (v: readonly number[], from: readonly number[] = [0, 0, 0]) => [0, 1, 2].map(c => [0, 1, 2].reduce((sum, i) => sum + pose.r[i]![c]! * (v[i]! - from[i]!), 0))\n const lands = figureFastenTargetAt(revision.asset, target, own(at.point, pose.t), own(at.normal), { ...revision.inputs })\n if ('face' in lands) {\n /* On the face where it was pressed, as a point of a curved surface is: its middle there. */\n const onFace = aimFasten(revision, part, { ...aimed, surface: undefined }, { targetFace: lands.face as FigureFace })\n const at = lands.at as Partial<Record<Axis, number>>\n return { form: { ...onFace, ...PRESSED, align: Object.fromEntries(Object.keys(at).map(a => [a, 'mm'])) as FastenForm['align'], alignMm: { ...at }, alignInput: {} }, part: target }\n }\n if ('surface' in lands) return { form: { ...aimed, ...PRESSED, toPlane: false, target, surface: lands.surface, align: {}, alignMm: {}, alignInput: {} }, part: target }\n return { form: aimed, note: 'aim-not-here', part: target }\n}\n"]}
1
+ {"version":3,"file":"fasten-form.js","sourceRoot":"","sources":["../../client/modeller/fasten-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AAGjJ,OAAO,EAAE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,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACvK,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5D,CAAC","sourcesContent":["import { FIGURE_FACES, figureFastenKeptGapOf, figureFastenTargetAt, figurePlaneFacingOf, figureSurfaceKeptPlaceOf } from '@hatiolab/figure-model'\nimport type { FigureAuthoringAction, FigureFace, FigureSurfacePlace } from '@hatiolab/figure-model'\n\nimport { faceViewOf, facesAsDrawnOf, type FaceView, type FastenMode, type FastenTarget } from './fasten-geometry.js'\nimport type { FastenChange } from './figure-fasten-drawing.js'\nimport {\n alignOf,\n alignRowsOf,\n canFasten,\n facesOf,\n fasteningOf,\n fastenGapOf,\n hangsFrom,\n heldBy,\n mountingPlaneOf,\n placeKeptOf,\n surfaceOf,\n type Alignment,\n type Axis\n} from './links.js'\nimport type { FigureRevision } from './revision.js'\nimport { standsWhereAdded } from './palette.js'\nimport { ownerOf } from './fields.js'\n\n/*\n * A fastening as it is chosen, before it is done: to what, which face, how, where across the face. The fastening window\n * (`figure-fasten-dialog.ts`) holds one and changes it as the author chooses; the attach command is worked out from it\n * only here, so the window, its preview and the panel's 「정렬 고치기」 send the same command for the same choice.\n */\n\nconst FACES = Object.keys(FIGURE_FACES) as FigureFace[]\n\nexport interface FastenForm {\n toPlane: boolean\n target: string\n targetFace: FigureFace\n /** How it meets the face: its near end on it, its far end on it (flush), or its middle (ADR-0140 3.11). */\n facing: FastenMode\n gap: number\n /** The record's gap when it is worked out (a length that follows something): kept until a number is typed. */\n gapKept: unknown\n /**\n * Where the gap came from (ADR-0140 stage 4, 「현재 상태로 붙이기」): `kept` -- the distance the part stands at, worked\n * out again whenever where or how it is fastened changes, so fastening does not move it; `typed` -- the author's\n * number, left as it is; `pressed` -- 0, the part put where the canvas was pressed.\n */\n gapFrom: 'kept' | 'typed' | 'pressed'\n align: Partial<Record<Axis, Alignment>>\n alignMm: Partial<Record<Axis, number>>\n alignInput: Partial<Record<Axis, string>>\n /** On a point of the target's curved surface instead of a face (ADR-0140 3.9): where, as the record says it. */\n surface?: FigureSurfacePlace\n}\n\nexport const freshFasten = (): FastenForm => ({\n toPlane: false,\n target: '',\n targetFace: 'top',\n facing: 'meet',\n gap: 0,\n gapKept: undefined,\n gapFrom: 'kept',\n align: {},\n alignMm: {},\n alignInput: {}\n})\n\n/** The part's own fastening as a form, or a fresh one: a window opens on what the part has (walk 1, 2026-09-26). */\nexport function fastenFormOf(revision: FigureRevision, part: string): FastenForm {\n const own = fasteningOf(revision, part)\n if (!own || own.atOrigin) {\n /* A part still where it was added was put nowhere by the author: fastened, it goes on the face, no gap to keep. */\n const pose = (revision.geometry.find(g => (g as { id: string }).id === part) as { pose?: { r: number[][]; t: number[] } } | undefined)?.pose\n return !own && standsWhereAdded(pose) ? { ...freshFasten(), gapFrom: 'pressed' } : freshFasten()\n }\n /* A gap the record works out is the author's; a number is where the part stands, so aiming again keeps it there. */\n return { ...freshFasten(), ...own, gapFrom: own.gapKept !== undefined ? 'typed' : 'kept' } as FastenForm\n}\n\n/** What a part may be fastened to: every other part that can be, each said whether it would close a loop. */\nexport function fastenTargetsOf(revision: FigureRevision, part: string): Array<{ part: string; loops: boolean }> {\n const asset = revision.asset\n return (\n asset.appearance\n .map(look => look.target)\n .filter(one => one !== part && canFasten(asset, one))\n /* Not a part that hangs from this one: fastening a frame to its own roller would close a loop. */\n .map(one => ({ part: one, loops: hangsFrom(asset, one, part) }))\n )\n}\n\n/**\n * The point of a target's curved surface on the side the part stands on now (ADR-0140 3.9): the kernel's\n * (`figureSurfaceKeptPlaceOf`), or, the part standing on its axis, the surface's first point.\n */\nexport function surfaceKeptOf(revision: FigureRevision, part: string, target: string): FigureSurfacePlace | undefined {\n const surface = surfaceOf(revision.asset, target)\n if (!surface) return undefined\n return (\n figureSurfaceKeptPlaceOf(revision.asset, part, target, { ...revision.inputs }) ??\n (surface.form === 'around' ? { around: 0, along: 'centre' } : { toward: { x: 0, y: 1, z: 0 } })\n )\n}\n\n/**\n * A new aim: the plane, another part, another face of the same part, or a point of its curved surface. Where on the\n * face -- or the surface -- is filled in as where the part stands now, so fastening it keeps it there (`placeKeptOf`,\n * `surfaceKeptOf`); the author changes it from there. A part aimed at a sphere, or beside a cylinder's side within its\n * length, is aimed at the surface: it is fastened as it stands (ADR-0140 3.6).\n */\nexport function aimFasten(\n revision: FigureRevision,\n part: string,\n form: FastenForm,\n to: { plane: true } | { part: string } | { targetFace: FigureFace } | { surface: true }\n): FastenForm {\n if ('surface' in to) return { ...form, surface: surfaceKeptOf(revision, part, form.target), align: {}, alignMm: {}, alignInput: {} }\n if ('part' in to) {\n /* Beside its curved surface -- a sphere's anywhere, a cylinder's side within its length -- or with no face at all. */\n const beside = figureSurfaceKeptPlaceOf(revision.asset, part, to.part, { ...revision.inputs })\n const kept = beside ?? (!facesOf(revision.asset, to.part).length ? surfaceKeptOf(revision, part, to.part) : undefined)\n if (kept) return { ...form, toPlane: false, target: to.part, surface: kept, align: {}, alignMm: {}, alignInput: {} }\n }\n form = { ...form, surface: undefined }\n /* Aimed at the plane, it meets it toward the side the placement uses -- below a ceiling -- until the author says (ADR-0140 3.11). */\n const f: FastenForm =\n 'plane' in to\n ? { ...form, toPlane: true, target: '', facing: form.toPlane ? form.facing : (figurePlaneFacingOf(revision.asset) ?? form.facing) }\n : 'part' in to\n ? { ...form, toPlane: false, target: to.part }\n : { ...form, targetFace: to.targetFace }\n const theirFaces = f.target ? facesOf(revision.asset, f.target) : FACES\n const targetFace = (theirFaces.includes(f.targetFace) ? f.targetFace : theirFaces[0]) as FigureFace\n const aim: FastenTarget | undefined = f.toPlane\n ? 'plane'\n : f.target\n ? { part: f.target, face: targetFace }\n : undefined\n return { ...f, ...(aim ? placeKeptOf(revision, part, aim) : { align: {}, alignMm: {}, alignInput: {} }) }\n}\n\n/** A change the drawing asks: a face, a way, a gap or a place across the face. */\nexport function fastenChanged(\n revision: FigureRevision,\n part: string,\n form: FastenForm,\n change: FastenChange\n): FastenForm {\n const f = form\n if ('targetFace' in change) return keptGapOf(revision, part, aimFasten(revision, part, f, { targetFace: change.targetFace as FigureFace }))\n if ('onSurface' in change) return keptGapOf(revision, part, aimFasten(revision, part, f, { surface: true }))\n if ('surface' in change) return keptGapOf(revision, part, { ...f, surface: change.surface })\n if ('mode' in change) return keptGapOf(revision, part, { ...f, facing: change.mode })\n if ('gap' in change) return { ...f, gap: change.gap, gapKept: undefined, gapFrom: 'typed' }\n return {\n ...f,\n align: { ...f.align, [change.axis]: change.how },\n alignMm: change.how === 'mm' ? { ...f.alignMm, [change.axis]: change.mm ?? 0 } : f.alignMm\n }\n}\n\n/**\n * The form with the gap that keeps the part where it stands (ADR-0140 stage 4, user 2026-10-20 「현재 상태로 붙이기」):\n * figure-model's `figureFastenKeptGapOf` for what it is aimed at and how it meets it. A gap the author typed, or the 0 a\n * canvas press puts, is left as it is. Nothing aimed at yet, the form is as it was.\n */\nexport function keptGapOf(revision: FigureRevision, part: string, form: FastenForm): FastenForm {\n if (form.gapFrom !== 'kept') return form\n const asset = revision.asset\n const theirFaces = form.target ? facesOf(asset, form.target) : FACES\n const targetFace = (theirFaces.includes(form.targetFace) ? form.targetFace : theirFaces[0]) as FigureFace\n const planeWay = figurePlaneFacingOf(asset)\n const mode: FastenMode = form.toPlane ? (mountingPlaneOf(asset).facings.includes(form.facing) ? form.facing : (planeWay ?? 'meet')) : form.facing\n const to = form.toPlane\n ? ('plane' as const)\n : form.target && form.surface && surfaceOf(asset, form.target)\n ? { part: form.target, surface: form.surface }\n : form.target\n ? { part: form.target, face: targetFace }\n : undefined\n if (!to) return form\n return { ...form, gap: figureFastenKeptGapOf(asset, part, to, mode, { ...revision.inputs }), gapKept: undefined }\n}\n\n/** What a form comes to: the face aimed at, the way, the drawing of the face and the command. */\nexport interface FastenPlan {\n /** Nothing is aimed at until a part or the plane is chosen. */\n aim?: FastenTarget\n theirFaces: string[]\n targetFace: FigureFace\n mode: FastenMode\n view?: FaceView\n /** The axes across the face asked in rows: where the drawing cannot set the place. */\n alignRows: { axis: Axis; edges: boolean }[]\n action?: FigureAuthoringAction\n /** The face the command would meet, lit on the canvas while it is tried. */\n face?: { part: string; face: string }\n /** On a point of the target's curved surface: which surface, about which axis, and where (ADR-0140 3.9). */\n surface?: { form: 'around' | 'toward'; axis: Axis; place: FigureSurfacePlace }\n /** The target's own face at each of the drawing's places, as the target is drawn (\\`facesAsDrawnOf\\`). */\n drawnFaces?: Record<FigureFace, FigureFace>\n}\n\nexport function fastenPlanOf(revision: FigureRevision, part: string, f: FastenForm): FastenPlan {\n const plan = fastenPlanWithout(revision, part, f)\n return f.target && !f.toPlane ? { ...plan, drawnFaces: facesAsDrawnOf(revision, f.target) } : plan\n}\n\nfunction fastenPlanWithout(revision: FigureRevision, part: string, f: FastenForm): FastenPlan {\n const asset = revision.asset\n const theirFaces = f.target ? facesOf(asset, f.target) : FACES\n const targetFace = (theirFaces.includes(f.targetFace) ? f.targetFace : theirFaces[0]) as FigureFace\n const aim: FastenTarget | undefined = f.toPlane\n ? 'plane'\n : f.target\n ? { part: f.target, face: targetFace }\n : undefined\n /* The plane takes a part standing on it or hanging below it, a wall only one standing out of it (ADR-0140 3.11). */\n const planeWay = figurePlaneFacingOf(asset)\n const mode: FastenMode = f.toPlane ? (mountingPlaneOf(asset).facings.includes(f.facing) ? f.facing : (planeWay ?? 'meet')) : f.facing\n const surface = !f.toPlane && f.target && f.surface ? surfaceOf(asset, f.target) : undefined\n if (surface) {\n /* On the surface: where is the surface's own words, so no alignment goes with it (ADR-0140 3.9). */\n const action = {\n kind: 'attach',\n part,\n to: { part: f.target, surface: f.surface },\n facing: mode,\n ...fastenGapOf(f),\n replace: !!heldBy(asset, part)\n } as FigureAuthoringAction\n return { theirFaces, targetFace, mode, alignRows: [], action, surface: { ...surface, place: f.surface! } }\n }\n if (!aim) return { theirFaces, targetFace, mode, alignRows: [] }\n const align = alignOf(asset, aim, f.align, f.alignMm, f.alignInput)\n const view = faceViewOf(revision, part, aim, mode)\n const action = {\n kind: 'attach',\n part,\n to: f.toPlane ? { plane: 'mounting-plane' } : { part: f.target, face: targetFace },\n /* On the plane the kernel takes the placement's way when none is said: only another way is said. */\n ...(f.toPlane ? (mode === planeWay ? {} : { facing: mode }) : { facing: mode }),\n ...fastenGapOf(f),\n ...(align ? { align } : {}),\n replace: !!heldBy(asset, part)\n } as FigureAuthoringAction\n return {\n aim,\n theirFaces,\n targetFace,\n mode,\n view,\n alignRows: alignRowsOf(asset, aim, view, f.alignInput),\n action,\n ...(f.toPlane ? {} : { face: { part: f.target, face: targetFace } })\n }\n}\n\ntype Say = (key: string, params?: Record<string, string>) => string\n\n/** 「bin의 윗면에 올려놓기」: what the fastening is, in one line -- the part is the one the window is open on, not named again. */\nexport function fastenSentenceOf(\n form: FastenForm,\n plan: FastenPlan,\n planeWord: string,\n say: Say\n): string {\n const where = plan.surface ? say('figure.label.surface-' + plan.surface.form) : say('figure.label.face-' + plan.targetFace)\n const to = form.toPlane ? planeWord : `${form.target}의 ${where}`\n return say(`figure.text.fasten-sentence-${plan.mode}`, { to })\n}\n\n/**\n * What the folded details hold that is not their default, said while folded; nothing for the default. The gap's default\n * is the one it starts at -- the distance the part stands at, or 0 where the canvas was pressed -- so only a number typed\n * is said.\n */\nexport function fastenDetailWordsOf(form: FastenForm, say: Say): string[] {\n return [\n ...(form.gapKept !== undefined\n ? [say('figure.text.fasten-summary-gap-worked-out')]\n : form.gapFrom === 'typed' && form.gap\n ? [say('figure.text.fasten-summary-gap', { mm: String(form.gap) })]\n : [])\n ]\n}\n\n/**\n * A part pressed on the canvas while the window is open (ADR-0140 stage 4): aimed at, on the face or the point pressed,\n * its middle where it was pressed -- the kernel's reading of the press (`figureFastenTargetAt`), the point and normal brought into that part's own\n * frame by the pose its body is drawn at (`at.id`, a row's copy too). The part itself, one hanging from it, or one with\n * nothing to fasten to is not aimed at; a press on a curve there is no fastening to aims at the part alone. Each says\n * why, by its words' key.\n */\n/* Put where the canvas was pressed: on the face or the surface there, with no gap (ADR-0140 stage 4). */\nconst PRESSED = { gap: 0, gapKept: undefined, gapFrom: 'pressed' as const }\n\nexport function aimFastenAt(\n revision: FigureRevision,\n part: string,\n form: FastenForm,\n at: { id: string; point?: readonly number[]; normal?: readonly number[] }\n): { form?: FastenForm; note?: 'aim-self' | 'aim-cannot' | 'target-would-loop' | 'aim-not-here'; part: string } {\n const target = ownerOf(at.id)\n const offered = fastenTargetsOf(revision, part).find(t => t.part === target)\n if (target === part) return { note: 'aim-self', part: target }\n if (!offered) return { note: 'aim-cannot', part: target }\n if (offered.loops) return { note: 'target-would-loop', part: target }\n const aimed = aimFasten(revision, part, form, { part: target })\n const pose = (revision.geometry as Array<{ id: string; pose?: { r: number[][]; t: number[] } }>).find(g => g.id === at.id)?.pose\n if (!pose || !at.point || !at.normal) return { form: aimed, part: target }\n /* Into the part's own frame: rᵀ (p − t), and the normal by rᵀ. */\n const own = (v: readonly number[], from: readonly number[] = [0, 0, 0]) => [0, 1, 2].map(c => [0, 1, 2].reduce((sum, i) => sum + pose.r[i]![c]! * (v[i]! - from[i]!), 0))\n const lands = figureFastenTargetAt(revision.asset, target, own(at.point, pose.t), own(at.normal), { ...revision.inputs })\n if ('face' in lands) {\n /* On the face where it was pressed, as a point of a curved surface is: its middle there. */\n const onFace = aimFasten(revision, part, { ...aimed, surface: undefined }, { targetFace: lands.face as FigureFace })\n const at = lands.at as Partial<Record<Axis, number>>\n return { form: { ...onFace, ...PRESSED, align: Object.fromEntries(Object.keys(at).map(a => [a, 'mm'])) as FastenForm['align'], alignMm: { ...at }, alignInput: {} }, part: target }\n }\n if ('surface' in lands) return { form: { ...aimed, ...PRESSED, toPlane: false, target, surface: lands.surface, align: {}, alignMm: {}, alignInput: {} }, part: target }\n return { form: aimed, note: 'aim-not-here', part: target }\n}\n"]}
@@ -108,4 +108,10 @@ export declare function fastenLabelsOf(face: {
108
108
  inside: boolean;
109
109
  };
110
110
  };
111
+ /**
112
+ * How much of an axis the face drawing shows, mm: room around the face for the part to go past its edges by about half
113
+ * itself, and for a part bigger than the face lined up with one of its edges (a mast flush with a low body's bottom) to
114
+ * show whole; a plane with no size, three parts wide.
115
+ */
116
+ export declare function drawingSpanOf(face: number | undefined, part: number): number;
111
117
  export {};
@@ -71,7 +71,8 @@ export function alignmentAt(d, face, part, edges, catchMm) {
71
71
  [-inside, 'min'],
72
72
  [inside, 'max']
73
73
  ])
74
- if (Math.abs(d - at) <= catchMm && inside > 0)
74
+ /* Level with an edge whatever the sizes: a part bigger than the face (a mast on a low body) lines up with it too. */
75
+ if (Math.abs(d - at) <= catchMm && inside !== 0)
75
76
  return edges ? { how, caught: 'inside' } : { how: 'mm', mm: Math.round(at), caught: 'inside' };
76
77
  for (const at of [-outside, outside])
77
78
  if (Math.abs(d - at) <= catchMm)
@@ -147,4 +148,12 @@ export function fastenLabelsOf(face, part, partName, height) {
147
148
  return { face: facePlace, part: { x: part.x + part.w / 2, y: edge + 14, inside: false } };
148
149
  return { face: facePlace, part: { x: part.x + part.w / 2, y: below <= height - 20 ? below : part.y - 5, inside: false } };
149
150
  }
151
+ /**
152
+ * How much of an axis the face drawing shows, mm: room around the face for the part to go past its edges by about half
153
+ * itself, and for a part bigger than the face lined up with one of its edges (a mast flush with a low body's bottom) to
154
+ * show whole; a plane with no size, three parts wide.
155
+ */
156
+ export function drawingSpanOf(face, part) {
157
+ return face !== undefined ? Math.max(face + part, 2 * part - face) : part * 3;
158
+ }
150
159
  //# sourceMappingURL=fasten-geometry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fasten-geometry.js","sourceRoot":"","sources":["../../client/modeller/fasten-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,oBA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AAE,KAAK,EAAE,EAAE,CAAA;AAC3H,CAAC","sourcesContent":["import { FIGURE_FACES, figureFaceInsideAlignOf, figureFaceMeasureOf, figureFaceOverhangAt, figureFastenPlaceOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureFace, FigureFaceMeasure, FigureFacing, FigureFastenAlignment } from '@hatiolab/figure-model'\n\nimport { alignAxesOf, type Alignment } from './links.js'\nimport type { FigureRevision } from './revision.js'\n\n/*\n * What the 붙이기 drawing reads (user 2026-10-01): the face a part is fastened to, seen from above, and where the part\n * lies on it. A fastening is chosen by the target's face and how (올려놓기 · 같은 면에 맞추기 · 가운데를 면에); the part\n * meets it by its real shape in the pose it has, by no face of its own (ADR-0140 3.2). What is measured -- the face,\n * the part's extent across it, how far it comes past and whether what touches is on it -- is the kernel's\n * (`figureFaceMeasureOf`, 3.8); this only draws it.\n */\n\ntype Axis = 'x' | 'y' | 'z'\nexport type FastenMode = FigureFacing\nexport type FastenTarget = { part: string; face: string } | 'plane'\n\n/* Which way each of the six faces looks, along its axis, in a part's own frame. */\nconst OUTWARD: Record<FigureFace, number> = { left: -1, right: 1, bottom: -1, top: 1, back: -1, front: 1 }\nconst SIX = Object.keys(OUTWARD) as FigureFace[]\n\n/**\n * The target's own face that stands at each of the drawing's six places as the part is drawn (robot dog, 2026-11-03):\n * a face is named in its part's own frame, so a cylinder laid on its side has its 「아래」 on the side, and the box drawn\n * upright showed the name where the face is not. Each place -- up, down, right, left, toward the eye, away -- shows the\n * own face whose outward normal, turned by the part's pose, points most that way. Unturned, each is itself.\n */\nexport function facesAsDrawnOf(revision: FigureRevision, target: string): Record<FigureFace, FigureFace> {\n const drawn = (revision.geometry as Array<{ id: string; pose?: { r: number[][] } }>).find(g => g.id === target)?.pose?.r\n const same = Object.fromEntries(SIX.map(f => [f, f])) as Record<FigureFace, FigureFace>\n if (!drawn) return same\n const index = { x: 0, y: 1, z: 2 } as const\n /* World direction of an own face: its column of the pose, outward. */\n const world = (f: FigureFace) => [0, 1, 2].map(i => OUTWARD[f] * drawn[i]![index[FIGURE_FACES[f] as Axis]]!)\n const along = (place: FigureFace) => [0, 1, 2].map(i => (i === index[FIGURE_FACES[place] as Axis] ? OUTWARD[place] : 0))\n const dot = (a: number[], b: number[]) => a.reduce((sum, v, i) => sum + v * b[i]!, 0)\n return Object.fromEntries(SIX.map(place => [place, SIX.reduce((best, f) => (dot(world(f), along(place)) > dot(world(best), along(place)) ? f : best))])) as Record<FigureFace, FigureFace>\n}\n\n/**\n * The face seen from above: its two axes across (as the form's alignment names them), the face's size on each as a\n * fastening lines up to it -- none for a plane with no declared size -- the part's real extent on each, whether its\n * edges can be lined up with, and the kernel's measure the drawing asks again as the part is moved.\n */\nexport interface FaceView {\n axes: [Axis, Axis]\n face: Partial<Record<Axis, number>>\n part: Record<Axis, number>\n edges: Record<Axis, boolean>\n measure: FigureFaceMeasure\n}\n\nexport function faceViewOf(revision: FigureRevision, part: string, target: FastenTarget, facing: FastenMode): FaceView | undefined {\n const measure = (() => {\n try {\n return figureFaceMeasureOf(revision.asset, part, revision.inputs, { on: target, facing })\n } catch {\n return undefined\n }\n })()\n if (!measure) return undefined\n const across = alignAxesOf(revision.asset, target)\n const face: Partial<Record<Axis, number>> = {}\n for (const a of measure.axes) {\n const e = measure.edges[a]\n if (e) face[a] = e.hi - e.lo\n }\n const extent = (a: Axis) => measure.extent[a].hi - measure.extent[a].lo\n return {\n axes: measure.axes,\n face,\n part: { x: extent('x'), y: extent('y'), z: extent('z') },\n edges: Object.fromEntries(measure.axes.map(a => [a, !!across.find(o => o.axis === a)?.edges])) as Record<Axis, boolean>,\n measure\n }\n}\n\n/**\n * Where the part's centre is from the face's centre along one axis, for the way it is aligned there: the kernel's\n * `figureFastenPlaceOf` (ADR-0140 D2), the form's distances -- typed, or a share of the size read as millimetres -- as\n * a distance, a position field's as the centre.\n */\nexport function offsetOf(how: Alignment | undefined, mm: number | undefined, face: number | undefined, part: number): number {\n const align = how === 'mm' || how === 'share' ? { mm: mm ?? 0 } : how === 'min' || how === 'max' || how === 'centre' ? how : undefined\n return figureFastenPlaceOf({ align: { x: align }, face: { x: face }, part: { x: part } }).x!\n}\n\n/**\n * A place dropped on the face, as the form's alignment: caught at the centre, at an edge from inside (level with it:\n * `min` / `max`, where the edges can be lined up with), or at an edge from outside (touching it, as a distance), when\n * within `catchMm`; anywhere else a distance off centre, whole millimetres.\n */\nexport function alignmentAt(d: number, face: number | undefined, part: number, edges: boolean, catchMm: number): { how: Alignment; mm?: number; caught?: 'centre' | 'inside' | 'outside' } {\n if (Math.abs(d) <= catchMm) return { how: 'centre', caught: 'centre' }\n if (face !== undefined) {\n const inside = (face - part) / 2,\n outside = (face + part) / 2\n for (const [at, how] of [\n [-inside, 'min'],\n [inside, 'max']\n ] as const)\n if (Math.abs(d - at) <= catchMm && inside > 0) return edges ? { how, caught: 'inside' } : { how: 'mm', mm: Math.round(at), caught: 'inside' }\n for (const at of [-outside, outside]) if (Math.abs(d - at) <= catchMm) return { how: 'mm', mm: Math.round(at), caught: 'outside' }\n }\n return { how: 'mm', mm: Math.round(d) }\n}\n\n/** The form's alignment on each axis across the face, in the kernel's words: a typed or shared distance as millimetres. */\nfunction kernelAlignOf(view: FaceView, align: Partial<Record<Axis, Alignment>>, alignMm: Partial<Record<Axis, number>>): Partial<Record<Axis, FigureFastenAlignment>> {\n const out: Partial<Record<Axis, FigureFastenAlignment>> = {}\n for (const a of view.axes) {\n const how = align[a] ?? 'centre'\n out[a] = how === 'mm' || how === 'share' ? { mm: alignMm[a] ?? 0 } : how === 'min' || how === 'max' ? how : 'centre'\n }\n return out\n}\n\n/**\n * The alignment that brings the part inside the face, for 정렬·간격 고치기: the kernel's least move\n * (`figureFaceInsideAlignOf`), in the form's words. `inside` when nothing of it is past an edge: what is out is something\n * fastened on it. `unmeasured` when the face has no size to measure against.\n */\nexport function insideAlignmentOf(\n view: FaceView | undefined,\n align: Partial<Record<Axis, Alignment>>,\n alignMm: Partial<Record<Axis, number>>\n): { align: Partial<Record<Axis, Alignment>>; alignMm: Partial<Record<Axis, number>>; moved: Axis[] } | { cannot: 'inside' | 'unmeasured' } {\n if (!view) return { cannot: 'unmeasured' }\n const fix = figureFaceInsideAlignOf(view.measure, kernelAlignOf(view, align, alignMm), view.edges)\n if ('cannot' in fix) return fix\n const next = { align: { ...align }, alignMm: { ...alignMm }, moved: fix.moved as Axis[] }\n for (const a of fix.moved as Axis[]) {\n const how = fix.align[a]\n if (how && typeof how === 'object') ((next.align[a] = 'mm'), (next.alignMm[a] = how.mm))\n else if (how) next.align[a] = how\n }\n return next\n}\n\n/**\n * How far the part comes past the face's edges, per side, whether any of it lies over the face, and whether what\n * touches the face is on it -- with its middle `at` from the face's middle: the kernel's (`figureFaceOverhangAt`).\n */\nexport function overhangOf(view: FaceView, at: Record<Axis, number>): { touching: boolean; contact: 'on' | 'off' | 'unknown'; sides: Array<{ axis: Axis; side: 'low' | 'high'; mm: number }> } {\n const o = figureFaceOverhangAt(view.measure, Object.fromEntries(view.axes.map(a => [a, { mm: at[a] }])))\n return { touching: o.over, contact: o.contact, sides: o.sides as Array<{ axis: Axis; side: 'low' | 'high'; mm: number }> }\n}\n\n/** Whether the part turns about a joint: then 가운데를 면에 is offered -- a roller spinning in place. */\nexport const turnsInPlace = (asset: FigureAsset, part: string) =>\n (asset.joints ?? []).some(j => j.body1.part === part && ((j.motion ?? []).some(a => a.type === 'revolute') || j.origin?.facing === 'centre'))\n\n/**\n * How the face lies on the screen: X across when it is one of the face's axes, else Z; the other down the screen -- up\n * for Y, which rises, so a front face is seen as it stands and not upside down.\n */\nexport function screenOf(axes: readonly [Axis, Axis]): { h: Axis; v: Axis; sign: Record<Axis, 1 | -1> } {\n const h = axes.includes('x') ? 'x' : 'z'\n const v = axes.find(a => a !== h)!\n return { h, v, sign: { x: 1, y: 1, z: 1, [v]: v === 'y' ? -1 : 1 } as Record<Axis, 1 | -1> }\n}\n\n/**\n * Where the fastening drawing writes its two names so neither lies over the other (user 2026-10-16: 「roller」 over the\n * roller's thin bar, and 「frame 윗면 2000 × 600」 cut by it). The face's name stands above the face, inside its top edge\n * only when the face fills the drawing. The part's name stands in the part when the part is wide and tall enough for it,\n * else just under it -- above it when the drawing ends first. Under a part as tall as the face, just under it is the\n * face's own edge, and the name lay on that line (2026-10-18, the roller in the fastening window): it goes under the edge.\n * Widths are estimated: 7 px a letter at 11-12 px; a line of it stands 11 px over its baseline and 3 under.\n */\nexport function fastenLabelsOf(\n face: { x: number; y: number; w: number; h: number },\n part: { x: number; y: number; w: number; h: number },\n partName: string,\n height: number\n): { face: { x: number; y: number }; part: { x: number; y: number; inside: boolean } } {\n const facePlace = face.y >= 16 ? { x: face.x, y: face.y - 5 } : { x: face.x + 4, y: face.y + 14 }\n const fits = part.w >= partName.length * 7 + 8 && part.h >= 16\n if (fits) return { face: facePlace, part: { x: part.x + part.w / 2, y: part.y + part.h / 2 + 4, inside: true } }\n const below = part.y + part.h + 14\n const edge = face.y + face.h\n if (below - 11 < edge + 2 && below + 3 > edge - 2 && edge + 14 <= height - 4) return { face: facePlace, part: { x: part.x + part.w / 2, y: edge + 14, inside: false } }\n return { face: facePlace, part: { x: part.x + part.w / 2, y: below <= height - 20 ? below : part.y - 5, inside: false } }\n}\n"]}
1
+ {"version":3,"file":"fasten-geometry.js","sourceRoot":"","sources":["../../client/modeller/fasten-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAG9I,OAAO,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAA;AAexD,mFAAmF;AACnF,MAAM,OAAO,GAA+B,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;AAC1G,M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FIGURE_FACES, figureFaceInsideAlignOf, figureFaceMeasureOf, figureFaceOverhangAt, figureFastenPlaceOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureFace, FigureFaceMeasure, FigureFacing, FigureFastenAlignment } from '@hatiolab/figure-model'\n\nimport { alignAxesOf, type Alignment } from './links.js'\nimport type { FigureRevision } from './revision.js'\n\n/*\n * What the 붙이기 drawing reads (user 2026-10-01): the face a part is fastened to, seen from above, and where the part\n * lies on it. A fastening is chosen by the target's face and how (올려놓기 · 같은 면에 맞추기 · 가운데를 면에); the part\n * meets it by its real shape in the pose it has, by no face of its own (ADR-0140 3.2). What is measured -- the face,\n * the part's extent across it, how far it comes past and whether what touches is on it -- is the kernel's\n * (`figureFaceMeasureOf`, 3.8); this only draws it.\n */\n\ntype Axis = 'x' | 'y' | 'z'\nexport type FastenMode = FigureFacing\nexport type FastenTarget = { part: string; face: string } | 'plane'\n\n/* Which way each of the six faces looks, along its axis, in a part's own frame. */\nconst OUTWARD: Record<FigureFace, number> = { left: -1, right: 1, bottom: -1, top: 1, back: -1, front: 1 }\nconst SIX = Object.keys(OUTWARD) as FigureFace[]\n\n/**\n * The target's own face that stands at each of the drawing's six places as the part is drawn (robot dog, 2026-11-03):\n * a face is named in its part's own frame, so a cylinder laid on its side has its 「아래」 on the side, and the box drawn\n * upright showed the name where the face is not. Each place -- up, down, right, left, toward the eye, away -- shows the\n * own face whose outward normal, turned by the part's pose, points most that way. Unturned, each is itself.\n */\nexport function facesAsDrawnOf(revision: FigureRevision, target: string): Record<FigureFace, FigureFace> {\n const drawn = (revision.geometry as Array<{ id: string; pose?: { r: number[][] } }>).find(g => g.id === target)?.pose?.r\n const same = Object.fromEntries(SIX.map(f => [f, f])) as Record<FigureFace, FigureFace>\n if (!drawn) return same\n const index = { x: 0, y: 1, z: 2 } as const\n /* World direction of an own face: its column of the pose, outward. */\n const world = (f: FigureFace) => [0, 1, 2].map(i => OUTWARD[f] * drawn[i]![index[FIGURE_FACES[f] as Axis]]!)\n const along = (place: FigureFace) => [0, 1, 2].map(i => (i === index[FIGURE_FACES[place] as Axis] ? OUTWARD[place] : 0))\n const dot = (a: number[], b: number[]) => a.reduce((sum, v, i) => sum + v * b[i]!, 0)\n return Object.fromEntries(SIX.map(place => [place, SIX.reduce((best, f) => (dot(world(f), along(place)) > dot(world(best), along(place)) ? f : best))])) as Record<FigureFace, FigureFace>\n}\n\n/**\n * The face seen from above: its two axes across (as the form's alignment names them), the face's size on each as a\n * fastening lines up to it -- none for a plane with no declared size -- the part's real extent on each, whether its\n * edges can be lined up with, and the kernel's measure the drawing asks again as the part is moved.\n */\nexport interface FaceView {\n axes: [Axis, Axis]\n face: Partial<Record<Axis, number>>\n part: Record<Axis, number>\n edges: Record<Axis, boolean>\n measure: FigureFaceMeasure\n}\n\nexport function faceViewOf(revision: FigureRevision, part: string, target: FastenTarget, facing: FastenMode): FaceView | undefined {\n const measure = (() => {\n try {\n return figureFaceMeasureOf(revision.asset, part, revision.inputs, { on: target, facing })\n } catch {\n return undefined\n }\n })()\n if (!measure) return undefined\n const across = alignAxesOf(revision.asset, target)\n const face: Partial<Record<Axis, number>> = {}\n for (const a of measure.axes) {\n const e = measure.edges[a]\n if (e) face[a] = e.hi - e.lo\n }\n const extent = (a: Axis) => measure.extent[a].hi - measure.extent[a].lo\n return {\n axes: measure.axes,\n face,\n part: { x: extent('x'), y: extent('y'), z: extent('z') },\n edges: Object.fromEntries(measure.axes.map(a => [a, !!across.find(o => o.axis === a)?.edges])) as Record<Axis, boolean>,\n measure\n }\n}\n\n/**\n * Where the part's centre is from the face's centre along one axis, for the way it is aligned there: the kernel's\n * `figureFastenPlaceOf` (ADR-0140 D2), the form's distances -- typed, or a share of the size read as millimetres -- as\n * a distance, a position field's as the centre.\n */\nexport function offsetOf(how: Alignment | undefined, mm: number | undefined, face: number | undefined, part: number): number {\n const align = how === 'mm' || how === 'share' ? { mm: mm ?? 0 } : how === 'min' || how === 'max' || how === 'centre' ? how : undefined\n return figureFastenPlaceOf({ align: { x: align }, face: { x: face }, part: { x: part } }).x!\n}\n\n/**\n * A place dropped on the face, as the form's alignment: caught at the centre, at an edge from inside (level with it:\n * `min` / `max`, where the edges can be lined up with), or at an edge from outside (touching it, as a distance), when\n * within `catchMm`; anywhere else a distance off centre, whole millimetres.\n */\nexport function alignmentAt(d: number, face: number | undefined, part: number, edges: boolean, catchMm: number): { how: Alignment; mm?: number; caught?: 'centre' | 'inside' | 'outside' } {\n if (Math.abs(d) <= catchMm) return { how: 'centre', caught: 'centre' }\n if (face !== undefined) {\n const inside = (face - part) / 2,\n outside = (face + part) / 2\n for (const [at, how] of [\n [-inside, 'min'],\n [inside, 'max']\n ] as const)\n /* Level with an edge whatever the sizes: a part bigger than the face (a mast on a low body) lines up with it too. */\n if (Math.abs(d - at) <= catchMm && inside !== 0) return edges ? { how, caught: 'inside' } : { how: 'mm', mm: Math.round(at), caught: 'inside' }\n for (const at of [-outside, outside]) if (Math.abs(d - at) <= catchMm) return { how: 'mm', mm: Math.round(at), caught: 'outside' }\n }\n return { how: 'mm', mm: Math.round(d) }\n}\n\n/** The form's alignment on each axis across the face, in the kernel's words: a typed or shared distance as millimetres. */\nfunction kernelAlignOf(view: FaceView, align: Partial<Record<Axis, Alignment>>, alignMm: Partial<Record<Axis, number>>): Partial<Record<Axis, FigureFastenAlignment>> {\n const out: Partial<Record<Axis, FigureFastenAlignment>> = {}\n for (const a of view.axes) {\n const how = align[a] ?? 'centre'\n out[a] = how === 'mm' || how === 'share' ? { mm: alignMm[a] ?? 0 } : how === 'min' || how === 'max' ? how : 'centre'\n }\n return out\n}\n\n/**\n * The alignment that brings the part inside the face, for 정렬·간격 고치기: the kernel's least move\n * (`figureFaceInsideAlignOf`), in the form's words. `inside` when nothing of it is past an edge: what is out is something\n * fastened on it. `unmeasured` when the face has no size to measure against.\n */\nexport function insideAlignmentOf(\n view: FaceView | undefined,\n align: Partial<Record<Axis, Alignment>>,\n alignMm: Partial<Record<Axis, number>>\n): { align: Partial<Record<Axis, Alignment>>; alignMm: Partial<Record<Axis, number>>; moved: Axis[] } | { cannot: 'inside' | 'unmeasured' } {\n if (!view) return { cannot: 'unmeasured' }\n const fix = figureFaceInsideAlignOf(view.measure, kernelAlignOf(view, align, alignMm), view.edges)\n if ('cannot' in fix) return fix\n const next = { align: { ...align }, alignMm: { ...alignMm }, moved: fix.moved as Axis[] }\n for (const a of fix.moved as Axis[]) {\n const how = fix.align[a]\n if (how && typeof how === 'object') ((next.align[a] = 'mm'), (next.alignMm[a] = how.mm))\n else if (how) next.align[a] = how\n }\n return next\n}\n\n/**\n * How far the part comes past the face's edges, per side, whether any of it lies over the face, and whether what\n * touches the face is on it -- with its middle `at` from the face's middle: the kernel's (`figureFaceOverhangAt`).\n */\nexport function overhangOf(view: FaceView, at: Record<Axis, number>): { touching: boolean; contact: 'on' | 'off' | 'unknown'; sides: Array<{ axis: Axis; side: 'low' | 'high'; mm: number }> } {\n const o = figureFaceOverhangAt(view.measure, Object.fromEntries(view.axes.map(a => [a, { mm: at[a] }])))\n return { touching: o.over, contact: o.contact, sides: o.sides as Array<{ axis: Axis; side: 'low' | 'high'; mm: number }> }\n}\n\n/** Whether the part turns about a joint: then 가운데를 면에 is offered -- a roller spinning in place. */\nexport const turnsInPlace = (asset: FigureAsset, part: string) =>\n (asset.joints ?? []).some(j => j.body1.part === part && ((j.motion ?? []).some(a => a.type === 'revolute') || j.origin?.facing === 'centre'))\n\n/**\n * How the face lies on the screen: X across when it is one of the face's axes, else Z; the other down the screen -- up\n * for Y, which rises, so a front face is seen as it stands and not upside down.\n */\nexport function screenOf(axes: readonly [Axis, Axis]): { h: Axis; v: Axis; sign: Record<Axis, 1 | -1> } {\n const h = axes.includes('x') ? 'x' : 'z'\n const v = axes.find(a => a !== h)!\n return { h, v, sign: { x: 1, y: 1, z: 1, [v]: v === 'y' ? -1 : 1 } as Record<Axis, 1 | -1> }\n}\n\n/**\n * Where the fastening drawing writes its two names so neither lies over the other (user 2026-10-16: 「roller」 over the\n * roller's thin bar, and 「frame 윗면 2000 × 600」 cut by it). The face's name stands above the face, inside its top edge\n * only when the face fills the drawing. The part's name stands in the part when the part is wide and tall enough for it,\n * else just under it -- above it when the drawing ends first. Under a part as tall as the face, just under it is the\n * face's own edge, and the name lay on that line (2026-10-18, the roller in the fastening window): it goes under the edge.\n * Widths are estimated: 7 px a letter at 11-12 px; a line of it stands 11 px over its baseline and 3 under.\n */\nexport function fastenLabelsOf(\n face: { x: number; y: number; w: number; h: number },\n part: { x: number; y: number; w: number; h: number },\n partName: string,\n height: number\n): { face: { x: number; y: number }; part: { x: number; y: number; inside: boolean } } {\n const facePlace = face.y >= 16 ? { x: face.x, y: face.y - 5 } : { x: face.x + 4, y: face.y + 14 }\n const fits = part.w >= partName.length * 7 + 8 && part.h >= 16\n if (fits) return { face: facePlace, part: { x: part.x + part.w / 2, y: part.y + part.h / 2 + 4, inside: true } }\n const below = part.y + part.h + 14\n const edge = face.y + face.h\n if (below - 11 < edge + 2 && below + 3 > edge - 2 && edge + 14 <= height - 4) return { face: facePlace, part: { x: part.x + part.w / 2, y: edge + 14, inside: false } }\n return { face: facePlace, part: { x: part.x + part.w / 2, y: below <= height - 20 ? below : part.y - 5, inside: false } }\n}\n\n/**\n * How much of an axis the face drawing shows, mm: room around the face for the part to go past its edges by about half\n * itself, and for a part bigger than the face lined up with one of its edges (a mast flush with a low body's bottom) to\n * show whole; a plane with no size, three parts wide.\n */\nexport function drawingSpanOf(face: number | undefined, part: number): number {\n return face !== undefined ? Math.max(face + part, 2 * part - face) : part * 3\n}\n"]}
@@ -4,7 +4,7 @@ import { customElement, property, state } from 'lit/decorators.js';
4
4
  import { i18next, localize } from '@operato/i18n';
5
5
  import { SidePanelStyles } from '@things-factory/figure-viewer/dist-client/side-panel-styles.js';
6
6
  import { figureAroundNormalOf, figureAroundOf, figureCaughtAngleOf, figureSurfaceAnglesOf, figureSurfacePlaceOf } from '@hatiolab/figure-model';
7
- import { alignmentAt, fastenLabelsOf, offsetOf, overhangOf, screenOf } from './fasten-geometry.js';
7
+ import { alignmentAt, drawingSpanOf, fastenLabelsOf, offsetOf, overhangOf, screenOf } from './fasten-geometry.js';
8
8
  const AXES = ['x', 'y', 'z'];
9
9
  const SEEN = [
10
10
  ['top', 'M60 30 L100 10 L200 10 L160 30 Z'],
@@ -312,8 +312,7 @@ let FigureFastenDrawing = class FigureFastenDrawing extends localize(i18next)(Li
312
312
  return nothing;
313
313
  const { h, v, sign } = screenOf(view.axes);
314
314
  const W = WHERE_W, H = WHERE_H;
315
- /* Room around the face for the part to go past its edges by about half itself; a plane with no size, three parts wide. */
316
- const span = (a) => (view.face[a] !== undefined ? view.face[a] + view.part[a] : view.part[a] * 3);
315
+ const span = (a) => drawingSpanOf(view.face[a], view.part[a]);
317
316
  const k = Math.min((W - 40) / span(h), (H - 40) / span(v));
318
317
  this.scale = k;
319
318
  const cx = W / 2, cy = H / 2;