@things-factory/figure-ui 10.1.82 → 10.1.84
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/command-preview.ts +4 -2
- package/client/modeller/drawn-shapes.ts +29 -0
- package/client/modeller/editor.ts +11 -29
- package/client/modeller/figure-links.ts +47 -101
- package/client/modeller/figure-material-panel.ts +2 -3
- package/client/modeller/figure-parts.ts +9 -11
- package/client/modeller/figure-section-panel.ts +175 -0
- package/client/modeller/gizmo.ts +26 -16
- package/client/modeller/joint-fan.ts +4 -3
- package/client/modeller/links.ts +24 -24
- package/client/modeller/maturity.ts +12 -6
- package/client/modeller/motion-ends.ts +2 -1
- package/client/modeller/refusals.ts +20 -0
- package/client/modeller/renderer.ts +3 -2
- package/client/modeller/section-controls.ts +34 -0
- package/client/modeller/starting-shape.ts +34 -0
- package/dist-client/modeller/clips.d.ts +1 -1
- package/dist-client/modeller/command-preview.js +4 -2
- package/dist-client/modeller/command-preview.js.map +1 -1
- package/dist-client/modeller/drawn-shapes.d.ts +44 -0
- package/dist-client/modeller/drawn-shapes.js +12 -0
- package/dist-client/modeller/drawn-shapes.js.map +1 -0
- package/dist-client/modeller/editor.d.ts +1 -6
- package/dist-client/modeller/editor.js +10 -29
- package/dist-client/modeller/editor.js.map +1 -1
- package/dist-client/modeller/figure-links.d.ts +2 -2
- package/dist-client/modeller/figure-links.js +45 -96
- package/dist-client/modeller/figure-links.js.map +1 -1
- package/dist-client/modeller/figure-material-panel.js +2 -3
- package/dist-client/modeller/figure-material-panel.js.map +1 -1
- package/dist-client/modeller/figure-parts.d.ts +3 -2
- package/dist-client/modeller/figure-parts.js +6 -9
- package/dist-client/modeller/figure-parts.js.map +1 -1
- package/dist-client/modeller/figure-section-panel.d.ts +28 -0
- package/dist-client/modeller/figure-section-panel.js +172 -0
- package/dist-client/modeller/figure-section-panel.js.map +1 -0
- package/dist-client/modeller/gizmo.d.ts +3 -3
- package/dist-client/modeller/gizmo.js +24 -11
- package/dist-client/modeller/gizmo.js.map +1 -1
- package/dist-client/modeller/joint-fan.js +4 -3
- package/dist-client/modeller/joint-fan.js.map +1 -1
- package/dist-client/modeller/links.d.ts +4 -1
- package/dist-client/modeller/links.js +23 -25
- package/dist-client/modeller/links.js.map +1 -1
- package/dist-client/modeller/maturity.d.ts +3 -2
- package/dist-client/modeller/maturity.js +9 -6
- package/dist-client/modeller/maturity.js.map +1 -1
- package/dist-client/modeller/motion-ends.js +2 -1
- package/dist-client/modeller/motion-ends.js.map +1 -1
- package/dist-client/modeller/refusals.d.ts +0 -5
- package/dist-client/modeller/refusals.js +25 -0
- package/dist-client/modeller/refusals.js.map +1 -1
- package/dist-client/modeller/renderer.d.ts +3 -4
- package/dist-client/modeller/renderer.js +3 -2
- package/dist-client/modeller/renderer.js.map +1 -1
- package/dist-client/modeller/section-controls.d.ts +11 -0
- package/dist-client/modeller/section-controls.js +27 -0
- package/dist-client/modeller/section-controls.js.map +1 -0
- package/dist-client/modeller/starting-shape.d.ts +32 -0
- package/dist-client/modeller/starting-shape.js +37 -0
- package/dist-client/modeller/starting-shape.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/test/browser/acceptance-page.js +8 -0
- package/test/command-preview.test.ts +3 -2
- package/test/fixtures/joint-column.json +110 -15
- package/test/fixtures/joint-roller.json +66 -9
- package/test/fixtures/robot-arm-6dof.json +203 -27
- package/test/joint-fan.test.ts +10 -7
- package/test/links.test.ts +6 -5
- package/test/material.test.ts +7 -2
- package/test/renderer.test.ts +2 -1
- package/test/resize-with-placement.test.ts +15 -14
- package/test/scene-canvas.test.ts +2 -1
- package/test/section-panel.test.ts +93 -0
- package/translations/en.json +21 -2
- package/translations/ja.json +20 -1
- package/translations/ko.json +22 -3
- package/translations/ms.json +20 -1
- package/translations/zh.json +20 -1
- package/dist-client/tsconfig.localkern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I,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,GAAG,EAAG,CAAC,CAAC,CAAC,CAAA;IAC3H,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { figureAttachmentsOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureInputChange } from '@hatiolab/figure-model'\n\n/**\n * What the gizmo may write for a part: move · turn · size, on a asset.\n *\n * A drag can only be written back where the part is placed by its own numbers. A part the create commands made is:\n * its pose is `rigid@1` into the asset frame from `<part>.position.*` and `<part>.rotation.*`, and a box's shape\n * (`box-shape@1` or `rounded-box@1`) takes its width, height and depth from inputs of its own — `<part>.size.*` from\n * `addFigureBox`, `<part>.dimension.*` from the editor's shape palette. A part fastened to another, following an instance size or placed by\n * expressions has no such numbers; the gizmo does not offer what it could not write back, rather\n * than move something the next evaluation would put back.\n */\nexport interface GizmoReach {\n translate: boolean\n rotate: boolean\n scale: boolean\n /** The inputs sizing the part along X, Y and Z, when it can be sized. */\n sizes?: [string, string, string]\n /**\n * Per axis, the part's own measure, or null where the measure follows another (a square section's depth following\n * its width): a scale drag writes the own ones and leaves a followed one to what it follows.\n */\n ownSizes?: (string | null)[]\n /**\n * A round part keeps its section round: the radii across (X and Z) take the one factor\n * the drag gave most; the length along Y takes its own. A sphere's three radii take one factor together.\n */\n round?: { across: string[]; along: string[] }\n}\n\n/** Shapes whose first three arguments are the extent along X, Y and Z: a door frame's too (its width, height, depth). */\nconst BOXES = new Set(['box-shape@1', 'rounded-box@1', 'portal-profile@2', 'hollow-box@2'])\n\ninterface Node {\n id: string\n op: string\n args: string[]\n outputs?: Record<string, string>\n params?: Record<string, unknown>\n}\ninterface AssetLike {\n document: { model: { nodes: Node[]; inputs: Array<{ id: string; role?: string }>; constants?: Array<{ id: string; value: number }> } }\n}\n\nconst AXES = ['x', 'y', 'z'] as const\n\nexport function gizmoReachOf(asset: AssetLike, part: string): GizmoReach {\n const { nodes, inputs } = asset.document.model\n const design = new Set(inputs.filter(input => input.role === 'design').map(input => input.id))\n const own = (name: string) => AXES.map(axis => `${part}.${name}.${axis}`)\n const allDesign = (ids: string[]) => ids.every(id => design.has(id))\n const pose = nodes.find(node => node.id === `${part}.pose`)\n const placed = nodes.find(node => node.id === part && node.op === 'place@1')\n const direct = !!pose && pose.op === 'rigid@1' && pose.params?.to === 'asset' && placed?.args[1] === `${part}.poseValue`\n /*\n A part taken off another (detach) stands on a seat into the asset frame with its own position numbers back. It\n can be moved like a part never fastened — unless it moves by itself, when where it is drawn is not its position.\n */\n const reseated =\n !!pose &&\n pose.op === 'rigid@1' &&\n !nodes.some(node => node.id === `${part}.motion`) &&\n figureAttachmentsOf(asset as unknown as FigureAsset)[part] === null\n const posed = direct || reseated\n const shape = nodes.find(node => node.id === `${part}.shape`)\n const mine = (ids: string[]) => ids.every(id => id.startsWith(`${part}.`) && design.has(id))\n const round =\n shape?.op === 'cylinder-shape@1' && mine(shape.args.slice(0, 2))\n ? { across: [shape.args[0]!], along: [shape.args[1]!] }\n : shape?.op === 'frustum-shape@1' && mine(shape.args.slice(0, 3))\n ? { across: shape.args.slice(0, 2), along: [shape.args[2]!] }\n : shape?.op === 'sphere-shape@1' && mine(shape.args.slice(0, 3))\n ? { across: shape.args.slice(0, 3), along: [] }\n : undefined\n const extent = shape && BOXES.has(shape.op) ? shape.args.slice(0, 3) : []\n const sizes =\n extent.length === 3 && extent.every(id => id.startsWith(`${part}.`) && design.has(id)) ? (extent as [string, string, string]) : undefined\n /*\n The part's own measure, also when another reads it: a measure some other part follows is read through a node of its\n own times 1 (`link-dimension`), and it is still the author's number -- the upper arm's width, which the forearm\n follows, is the upper arm's to drag.\n */\n const constants = asset.document.model.constants ?? []\n const ownMeasure = (id: string): string | null => {\n if (id.startsWith(`${part}.`) && design.has(id)) return id\n const writer = nodes.find(node => Object.values(node.outputs ?? {}).includes(id))\n const one = writer?.op === 'mul@1' && writer.args.length === 2 && constants.find(c => c.id === writer.args[1])?.value === 1\n return one && writer!.args[0]!.startsWith(`${part}.`) && design.has(writer!.args[0]!) ? writer!.args[0]! : null\n }\n const ownSizes = extent.length === 3 && !sizes ? extent.map(ownMeasure) : undefined\n const someOwn = !!ownSizes?.some(Boolean)\n return {\n translate: posed && allDesign(own('position')) && own('position').every((id, i) => pose!.args[i] === id),\n rotate: posed && allDesign(own('rotation')) && own('rotation').every((id, i) => pose!.args[3 + i] === id),\n scale: !!sizes || !!round || someOwn,\n ...(sizes ? { sizes } : {}),\n ...(someOwn ? { ownSizes } : {}),\n ...(round ? { round } : {})\n }\n}\n\n/** Where a drag left the part, in the asset frame: millimetres, degrees and per-axis scale. */\nexport interface GizmoResult {\n position?: [number, number, number]\n rotation?: [number, number, number]\n scale?: [number, number, number]\n}\n\n/**\n * The input changes a drag makes — one list, applied as one step. Millimetres to the millimetre and degrees to a\n * tenth (a drag otherwise stores 722.4180046035418 mm). A size never goes below 1 mm.\n */\nexport function gizmoChanges(part: string, reach: GizmoReach, result: GizmoResult, sizes: Record<string, number>): FigureInputChange[] {\n const changes: FigureInputChange[] = []\n const put = (input: string, unit: FigureInputChange['unit'], value: number) =>\n changes.push({ kind: 'set-design', input, unit, value } as FigureInputChange)\n if (result.position && reach.translate)\n AXES.forEach((axis, i) => put(`${part}.position.${axis}`, 'mm', Math.round(result.position![i]!)))\n if (result.rotation && reach.rotate)\n AXES.forEach((axis, i) => put(`${part}.rotation.${axis}`, 'deg', Math.round(result.rotation![i]! * 10) / 10))\n if (result.scale && reach.scale && reach.sizes)\n reach.sizes.forEach((id, i) => {\n if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * result.scale![i]!)))\n })\n if (result.scale && reach.scale && reach.ownSizes)\n reach.ownSizes.forEach((id, i) => {\n if (id && sizes[id] !== undefined && Math.abs(result.scale![i]! - 1) > 1e-4) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * result.scale![i]!)))\n })\n if (result.scale && reach.scale && reach.round) {\n const [sx, sy, sz] = result.scale\n /* The factor the drag moved most: across for a cylinder (X or Z), any axis for a sphere. */\n const most = (factors: number[]) => factors.reduce((a, b) => (Math.abs(b - 1) > Math.abs(a - 1) ? b : a), 1)\n const sphere = reach.round.along.length === 0\n const across = sphere ? most([sx!, sy!, sz!]) : most([sx!, sz!])\n for (const id of reach.round.across) if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * across)))\n for (const id of reach.round.along) if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * sy!)))\n }\n return changes\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gizmo.js","sourceRoot":"","sources":["../../client/modeller/gizmo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AA0CnF,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAA;AAErC,MAAM,UAAU,YAAY,CAAC,KAAgB,EAAE,IAAY;IACzD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAA;IAC9C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IAC9F,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC,CAAA;IACzE,MAAM,SAAS,GAAG,CAAC,GAAa,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IACpE,MAAM,IAAI,GAAG,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CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,GAAG,EAAG,CAAC,CAAC,CAAC,CAAA;IAC3H,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { figureAttachmentsOf, figureShapeProviderOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureInputChange } from '@hatiolab/figure-model'\n\n/**\n * What the gizmo may write for a part: move · turn · size, on a asset.\n *\n * A drag can only be written back where the part is placed by its own numbers. A part the create commands made is:\n * its pose is `rigid@1` into the asset frame from `<part>.position.*` and `<part>.rotation.*`, and its shape takes its\n * measures from inputs of its own — `<part>.size.*` from `addFigureBox`, `<part>.dimension.*` from the editor's shape\n * palette — at the arguments the shape itself names (figure-model's provider). A part fastened to another, following an instance size or placed by\n * expressions has no such numbers; the gizmo does not offer what it could not write back, rather\n * than move something the next evaluation would put back.\n */\nexport interface GizmoReach {\n translate: boolean\n rotate: boolean\n scale: boolean\n /** The inputs sizing the part along X, Y and Z, when it can be sized. */\n sizes?: [string, string, string]\n /**\n * Per axis, the part's own measure, or null where the measure follows another (a square section's depth following\n * its width): a scale drag writes the own ones and leaves a followed one to what it follows.\n */\n ownSizes?: (string | null)[]\n /**\n * A round part keeps its section round: the radii across (X and Z) take the one factor\n * the drag gave most; the length along Y takes its own. A sphere's three radii take one factor together.\n */\n round?: { across: string[]; along: string[] }\n}\n\ninterface Node {\n id: string\n op: string\n args: string[]\n outputs?: Record<string, string>\n params?: Record<string, unknown>\n}\ninterface AssetLike {\n document: { model: { nodes: Node[]; inputs: Array<{ id: string; role?: string }>; constants?: Array<{ id: string; value: number }> } }\n}\n\nconst AXES = ['x', 'y', 'z'] as const\n\nexport function gizmoReachOf(asset: AssetLike, part: string): GizmoReach {\n const { nodes, inputs } = asset.document.model\n const design = new Set(inputs.filter(input => input.role === 'design').map(input => input.id))\n const own = (name: string) => AXES.map(axis => `${part}.${name}.${axis}`)\n const allDesign = (ids: string[]) => ids.every(id => design.has(id))\n const pose = nodes.find(node => node.id === `${part}.pose`)\n const placed = nodes.find(node => node.id === part && node.op === 'place@1')\n const direct = !!pose && pose.op === 'rigid@1' && pose.params?.to === 'asset' && placed?.args[1] === `${part}.poseValue`\n /*\n A part taken off another (detach) stands on a seat into the asset frame with its own position numbers back. It\n can be moved like a part never fastened — unless it moves by itself, when where it is drawn is not its position.\n */\n const reseated =\n !!pose &&\n pose.op === 'rigid@1' &&\n !nodes.some(node => node.id === `${part}.motion`) &&\n figureAttachmentsOf(asset as unknown as FigureAsset)[part] === null\n const posed = direct || reseated\n const shape = nodes.find(node => node.id === `${part}.shape`)\n const mine = (ids: string[]) => ids.every(id => id.startsWith(`${part}.`) && design.has(id))\n /*\n Which argument sizes the part along X, Y and Z: the shape says (figure-model's provider, ADR-0100) -- never its first\n three arguments. A round section written from one radius, a sphere and a taper keep their shape: their radii take one\n factor together.\n */\n const provider = shape ? figureShapeProviderOf(shape as never) : undefined\n const edit = provider?.edit\n const refOf = (axis: 'x' | 'y' | 'z') => {\n const e = edit?.[axis]\n return e && !('refused' in e) ? shape!.args[e.arg]! : undefined\n }\n const measures = AXES.map(refOf)\n const shared = !!edit && AXES.some(axis => { const e = edit[axis]; return !('refused' in e) && !!(e.sameAs || e.with?.length) })\n let round: GizmoReach['round']\n if (shared && edit) {\n const withs = AXES.flatMap(axis => { const e = edit[axis]; return !('refused' in e) ? (e.with ?? []).map(i => shape!.args[i]!) : [] })\n const sphere = !!provider && Object.keys(provider.faces).length === 0\n const across = [...new Set([refOf('x')!, ...withs])]\n const along = sphere ? [] : [refOf('y')!]\n if ([...across, ...along].every(id => id && mine([id]))) round = { across: sphere ? [...new Set([...across, refOf('y')!])] : across, along }\n }\n const extent = !round && measures.every(Boolean) ? (measures as string[]) : []\n const sizes =\n extent.length === 3 && extent.every(id => id.startsWith(`${part}.`) && design.has(id)) ? (extent as [string, string, string]) : undefined\n /*\n The part's own measure, also when another reads it: a measure some other part follows is read through a node of its\n own times 1 (`link-dimension`), and it is still the author's number -- the upper arm's width, which the forearm\n follows, is the upper arm's to drag.\n */\n const constants = asset.document.model.constants ?? []\n const ownMeasure = (id: string): string | null => {\n if (id.startsWith(`${part}.`) && design.has(id)) return id\n const writer = nodes.find(node => Object.values(node.outputs ?? {}).includes(id))\n const one = writer?.op === 'mul@1' && writer.args.length === 2 && constants.find(c => c.id === writer.args[1])?.value === 1\n return one && writer!.args[0]!.startsWith(`${part}.`) && design.has(writer!.args[0]!) ? writer!.args[0]! : null\n }\n const ownSizes = extent.length === 3 && !sizes ? extent.map(ownMeasure) : undefined\n const someOwn = !!ownSizes?.some(Boolean)\n return {\n translate: posed && allDesign(own('position')) && own('position').every((id, i) => pose!.args[i] === id),\n rotate: posed && allDesign(own('rotation')) && own('rotation').every((id, i) => pose!.args[3 + i] === id),\n scale: !!sizes || !!round || someOwn,\n ...(sizes ? { sizes } : {}),\n ...(someOwn ? { ownSizes } : {}),\n ...(round ? { round } : {})\n }\n}\n\n/** Where a drag left the part, in the asset frame: millimetres, degrees and per-axis scale. */\nexport interface GizmoResult {\n position?: [number, number, number]\n rotation?: [number, number, number]\n scale?: [number, number, number]\n}\n\n/**\n * The input changes a drag makes — one list, applied as one step. Millimetres to the millimetre and degrees to a\n * tenth (a drag otherwise stores 722.4180046035418 mm). A size never goes below 1 mm.\n */\nexport function gizmoChanges(part: string, reach: GizmoReach, result: GizmoResult, sizes: Record<string, number>): FigureInputChange[] {\n const changes: FigureInputChange[] = []\n const put = (input: string, unit: FigureInputChange['unit'], value: number) =>\n changes.push({ kind: 'set-design', input, unit, value } as FigureInputChange)\n if (result.position && reach.translate)\n AXES.forEach((axis, i) => put(`${part}.position.${axis}`, 'mm', Math.round(result.position![i]!)))\n if (result.rotation && reach.rotate)\n AXES.forEach((axis, i) => put(`${part}.rotation.${axis}`, 'deg', Math.round(result.rotation![i]! * 10) / 10))\n if (result.scale && reach.scale && reach.sizes)\n reach.sizes.forEach((id, i) => {\n if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * result.scale![i]!)))\n })\n if (result.scale && reach.scale && reach.ownSizes)\n reach.ownSizes.forEach((id, i) => {\n if (id && sizes[id] !== undefined && Math.abs(result.scale![i]! - 1) > 1e-4) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * result.scale![i]!)))\n })\n if (result.scale && reach.scale && reach.round) {\n const [sx, sy, sz] = result.scale\n /* The factor the drag moved most: across for a cylinder (X or Z), any axis for a sphere. */\n const most = (factors: number[]) => factors.reduce((a, b) => (Math.abs(b - 1) > Math.abs(a - 1) ? b : a), 1)\n const sphere = reach.round.along.length === 0\n const across = sphere ? most([sx!, sy!, sz!]) : most([sx!, sz!])\n for (const id of reach.round.across) if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * across)))\n for (const id of reach.round.along) if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * sy!)))\n }\n return changes\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compileFigureAsset, compileFigureGraph, figureWorldBoxesOf, figureWritersOf } from '@hatiolab/figure-model';
|
|
2
|
+
import { sectionShape } from './drawn-shapes.js';
|
|
2
3
|
/*
|
|
3
4
|
* Where the selected part turns, and how far -- a translucent fan on the editing board. An axis name says nothing about which way a part swings; on a six-axis arm the author went to the preview and
|
|
4
5
|
* pushed each slider to its end to find out. The fan lies in the plane the part turns in, at the pivot, open from the
|
|
@@ -225,13 +226,13 @@ export function jointFanOf(asset, part, values = {}) {
|
|
|
225
226
|
const r = [0, 1, 2].map(i => [first[i], axisNow[i], zAxis[i]]);
|
|
226
227
|
const local = (p) => {
|
|
227
228
|
const v = sub(p, pivot);
|
|
228
|
-
return { x: dot(v, first),
|
|
229
|
+
return { x: dot(v, first), z: dot(v, zAxis) };
|
|
229
230
|
};
|
|
230
231
|
const full = max - min >= 359.999;
|
|
231
|
-
const profile = [...(full ? [] : [{ x: 0,
|
|
232
|
+
const profile = [...(full ? [] : [{ x: 0, z: 0 }]), ...traced.map(local)].map(p => ({ x: Math.round(p.x * 1000) / 1000, z: Math.round(p.z * 1000) / 1000 }));
|
|
232
233
|
return {
|
|
233
234
|
id: JOINT_FAN,
|
|
234
|
-
shape:
|
|
235
|
+
shape: sectionShape(profile, THICKNESS),
|
|
235
236
|
pose: { t: pivot, r },
|
|
236
237
|
material: { token: '__joint-fan', transparent: true },
|
|
237
238
|
/** Which control turns it: the joint the fan shows. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joint-fan.js","sourceRoot":"","sources":["../../client/modeller/joint-fan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKpH;;;;;;;;;;;;;;;GAeG;AAEH,6FAA6F;AAC7F,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAA;AAEtC,+FAA+F;AAC/F,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,CAAC,CAAA;AAWlB,MAAM,KAAK,GAAG,CAAC,CAAO,EAAE,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAA;AACrI,MAAM,GAAG,GAAG,CAAC,CAAW,EAAE,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAA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IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,GAAG,KAAK,EAAE,CAAC;YAChC,IAAI,EAAE,CAAC,CAAC,CAAE,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC,CAAE,GAAG,GAAG;gBAAE,OAAO,KAAK,CAAA;YAC9C,SAAQ;QACV,CAAC;QACD,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,EACnC,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;QACjC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QACnC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QACnC,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,KAAK,CAAA;IAC3B,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { compileFigureAsset, compileFigureGraph, figureWorldBoxesOf, figureWritersOf } from '@hatiolab/figure-model'\nimport type { FigureAsset } from '@hatiolab/figure-model'\n\nimport type { FigureRenderPart } from './renderer.js'\n\n/*\n * Where the selected part turns, and how far -- a translucent fan on the editing board. An axis name says nothing about which way a part swings; on a six-axis arm the author went to the preview and\n * pushed each slider to its end to find out. The fan lies in the plane the part turns in, at the pivot, open from the\n * control's lowest value to its highest; the edge at the value the figure holds now is where the part is.\n *\n * It is found by evaluating, not by reading the graph's shape: the frame that carries the part is sampled across the\n * control's range, and a point at a fixed distance from the pivot traces the fan. So the direction is right whatever\n * the slope of the control, and a joint inside other joints is drawn where its parents put it.\n *\n * Two ways a part turns are read:\n * - a joint record (ADR-0093): at the joint's origin, about its axis;\n * - a joint written as values (`<joint>.motion` · `<joint>.chain`): the part is composed on the joint's\n * chain, the pivot is the joint's origin (`<joint>.frameOnParent`).\n * A slide has no fan. Nothing is drawn when the turn cannot be found -- a fan in some guessed plane would point the\n * wrong way.\n */\n\n/** The fan's name on the board. It is not a part: not in the list, not saved, not picked. */\nexport const JOINT_FAN = '__joint-fan'\n\n/** How thick the fan is: thin enough not to hide the part, thick enough to be seen edge-on. */\nconst THICKNESS = 6\n/** About one segment every six degrees, so a full turn reads as a circle. */\nconst STEP_DEG = 6\n\ntype Pose = { r: number[][]; t: number[] }\ninterface Node {\n id: string\n op: string\n args: string[]\n outputs: Record<string, string>\n params?: Record<string, string>\n}\n\nconst apply = (p: Pose, v: number[]) => [0, 1, 2].map(i => p.r[i]![0]! * v[0]! + p.r[i]![1]! * v[1]! + p.r[i]![2]! * v[2]! + p.t[i]!)\nconst sub = (a: number[], b: number[]) => a.map((v, i) => v - b[i]!)\nconst dot = (a: number[], b: number[]) => a.reduce((s, v, i) => s + v * b[i]!, 0)\nconst cross = (a: number[], b: number[]) => [a[1]! * b[2]! - a[2]! * b[1]!, a[2]! * b[0]! - a[0]! * b[2]!, a[0]! * b[1]! - a[1]! * b[0]!]\nconst norm = (a: number[]) => {\n const l = Math.hypot(...a)\n return l > 1e-9 ? a.map(v => v / l) : null\n}\n\n/** How far outside a part's box a pivot may lie and still be on the part: the kernel's contact skin. */\nconst SEAM = 1\n/** An origin this deep in a part's box (a share of its half-measure, on every axis) is housed by the part. */\nconst HOUSED = 0.5\nconst AXIS_NAMES = ['x', 'y', 'z'] as const\ntype WorldBox = { centre: Record<'x' | 'y' | 'z', number>; extent: Record<'x' | 'y' | 'z', number> }\n\ninterface Turn {\n /** The node whose value carries the moving frame into the figure's frame. */\n carrier: string\n /** The pivot, in the moving frame. */\n pivot: number[]\n /** The axis, in the moving frame. */\n axis: number[]\n /** Where the part sits, in the moving frame -- which way the fan's reference edge points. */\n toward: number[]\n /** The part the joint turns -- the fan is sized from it, so a joint shows one fan whichever part is selected. */\n turnedPart: string\n /** The state input that turns it. */\n control: { id: string; min: number; max: number }\n}\n\nfunction turnOf(asset: FigureAsset, part: string, values: Record<string, unknown>, box: WorldBox | undefined): Turn | null {\n const m = asset.document.model as unknown as { nodes: Node[]; constants: { id: string; value: number }[]; inputs: { id: string; role?: string; min?: number; max?: number }[] }\n const node = (id: string) => m.nodes.find(n => n.id === id)\n const constant = (ref: string) => m.constants.find(c => c.id === ref)?.value\n const valueOf = (n: Node | undefined) => (n ? values[Object.values(n.outputs)[0]!] : undefined) as Pose | undefined\n const controlOf = (ref: string | undefined, seen = new Set<string>()): Turn['control'] | null => {\n if (!ref || seen.has(ref)) return null\n seen.add(ref)\n const input = m.inputs.find(i => i.id === ref && i.role === 'state')\n if (input) return { id: input.id, min: input.min ?? 0, max: input.max ?? 0 }\n const writer = m.nodes.find(n => Object.values(n.outputs).includes(ref))\n for (const arg of writer?.args ?? []) {\n const found = controlOf(arg, seen)\n if (found) return found\n }\n return null\n }\n const axisOf = (motion: Node) => {\n const axis = motion.args.slice(0, 3).map(constant)\n return axis.every(v => typeof v === 'number') ? norm(axis as number[]) : null\n }\n\n /*\n A joint record (ADR-0093): the fan stands at the joint -- the point on the parent's face the child is fastened at --\n about the joint's axis. A part that does not turn itself shows the joint that sits on it, when there is one: the\n elbow block shows the elbow (user, 2026-09-24: 「elbow-housing itself is a axis」).\n */\n const turning = (asset.joints ?? []).filter(j => j.type === 'revolute')\n const record = turning.find(j => j.body1.part === part) ?? (() => {\n const on = turning.filter(j => 'part' in j.body0 && j.body0.part === part)\n return on.length === 1 && !(asset.joints ?? []).some(j => j.body1.part === part && j.type !== 'fixed') ? on[0] : undefined\n })()\n if (record) {\n const child = record.body1.part\n const carrier = node(`${child}.world`) ? `${child}.world` : `${child}.chain`\n const pose = valueOf(node(`${child}.pose`))\n const motion = node(`${child}.motion`)\n const control = controlOf(motion?.args[3])\n if (!node(carrier) || !pose || !control) return null\n /* In the child's own frame: the joint is where its pose puts the seat's origin, the axis turned back by its pose. */\n const back = (v: number[]) => [0, 1, 2].map(i => pose.r[0]![i]! * v[0]! + pose.r[1]![i]! * v[1]! + pose.r[2]![i]! * v[2]!)\n const pivot = back(pose.t.map(v => -v))\n const axis = norm(back(AXIS_NAMES.map(a => (a.toUpperCase() === record.axis ? 1 : 0))))\n if (!axis) return null\n return { carrier, pivot, axis, toward: [0, 0, 0], control, turnedPart: child }\n }\n\n /*\n A joint written as values (`<joint>.motion`, its origin `<joint>.frameOnParent`) carries its own part and\n everything fastened below it, through its chain (the first joint of a chain has only its attachment). A part shows\n the joint it is to that part of the mechanism (user, 2026-09-24: 「elbow-housing itself is a axis」 · 「please check\n all that logic and concept」), tested in this order on the joints as they stand now:\n 1. housing -- a joint's origin lies deep inside the part, which is centred on it: the shoulder housing shows the\n shoulder and the elbow housing the elbow, though another joint carries them;\n 2. turned -- the joint that carries the part, when its axis passes through the part: through its middle for a\n body that rolls on it (the wrist roll, the tool flange, the gripper body), through its root for a link (the\n upper arm, the forearm);\n 3. otherwise none: the pedestal (the base's axis runs through it but turns it not), the fingers.\n An axis passing through a part is not enough by itself: the wrist roll's axis runs the forearm's length and the\n tool roll's through the wrist pitch, and neither turns them (an earlier rule said so, and was wrong).\n */\n if (!box) return null\n const carrierOf = (joint: string) => (node(`${joint}.chain`) ? `${joint}.chain` : `${joint}.attach`)\n const mine = node(`${part}.moved`)?.args.find(arg => /\\.(chain|attach)\\.value$/.test(arg))?.replace(/\\.value$/, '')\n const centre = AXIS_NAMES.map(a => box.centre[a])\n const half = AXIS_NAMES.map(a => box.extent[a] / 2)\n const joints = m.nodes\n .filter(n => n.op === 'axis-turn@1' && n.id.endsWith('.motion') && node(n.id.replace(/\\.motion$/, '.frameOnParent')))\n .map(motion => {\n const joint = motion.id.replace(/\\.motion$/, '')\n const carrier = carrierOf(joint)\n const frame = valueOf(node(carrier))\n const origin = valueOf(node(`${joint}.frameOnParent`))\n const local = axisOf(motion)\n if (!frame || !origin || !local) return null\n const at = apply(frame, origin.t)\n const along = norm([0, 1, 2].map(i => dot(frame.r[i]!, local)))\n if (!along) return null\n const off = sub(centre, at)\n return {\n joint,\n motion,\n carrier,\n origin,\n /* How deep the origin lies: 0 at the centre, 1 on the box's face, on the axis where it is shallowest. */\n depth: Math.max(...[0, 1, 2].map(i => Math.abs(off[i]!) / (half[i]! + SEAM))),\n fromCentre: Math.hypot(...off),\n through: lineMeetsBox(at, along, centre, half)\n }\n })\n .filter((c): c is NonNullable<typeof c> => !!c)\n const housing = joints.filter(c => c.depth <= HOUSED).sort((a, b) => a.fromCentre - b.fromCentre)[0]\n const carrying = joints.find(c => c.carrier === mine)\n const chosen = housing ?? (carrying && carrying.through ? carrying : undefined)\n if (!chosen) return null\n const axis = axisOf(chosen.motion)\n const control = controlOf(chosen.motion.args[3])\n if (!axis || !control) return null\n /* The reference edge points at what the joint turns: of the parts it carries, the one farthest off its axis. */\n const flatOff = (t: number[]) => {\n const rel = sub(t, chosen.origin.t)\n return Math.hypot(...sub(rel, axis.map(v => v * dot(rel, axis))))\n }\n const turned = m.nodes\n .filter(n => n.id.endsWith('.moved') && n.args.includes(`${chosen.carrier}.value`))\n .map(n => ({ id: n.id.replace(/\\.moved$/, ''), t: valueOf(node(n.id.replace(/\\.moved$/, '.pose')))?.t }))\n .filter((one): one is { id: string; t: number[] } => !!one.t)\n .sort((a, b) => flatOff(b.t) - flatOff(a.t))[0]\n return { carrier: chosen.carrier, pivot: chosen.origin.t, axis, toward: turned?.t ?? chosen.origin.t, control, turnedPart: turned?.id ?? part }\n}\n\n/**\n * The fan for the part, as a body to stand on the board, or null when the part does not turn. `values` are the\n * inputs the figure is drawn with now (a pose in hand included), so the fan follows the arm as it is posed.\n */\nexport function jointFanOf(asset: FigureAsset, part: string, values: Record<string, number> = {}): FigureRenderPart | null {\n if (!part) return null\n let graph: ReturnType<typeof compileFigureGraph>\n try {\n graph = compileFigureGraph(asset.document.model as never)\n } catch {\n return null\n }\n const inputs = { ...asset.designInputs, ...asset.stateDefaults, ...values }\n const at = (over: Record<string, number>) => graph.evaluate({ ...inputs, ...over }).values as Record<string, unknown>\n let now: Record<string, unknown>\n try {\n now = at({})\n } catch {\n return null\n }\n let box: WorldBox | undefined\n try {\n box = figureWorldBoxesOf(\n compileFigureAsset({ ...asset, designInputs: { ...asset.designInputs, ...pick(values, asset.designInputs) }, stateDefaults: { ...asset.stateDefaults, ...pick(values, asset.stateDefaults) } })\n .evaluate()\n .geometry.filter(g => g.id === part),\n figureWritersOf(asset)\n )[0]\n } catch {\n box = undefined\n }\n const turn = turnOf(asset, part, now, box)\n if (!turn) return null\n const carrierRef = Object.values(asset.document.model.nodes.find(n => n.id === turn.carrier)!.outputs)[0]!\n const carrierNow = now[carrierRef] as Pose | undefined\n if (!carrierNow) return null\n\n /* The reference edge points from the pivot toward the part, in the plane it turns in; any perpendicular if it sits on the axis. */\n const rel = sub(turn.toward, turn.pivot)\n const inPlane = sub(rel, turn.axis.map(v => v * dot(rel, turn.axis)))\n const d = norm(inPlane) ?? norm(cross(turn.axis, Math.abs(turn.axis[0]!) < 0.9 ? [1, 0, 0] : [0, 1, 0]))!\n /*\n Sized from what the joint turns, not from the selected part: selecting the elbow housing or the forearm\n shows the elbow's one fan, not a smaller one for the smaller part (user, 2026-09-24).\n */\n const radius = Math.max(60, Math.round(Math.max(largestMeasureOf(asset, turn.turnedPart, inputs), Math.hypot(...inPlane)) * 0.6))\n const edge = turn.pivot.map((v, i) => v + d[i]! * radius)\n\n const { min, max } = turn.control\n if (!(max > min)) return null\n const steps = Math.max(2, Math.ceil((max - min) / STEP_DEG))\n const pivot = apply(carrierNow, turn.pivot)\n const traced: number[][] = []\n try {\n for (let i = 0; i <= steps; i++) {\n const s = min + ((max - min) * i) / steps\n traced.push(apply(at({ [turn.control.id]: s })[carrierRef] as Pose, edge))\n }\n } catch {\n return null\n }\n\n /* The fan's own frame: x toward the first traced point, y along the axis as it stands now, z completing them. */\n const axisNow = norm([0, 1, 2].map(i => dot(carrierNow.r[i]!, turn.axis)))\n const first = norm(sub(traced[0]!, pivot))\n if (!axisNow || !first) return null\n const zAxis = cross(first, axisNow)\n const r = [0, 1, 2].map(i => [first[i]!, axisNow[i]!, zAxis[i]!])\n const local = (p: number[]) => {\n const v = sub(p, pivot)\n return { x: dot(v, first), y: dot(v, zAxis) }\n }\n const full = max - min >= 359.999\n const profile = [...(full ? [] : [{ x: 0, y: 0 }]), ...traced.map(local)].map(p => ({ x: Math.round(p.x * 1000) / 1000, y: Math.round(p.y * 1000) / 1000 }))\n\n return {\n id: JOINT_FAN,\n shape: { provider: 'polygon', dimensions: { height: THICKNESS }, profile },\n pose: { t: pivot, r },\n material: { token: '__joint-fan', transparent: true },\n /** Which control turns it: the joint the fan shows. */\n turns: turn.control.id\n } as unknown as FigureRenderPart\n}\n\n/** The values in hand that belong to a record's keys (design inputs, or state defaults). */\nfunction pick(values: Record<string, number>, of: Record<string, number>): Record<string, number> {\n return Object.fromEntries(Object.entries(values).filter(([id]) => id in of))\n}\n\n/** A part's largest own measure (a box side, a diameter, a length) at the inputs given; 0 when it cannot be read. */\nfunction largestMeasureOf(asset: FigureAsset, part: string, inputs: Record<string, number>): number {\n try {\n const body = compileFigureAsset({ ...asset, designInputs: pick(inputs, asset.designInputs), stateDefaults: pick(inputs, asset.stateDefaults) })\n .evaluate()\n .geometry.find(g => g.id === part) as { shape?: { dimensions?: Record<string, number> } } | undefined\n const dims = Object.entries(body?.shape?.dimensions ?? {}).map(([k, v]) => (k.startsWith('radius') ? v * 2 : v))\n return dims.length ? Math.max(...dims) : 0\n } catch {\n return 0\n }\n}\n\n/** Whether the line through `at` along `along` passes through the box (centre, half-measures), within the skin. */\nfunction lineMeetsBox(at: number[], along: number[], centre: number[], half: number[]): boolean {\n let lo = -Infinity,\n hi = Infinity\n for (let i = 0; i < 3; i++) {\n const min = centre[i]! - half[i]! - SEAM,\n max = centre[i]! + half[i]! + SEAM\n if (Math.abs(along[i]!) < 1e-12) {\n if (at[i]! < min || at[i]! > max) return false\n continue\n }\n const t1 = (min - at[i]!) / along[i]!,\n t2 = (max - at[i]!) / along[i]!\n lo = Math.max(lo, Math.min(t1, t2))\n hi = Math.min(hi, Math.max(t1, t2))\n if (lo > hi) return false\n }\n return true\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"joint-fan.js","sourceRoot":"","sources":["../../client/modeller/joint-fan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAIpH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;;;;;;;;;;;;;GAeG;AAEH,6FAA6F;AAC7F,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAA;AAEtC,+FAA+F;AAC/F,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,CAAC,CAAA;AAWlB,MAAM,KAAK,GAAG,CAAC,CAAO,EAAE,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAA;AACrI,MAAM,GAAG,GAAG,CAAC,CAAW,EAAE,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CA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AAC,CAAE,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC,CAAE,GAAG,GAAG;gBAAE,OAAO,KAAK,CAAA;YAC9C,SAAQ;QACV,CAAC;QACD,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,EACnC,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;QACjC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QACnC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QACnC,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,KAAK,CAAA;IAC3B,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { compileFigureAsset, compileFigureGraph, figureWorldBoxesOf, figureWritersOf } from '@hatiolab/figure-model'\nimport type { FigureAsset } from '@hatiolab/figure-model'\n\nimport type { FigureRenderPart } from './renderer.js'\nimport { sectionShape } from './drawn-shapes.js'\n\n/*\n * Where the selected part turns, and how far -- a translucent fan on the editing board. An axis name says nothing about which way a part swings; on a six-axis arm the author went to the preview and\n * pushed each slider to its end to find out. The fan lies in the plane the part turns in, at the pivot, open from the\n * control's lowest value to its highest; the edge at the value the figure holds now is where the part is.\n *\n * It is found by evaluating, not by reading the graph's shape: the frame that carries the part is sampled across the\n * control's range, and a point at a fixed distance from the pivot traces the fan. So the direction is right whatever\n * the slope of the control, and a joint inside other joints is drawn where its parents put it.\n *\n * Two ways a part turns are read:\n * - a joint record (ADR-0093): at the joint's origin, about its axis;\n * - a joint written as values (`<joint>.motion` · `<joint>.chain`): the part is composed on the joint's\n * chain, the pivot is the joint's origin (`<joint>.frameOnParent`).\n * A slide has no fan. Nothing is drawn when the turn cannot be found -- a fan in some guessed plane would point the\n * wrong way.\n */\n\n/** The fan's name on the board. It is not a part: not in the list, not saved, not picked. */\nexport const JOINT_FAN = '__joint-fan'\n\n/** How thick the fan is: thin enough not to hide the part, thick enough to be seen edge-on. */\nconst THICKNESS = 6\n/** About one segment every six degrees, so a full turn reads as a circle. */\nconst STEP_DEG = 6\n\ntype Pose = { r: number[][]; t: number[] }\ninterface Node {\n id: string\n op: string\n args: string[]\n outputs: Record<string, string>\n params?: Record<string, string>\n}\n\nconst apply = (p: Pose, v: number[]) => [0, 1, 2].map(i => p.r[i]![0]! * v[0]! + p.r[i]![1]! * v[1]! + p.r[i]![2]! * v[2]! + p.t[i]!)\nconst sub = (a: number[], b: number[]) => a.map((v, i) => v - b[i]!)\nconst dot = (a: number[], b: number[]) => a.reduce((s, v, i) => s + v * b[i]!, 0)\nconst cross = (a: number[], b: number[]) => [a[1]! * b[2]! - a[2]! * b[1]!, a[2]! * b[0]! - a[0]! * b[2]!, a[0]! * b[1]! - a[1]! * b[0]!]\nconst norm = (a: number[]) => {\n const l = Math.hypot(...a)\n return l > 1e-9 ? a.map(v => v / l) : null\n}\n\n/** How far outside a part's box a pivot may lie and still be on the part: the kernel's contact skin. */\nconst SEAM = 1\n/** An origin this deep in a part's box (a share of its half-measure, on every axis) is housed by the part. */\nconst HOUSED = 0.5\nconst AXIS_NAMES = ['x', 'y', 'z'] as const\ntype WorldBox = { centre: Record<'x' | 'y' | 'z', number>; extent: Record<'x' | 'y' | 'z', number> }\n\ninterface Turn {\n /** The node whose value carries the moving frame into the figure's frame. */\n carrier: string\n /** The pivot, in the moving frame. */\n pivot: number[]\n /** The axis, in the moving frame. */\n axis: number[]\n /** Where the part sits, in the moving frame -- which way the fan's reference edge points. */\n toward: number[]\n /** The part the joint turns -- the fan is sized from it, so a joint shows one fan whichever part is selected. */\n turnedPart: string\n /** The state input that turns it. */\n control: { id: string; min: number; max: number }\n}\n\nfunction turnOf(asset: FigureAsset, part: string, values: Record<string, unknown>, box: WorldBox | undefined): Turn | null {\n const m = asset.document.model as unknown as { nodes: Node[]; constants: { id: string; value: number }[]; inputs: { id: string; role?: string; min?: number; max?: number }[] }\n const node = (id: string) => m.nodes.find(n => n.id === id)\n const constant = (ref: string) => m.constants.find(c => c.id === ref)?.value\n const valueOf = (n: Node | undefined) => (n ? values[Object.values(n.outputs)[0]!] : undefined) as Pose | undefined\n const controlOf = (ref: string | undefined, seen = new Set<string>()): Turn['control'] | null => {\n if (!ref || seen.has(ref)) return null\n seen.add(ref)\n const input = m.inputs.find(i => i.id === ref && i.role === 'state')\n if (input) return { id: input.id, min: input.min ?? 0, max: input.max ?? 0 }\n const writer = m.nodes.find(n => Object.values(n.outputs).includes(ref))\n for (const arg of writer?.args ?? []) {\n const found = controlOf(arg, seen)\n if (found) return found\n }\n return null\n }\n const axisOf = (motion: Node) => {\n const axis = motion.args.slice(0, 3).map(constant)\n return axis.every(v => typeof v === 'number') ? norm(axis as number[]) : null\n }\n\n /*\n A joint record (ADR-0093): the fan stands at the joint -- the point on the parent's face the child is fastened at --\n about the joint's axis. A part that does not turn itself shows the joint that sits on it, when there is one: the\n elbow block shows the elbow (user, 2026-09-24: 「elbow-housing itself is a axis」).\n */\n const turning = (asset.joints ?? []).filter(j => j.type === 'revolute')\n const record = turning.find(j => j.body1.part === part) ?? (() => {\n const on = turning.filter(j => 'part' in j.body0 && j.body0.part === part)\n return on.length === 1 && !(asset.joints ?? []).some(j => j.body1.part === part && j.type !== 'fixed') ? on[0] : undefined\n })()\n if (record) {\n const child = record.body1.part\n const carrier = node(`${child}.world`) ? `${child}.world` : `${child}.chain`\n const pose = valueOf(node(`${child}.pose`))\n const motion = node(`${child}.motion`)\n const control = controlOf(motion?.args[3])\n if (!node(carrier) || !pose || !control) return null\n /* In the child's own frame: the joint is where its pose puts the seat's origin, the axis turned back by its pose. */\n const back = (v: number[]) => [0, 1, 2].map(i => pose.r[0]![i]! * v[0]! + pose.r[1]![i]! * v[1]! + pose.r[2]![i]! * v[2]!)\n const pivot = back(pose.t.map(v => -v))\n const axis = norm(back(AXIS_NAMES.map(a => (a.toUpperCase() === record.axis ? 1 : 0))))\n if (!axis) return null\n return { carrier, pivot, axis, toward: [0, 0, 0], control, turnedPart: child }\n }\n\n /*\n A joint written as values (`<joint>.motion`, its origin `<joint>.frameOnParent`) carries its own part and\n everything fastened below it, through its chain (the first joint of a chain has only its attachment). A part shows\n the joint it is to that part of the mechanism (user, 2026-09-24: 「elbow-housing itself is a axis」 · 「please check\n all that logic and concept」), tested in this order on the joints as they stand now:\n 1. housing -- a joint's origin lies deep inside the part, which is centred on it: the shoulder housing shows the\n shoulder and the elbow housing the elbow, though another joint carries them;\n 2. turned -- the joint that carries the part, when its axis passes through the part: through its middle for a\n body that rolls on it (the wrist roll, the tool flange, the gripper body), through its root for a link (the\n upper arm, the forearm);\n 3. otherwise none: the pedestal (the base's axis runs through it but turns it not), the fingers.\n An axis passing through a part is not enough by itself: the wrist roll's axis runs the forearm's length and the\n tool roll's through the wrist pitch, and neither turns them (an earlier rule said so, and was wrong).\n */\n if (!box) return null\n const carrierOf = (joint: string) => (node(`${joint}.chain`) ? `${joint}.chain` : `${joint}.attach`)\n const mine = node(`${part}.moved`)?.args.find(arg => /\\.(chain|attach)\\.value$/.test(arg))?.replace(/\\.value$/, '')\n const centre = AXIS_NAMES.map(a => box.centre[a])\n const half = AXIS_NAMES.map(a => box.extent[a] / 2)\n const joints = m.nodes\n .filter(n => n.op === 'axis-turn@1' && n.id.endsWith('.motion') && node(n.id.replace(/\\.motion$/, '.frameOnParent')))\n .map(motion => {\n const joint = motion.id.replace(/\\.motion$/, '')\n const carrier = carrierOf(joint)\n const frame = valueOf(node(carrier))\n const origin = valueOf(node(`${joint}.frameOnParent`))\n const local = axisOf(motion)\n if (!frame || !origin || !local) return null\n const at = apply(frame, origin.t)\n const along = norm([0, 1, 2].map(i => dot(frame.r[i]!, local)))\n if (!along) return null\n const off = sub(centre, at)\n return {\n joint,\n motion,\n carrier,\n origin,\n /* How deep the origin lies: 0 at the centre, 1 on the box's face, on the axis where it is shallowest. */\n depth: Math.max(...[0, 1, 2].map(i => Math.abs(off[i]!) / (half[i]! + SEAM))),\n fromCentre: Math.hypot(...off),\n through: lineMeetsBox(at, along, centre, half)\n }\n })\n .filter((c): c is NonNullable<typeof c> => !!c)\n const housing = joints.filter(c => c.depth <= HOUSED).sort((a, b) => a.fromCentre - b.fromCentre)[0]\n const carrying = joints.find(c => c.carrier === mine)\n const chosen = housing ?? (carrying && carrying.through ? carrying : undefined)\n if (!chosen) return null\n const axis = axisOf(chosen.motion)\n const control = controlOf(chosen.motion.args[3])\n if (!axis || !control) return null\n /* The reference edge points at what the joint turns: of the parts it carries, the one farthest off its axis. */\n const flatOff = (t: number[]) => {\n const rel = sub(t, chosen.origin.t)\n return Math.hypot(...sub(rel, axis.map(v => v * dot(rel, axis))))\n }\n const turned = m.nodes\n .filter(n => n.id.endsWith('.moved') && n.args.includes(`${chosen.carrier}.value`))\n .map(n => ({ id: n.id.replace(/\\.moved$/, ''), t: valueOf(node(n.id.replace(/\\.moved$/, '.pose')))?.t }))\n .filter((one): one is { id: string; t: number[] } => !!one.t)\n .sort((a, b) => flatOff(b.t) - flatOff(a.t))[0]\n return { carrier: chosen.carrier, pivot: chosen.origin.t, axis, toward: turned?.t ?? chosen.origin.t, control, turnedPart: turned?.id ?? part }\n}\n\n/**\n * The fan for the part, as a body to stand on the board, or null when the part does not turn. `values` are the\n * inputs the figure is drawn with now (a pose in hand included), so the fan follows the arm as it is posed.\n */\nexport function jointFanOf(asset: FigureAsset, part: string, values: Record<string, number> = {}): FigureRenderPart | null {\n if (!part) return null\n let graph: ReturnType<typeof compileFigureGraph>\n try {\n graph = compileFigureGraph(asset.document.model as never)\n } catch {\n return null\n }\n const inputs = { ...asset.designInputs, ...asset.stateDefaults, ...values }\n const at = (over: Record<string, number>) => graph.evaluate({ ...inputs, ...over }).values as Record<string, unknown>\n let now: Record<string, unknown>\n try {\n now = at({})\n } catch {\n return null\n }\n let box: WorldBox | undefined\n try {\n box = figureWorldBoxesOf(\n compileFigureAsset({ ...asset, designInputs: { ...asset.designInputs, ...pick(values, asset.designInputs) }, stateDefaults: { ...asset.stateDefaults, ...pick(values, asset.stateDefaults) } })\n .evaluate()\n .geometry.filter(g => g.id === part),\n figureWritersOf(asset)\n )[0]\n } catch {\n box = undefined\n }\n const turn = turnOf(asset, part, now, box)\n if (!turn) return null\n const carrierRef = Object.values(asset.document.model.nodes.find(n => n.id === turn.carrier)!.outputs)[0]!\n const carrierNow = now[carrierRef] as Pose | undefined\n if (!carrierNow) return null\n\n /* The reference edge points from the pivot toward the part, in the plane it turns in; any perpendicular if it sits on the axis. */\n const rel = sub(turn.toward, turn.pivot)\n const inPlane = sub(rel, turn.axis.map(v => v * dot(rel, turn.axis)))\n const d = norm(inPlane) ?? norm(cross(turn.axis, Math.abs(turn.axis[0]!) < 0.9 ? [1, 0, 0] : [0, 1, 0]))!\n /*\n Sized from what the joint turns, not from the selected part: selecting the elbow housing or the forearm\n shows the elbow's one fan, not a smaller one for the smaller part (user, 2026-09-24).\n */\n const radius = Math.max(60, Math.round(Math.max(largestMeasureOf(asset, turn.turnedPart, inputs), Math.hypot(...inPlane)) * 0.6))\n const edge = turn.pivot.map((v, i) => v + d[i]! * radius)\n\n const { min, max } = turn.control\n if (!(max > min)) return null\n const steps = Math.max(2, Math.ceil((max - min) / STEP_DEG))\n const pivot = apply(carrierNow, turn.pivot)\n const traced: number[][] = []\n try {\n for (let i = 0; i <= steps; i++) {\n const s = min + ((max - min) * i) / steps\n traced.push(apply(at({ [turn.control.id]: s })[carrierRef] as Pose, edge))\n }\n } catch {\n return null\n }\n\n /* The fan's own frame: x toward the first traced point, y along the axis as it stands now, z completing them. */\n const axisNow = norm([0, 1, 2].map(i => dot(carrierNow.r[i]!, turn.axis)))\n const first = norm(sub(traced[0]!, pivot))\n if (!axisNow || !first) return null\n const zAxis = cross(first, axisNow)\n const r = [0, 1, 2].map(i => [first[i]!, axisNow[i]!, zAxis[i]!])\n const local = (p: number[]) => {\n const v = sub(p, pivot)\n return { x: dot(v, first), z: dot(v, zAxis) }\n }\n const full = max - min >= 359.999\n const profile = [...(full ? [] : [{ x: 0, z: 0 }]), ...traced.map(local)].map(p => ({ x: Math.round(p.x * 1000) / 1000, z: Math.round(p.z * 1000) / 1000 }))\n\n return {\n id: JOINT_FAN,\n shape: sectionShape(profile, THICKNESS),\n pose: { t: pivot, r },\n material: { token: '__joint-fan', transparent: true },\n /** Which control turns it: the joint the fan shows. */\n turns: turn.control.id\n } as unknown as FigureRenderPart\n}\n\n/** The values in hand that belong to a record's keys (design inputs, or state defaults). */\nfunction pick(values: Record<string, number>, of: Record<string, number>): Record<string, number> {\n return Object.fromEntries(Object.entries(values).filter(([id]) => id in of))\n}\n\n/** A part's largest own measure (a box side, a diameter, a length) at the inputs given; 0 when it cannot be read. */\nfunction largestMeasureOf(asset: FigureAsset, part: string, inputs: Record<string, number>): number {\n try {\n const body = compileFigureAsset({ ...asset, designInputs: pick(inputs, asset.designInputs), stateDefaults: pick(inputs, asset.stateDefaults) })\n .evaluate()\n .geometry.find(g => g.id === part) as { shape?: { dimensions?: Record<string, number> } } | undefined\n const dims = Object.entries(body?.shape?.dimensions ?? {}).map(([k, v]) => (k.startsWith('radius') ? v * 2 : v))\n return dims.length ? Math.max(...dims) : 0\n } catch {\n return 0\n }\n}\n\n/** Whether the line through `at` along `along` passes through the box (centre, half-measures), within the skin. */\nfunction lineMeetsBox(at: number[], along: number[], centre: number[], half: number[]): boolean {\n let lo = -Infinity,\n hi = Infinity\n for (let i = 0; i < 3; i++) {\n const min = centre[i]! - half[i]! - SEAM,\n max = centre[i]! + half[i]! + SEAM\n if (Math.abs(along[i]!) < 1e-12) {\n if (at[i]! < min || at[i]! > max) return false\n continue\n }\n const t1 = (min - at[i]!) / along[i]!,\n t2 = (max - at[i]!) / along[i]!\n lo = Math.max(lo, Math.min(t1, t2))\n hi = Math.min(hi, Math.max(t1, t2))\n if (lo > hi) return false\n }\n return true\n}\n\n"]}
|
|
@@ -252,7 +252,10 @@ export declare function leadersFor(asset: FigureAsset, part: string, kind: Motio
|
|
|
252
252
|
export declare function motionJoint(joint: FigureJoint, m: MotionForm, part: string): FigureJoint;
|
|
253
253
|
/** The select's value for what a dimension follows now. */
|
|
254
254
|
export declare function choiceOf(follow: Follow): string;
|
|
255
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* The faces a place can sit on for this part: its flat faces, but not a plane that only touches a curved side along a
|
|
257
|
+
* line (a cylinder's side, Q3) -- nothing is held on a line. A sphere has none.
|
|
258
|
+
*/
|
|
256
259
|
export declare function placeFacesOf(asset: FigureAsset, part: string): FigureFace[];
|
|
257
260
|
/** The places things are held that sit on this part. */
|
|
258
261
|
export declare function placesOn(asset: FigureAsset, part: string): FigureBindingPlace[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FIGURE_FACES, figureShapeFaces, figurePartsExtentOf, compileFigureAsset, compileFigureGraph, figureFollowOf, proposeFigureProportion, defaultInstanceSizeRange, foldInstanceSizeRange, figureAttachmentsOf, figureBindingsOf, figureInstanceSizeLimitsOf, figureFollowableAxesOf, figureShapeProviderOf } from '@hatiolab/figure-model';
|
|
2
|
+
import { startingShapeKindOf } from './starting-shape.js';
|
|
2
3
|
export const AXES = ['x', 'y', 'z'];
|
|
3
4
|
const modelOf = (asset) => asset.document.model;
|
|
4
5
|
/**
|
|
@@ -38,7 +39,7 @@ export function canFollow(asset, part) {
|
|
|
38
39
|
*/
|
|
39
40
|
export function followableAxes(asset, part) {
|
|
40
41
|
const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`);
|
|
41
|
-
return shape ? figureFollowableAxesOf(shape
|
|
42
|
+
return shape ? figureFollowableAxesOf(shape) : [];
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* The directions "follow the size, attached" passes to figure-model (designer 2026-09-27):
|
|
@@ -62,26 +63,14 @@ export function resizeAxesOf(asset, part, pending) {
|
|
|
62
63
|
return { axes: following, basis: 'chosen' };
|
|
63
64
|
return { axes: editable, basis: editable.length ? 'suggested' : 'none' };
|
|
64
65
|
}
|
|
65
|
-
const KIND_OF_SHAPE = {
|
|
66
|
-
'box-shape@1': 'cube',
|
|
67
|
-
'rounded-box@1': 'rounded-box',
|
|
68
|
-
'rounded-box@2': 'rounded-box',
|
|
69
|
-
'hollow-box@1': 'hollow-box',
|
|
70
|
-
'hollow-box@2': 'hollow-box',
|
|
71
|
-
'portal-profile@2': 'portal',
|
|
72
|
-
'cylinder-shape@1': 'cylinder',
|
|
73
|
-
'cylinder-shape@2': 'cylinder',
|
|
74
|
-
'sphere-shape@1': 'sphere',
|
|
75
|
-
'frustum-shape@1': 'frustum',
|
|
76
|
-
'polygon-shape@1': 'polygon'
|
|
77
|
-
};
|
|
78
66
|
/**
|
|
79
67
|
* The selected part in three short lines, for the head of its panel (designer 2026-09-27, B): what it is, how its
|
|
80
68
|
* size answers the figure's, and what holds it -- 「box · 상자 / 너비는 도형을 따라감 / 아랫면을 바닥에 유지 중」.
|
|
81
69
|
*/
|
|
82
70
|
export function partSummaryOf(asset, part, say) {
|
|
83
71
|
const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`);
|
|
84
|
-
const
|
|
72
|
+
const named = startingShapeKindOf(shape);
|
|
73
|
+
const kind = named ? say(`figure.label.primitive-${named}`) : '';
|
|
85
74
|
const editable = followableAxes(asset, part);
|
|
86
75
|
const round = editable.length === 2;
|
|
87
76
|
const word = (axis) => say(round && axis === 'x' ? 'figure.label.resize-diameter' : `figure.label.resize-${axis}`);
|
|
@@ -119,7 +108,10 @@ export function fieldWordsOf(id, say) {
|
|
|
119
108
|
/** What a part's own measure on an axis is now (a box's side, a cylinder's radius or length), at the design as it stands. */
|
|
120
109
|
export function dimensionNow(asset, part, axis) {
|
|
121
110
|
const m = modelOf(asset);
|
|
122
|
-
|
|
111
|
+
/* The argument the shape names for this axis (figure-model's provider), not its place among the arguments. */
|
|
112
|
+
const shape = m.nodes.find(n => n.id === `${part}.shape`);
|
|
113
|
+
const edit = shape && figureShapeProviderOf(shape)?.edit[axis];
|
|
114
|
+
const ref = edit && !('refused' in edit) ? shape.args[edit.arg] : undefined;
|
|
123
115
|
if (!ref)
|
|
124
116
|
return undefined;
|
|
125
117
|
try {
|
|
@@ -137,7 +129,7 @@ export function dimensionNow(asset, part, axis) {
|
|
|
137
129
|
*/
|
|
138
130
|
export function measureNow(asset, part, axis) {
|
|
139
131
|
const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`);
|
|
140
|
-
const edit = shape && figureShapeProviderOf(shape
|
|
132
|
+
const edit = shape && figureShapeProviderOf(shape)?.edit[axis];
|
|
141
133
|
if (!shape || !edit || 'refused' in edit)
|
|
142
134
|
return undefined;
|
|
143
135
|
try {
|
|
@@ -155,12 +147,18 @@ export function measureNow(asset, part, axis) {
|
|
|
155
147
|
*/
|
|
156
148
|
export function facesOf(asset, part) {
|
|
157
149
|
const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`);
|
|
158
|
-
return Object.keys((shape && figureShapeFaces(shape
|
|
150
|
+
return inScreenOrder(Object.keys((shape && figureShapeFaces(shape)) ?? {}));
|
|
151
|
+
}
|
|
152
|
+
/** Faces in the order the screen lists them: the six outer ones left to front, then the rest as the shape gives them. */
|
|
153
|
+
const SCREEN_ORDER = ['left', 'right', 'bottom', 'top', 'back', 'front'];
|
|
154
|
+
function inScreenOrder(names) {
|
|
155
|
+
const rank = (n) => (SCREEN_ORDER.includes(n) ? SCREEN_ORDER.indexOf(n) : SCREEN_ORDER.length);
|
|
156
|
+
return names.map((n, i) => [n, i]).sort((a, b) => rank(a[0]) - rank(b[0]) || a[1] - b[1]).map(([n]) => n);
|
|
159
157
|
}
|
|
160
158
|
/** The axis a face of a part faces along, from the same definitions. */
|
|
161
159
|
export function faceAxisOf(asset, part, face) {
|
|
162
160
|
const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`);
|
|
163
|
-
return (shape && figureShapeFaces(shape
|
|
161
|
+
return (shape && figureShapeFaces(shape)?.[face]?.axis);
|
|
164
162
|
}
|
|
165
163
|
/** Whether `attach` can take this part: any part whose shape has a flat face. */
|
|
166
164
|
export function canFasten(asset, part) {
|
|
@@ -472,14 +470,14 @@ export function choiceOf(follow) {
|
|
|
472
470
|
return 'expression';
|
|
473
471
|
}
|
|
474
472
|
}
|
|
475
|
-
/**
|
|
473
|
+
/**
|
|
474
|
+
* The faces a place can sit on for this part: its flat faces, but not a plane that only touches a curved side along a
|
|
475
|
+
* line (a cylinder's side, Q3) -- nothing is held on a line. A sphere has none.
|
|
476
|
+
*/
|
|
476
477
|
export function placeFacesOf(asset, part) {
|
|
477
478
|
const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`);
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
if (shape?.op === 'rounded-box@1')
|
|
481
|
-
return ['bottom', 'top'];
|
|
482
|
-
return [];
|
|
479
|
+
const faces = (shape && figureShapeFaces(shape)) ?? {};
|
|
480
|
+
return inScreenOrder(Object.entries(faces).filter(([, f]) => !f.contact).map(([name]) => name));
|
|
483
481
|
}
|
|
484
482
|
/** The places things are held that sit on this part. */
|
|
485
483
|
export function placesOn(asset, part) {
|