@things-factory/figure-ui 10.1.46 → 10.1.48

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 (148) hide show
  1. package/client/modeller/angle-dial.ts +70 -0
  2. package/client/modeller/figure-settings.ts +328 -0
  3. package/client/modeller/figure-v3-capability.ts +137 -0
  4. package/client/modeller/figure-v3-clips.ts +253 -0
  5. package/client/modeller/figure-v3-controls.ts +212 -0
  6. package/client/modeller/figure-v3-links.ts +61 -81
  7. package/client/modeller/figure-v3-material.ts +108 -35
  8. package/client/modeller/figure-v3-parts.ts +96 -3
  9. package/client/modeller/figure-v3-preview.ts +326 -0
  10. package/client/modeller/figure-v3-properties.ts +29 -57
  11. package/client/modeller/figure-v3-verdict.ts +598 -60
  12. package/client/modeller/figure-view.ts +152 -0
  13. package/client/modeller/side-panel-styles.ts +326 -0
  14. package/client/modeller/v3-canvas.ts +254 -262
  15. package/client/modeller/v3-clips.ts +89 -0
  16. package/client/modeller/v3-controls.ts +54 -0
  17. package/client/modeller/v3-editor.ts +566 -223
  18. package/client/modeller/v3-fields.ts +84 -0
  19. package/client/modeller/v3-help.ts +41 -0
  20. package/client/modeller/v3-joint-fan.ts +292 -0
  21. package/client/modeller/v3-keys.ts +34 -0
  22. package/client/modeller/v3-links.ts +101 -9
  23. package/client/modeller/v3-live.ts +79 -0
  24. package/client/modeller/v3-maturity.ts +415 -0
  25. package/client/modeller/v3-palette.ts +45 -0
  26. package/client/modeller/v3-preview-model.ts +54 -0
  27. package/client/modeller/v3-stage-model.ts +159 -0
  28. package/client/modeller/v3-thumbnail.ts +8 -4
  29. package/client/pages/figure-list-page.ts +4 -4
  30. package/client/pages/figure-v3-modeller-page.ts +66 -134
  31. package/dist-client/modeller/angle-dial.d.ts +32 -0
  32. package/dist-client/modeller/angle-dial.js +41 -0
  33. package/dist-client/modeller/angle-dial.js.map +1 -0
  34. package/dist-client/modeller/figure-settings.d.ts +39 -0
  35. package/dist-client/modeller/figure-settings.js +317 -0
  36. package/dist-client/modeller/figure-settings.js.map +1 -0
  37. package/dist-client/modeller/figure-v3-capability.d.ts +22 -0
  38. package/dist-client/modeller/figure-v3-capability.js +141 -0
  39. package/dist-client/modeller/figure-v3-capability.js.map +1 -0
  40. package/dist-client/modeller/figure-v3-clips.d.ts +31 -0
  41. package/dist-client/modeller/figure-v3-clips.js +268 -0
  42. package/dist-client/modeller/figure-v3-clips.js.map +1 -0
  43. package/dist-client/modeller/figure-v3-controls.d.ts +36 -0
  44. package/dist-client/modeller/figure-v3-controls.js +226 -0
  45. package/dist-client/modeller/figure-v3-controls.js.map +1 -0
  46. package/dist-client/modeller/figure-v3-links.d.ts +4 -1
  47. package/dist-client/modeller/figure-v3-links.js +64 -82
  48. package/dist-client/modeller/figure-v3-links.js.map +1 -1
  49. package/dist-client/modeller/figure-v3-material.d.ts +4 -1
  50. package/dist-client/modeller/figure-v3-material.js +109 -35
  51. package/dist-client/modeller/figure-v3-material.js.map +1 -1
  52. package/dist-client/modeller/figure-v3-parts.d.ts +10 -0
  53. package/dist-client/modeller/figure-v3-parts.js +88 -3
  54. package/dist-client/modeller/figure-v3-parts.js.map +1 -1
  55. package/dist-client/modeller/figure-v3-preview.d.ts +34 -0
  56. package/dist-client/modeller/figure-v3-preview.js +322 -0
  57. package/dist-client/modeller/figure-v3-preview.js.map +1 -0
  58. package/dist-client/modeller/figure-v3-properties.d.ts +1 -1
  59. package/dist-client/modeller/figure-v3-properties.js +29 -57
  60. package/dist-client/modeller/figure-v3-properties.js.map +1 -1
  61. package/dist-client/modeller/figure-v3-verdict.d.ts +31 -17
  62. package/dist-client/modeller/figure-v3-verdict.js +579 -59
  63. package/dist-client/modeller/figure-v3-verdict.js.map +1 -1
  64. package/dist-client/modeller/figure-view.d.ts +118 -0
  65. package/dist-client/modeller/figure-view.js +78 -0
  66. package/dist-client/modeller/figure-view.js.map +1 -0
  67. package/dist-client/modeller/side-panel-styles.d.ts +23 -0
  68. package/dist-client/modeller/side-panel-styles.js +326 -0
  69. package/dist-client/modeller/side-panel-styles.js.map +1 -0
  70. package/dist-client/modeller/v3-canvas.d.ts +44 -37
  71. package/dist-client/modeller/v3-canvas.js +230 -260
  72. package/dist-client/modeller/v3-canvas.js.map +1 -1
  73. package/dist-client/modeller/v3-clips.d.ts +39 -0
  74. package/dist-client/modeller/v3-clips.js +58 -0
  75. package/dist-client/modeller/v3-clips.js.map +1 -0
  76. package/dist-client/modeller/v3-controls.d.ts +28 -0
  77. package/dist-client/modeller/v3-controls.js +28 -0
  78. package/dist-client/modeller/v3-controls.js.map +1 -0
  79. package/dist-client/modeller/v3-editor.d.ts +73 -1
  80. package/dist-client/modeller/v3-editor.js +593 -218
  81. package/dist-client/modeller/v3-editor.js.map +1 -1
  82. package/dist-client/modeller/v3-fields.d.ts +39 -0
  83. package/dist-client/modeller/v3-fields.js +69 -0
  84. package/dist-client/modeller/v3-fields.js.map +1 -0
  85. package/dist-client/modeller/v3-help.d.ts +18 -0
  86. package/dist-client/modeller/v3-help.js +37 -0
  87. package/dist-client/modeller/v3-help.js.map +1 -0
  88. package/dist-client/modeller/v3-joint-fan.d.ts +9 -0
  89. package/dist-client/modeller/v3-joint-fan.js +264 -0
  90. package/dist-client/modeller/v3-joint-fan.js.map +1 -0
  91. package/dist-client/modeller/v3-keys.d.ts +14 -0
  92. package/dist-client/modeller/v3-keys.js +23 -0
  93. package/dist-client/modeller/v3-keys.js.map +1 -0
  94. package/dist-client/modeller/v3-links.d.ts +35 -1
  95. package/dist-client/modeller/v3-links.js +101 -8
  96. package/dist-client/modeller/v3-links.js.map +1 -1
  97. package/dist-client/modeller/v3-live.d.ts +31 -0
  98. package/dist-client/modeller/v3-live.js +58 -0
  99. package/dist-client/modeller/v3-live.js.map +1 -0
  100. package/dist-client/modeller/v3-maturity.d.ts +120 -0
  101. package/dist-client/modeller/v3-maturity.js +317 -0
  102. package/dist-client/modeller/v3-maturity.js.map +1 -0
  103. package/dist-client/modeller/v3-palette.d.ts +7 -0
  104. package/dist-client/modeller/v3-palette.js +42 -0
  105. package/dist-client/modeller/v3-palette.js.map +1 -0
  106. package/dist-client/modeller/v3-preview-model.d.ts +32 -0
  107. package/dist-client/modeller/v3-preview-model.js +48 -0
  108. package/dist-client/modeller/v3-preview-model.js.map +1 -0
  109. package/dist-client/modeller/v3-stage-model.d.ts +31 -0
  110. package/dist-client/modeller/v3-stage-model.js +121 -0
  111. package/dist-client/modeller/v3-stage-model.js.map +1 -0
  112. package/dist-client/modeller/v3-thumbnail.js +6 -3
  113. package/dist-client/modeller/v3-thumbnail.js.map +1 -1
  114. package/dist-client/pages/figure-list-page.js +4 -4
  115. package/dist-client/pages/figure-list-page.js.map +1 -1
  116. package/dist-client/pages/figure-v3-modeller-page.d.ts +2 -6
  117. package/dist-client/pages/figure-v3-modeller-page.js +64 -136
  118. package/dist-client/pages/figure-v3-modeller-page.js.map +1 -1
  119. package/dist-client/tsconfig.chk.tsbuildinfo +1 -0
  120. package/dist-client/tsconfig.scratch-fm.tsbuildinfo +1 -1
  121. package/dist-client/tsconfig.tsbuildinfo +1 -1
  122. package/package.json +6 -6
  123. package/test/v3-clips.test.ts +70 -0
  124. package/test/v3-controls.test.ts +68 -0
  125. package/test/v3-fields.test.ts +71 -0
  126. package/test/v3-gizmo.test.ts +3 -5
  127. package/test/v3-joint-fan.test.ts +210 -0
  128. package/test/v3-keys.test.ts +37 -0
  129. package/test/v3-layout.test.ts +78 -0
  130. package/test/v3-links.test.ts +89 -6
  131. package/test/v3-live.test.ts +99 -0
  132. package/test/v3-material.test.ts +6 -0
  133. package/test/v3-maturity.test.ts +268 -0
  134. package/test/v3-palette-icons.test.ts +22 -0
  135. package/test/v3-parts-wiring.test.ts +3 -1
  136. package/test/v3-preview.test.ts +42 -0
  137. package/test/v3-properties.test.ts +4 -2
  138. package/test/v3-scene-canvas.test.ts +85 -0
  139. package/test/v3-stage-model.test.ts +25 -0
  140. package/test/v3-theme.test.ts +16 -25
  141. package/test/v3-thumbnail.test.ts +29 -0
  142. package/test/v3-verdict.test.ts +12 -6
  143. package/test/v3-view.test.ts +20 -0
  144. package/translations/en.json +90 -6
  145. package/translations/ja.json +92 -8
  146. package/translations/ko.json +90 -6
  147. package/translations/ms.json +92 -8
  148. package/translations/zh.json +92 -8
@@ -1 +1 @@
1
- {"version":3,"file":"v3-links.js","sourceRoot":"","sources":["../../client/modeller/v3-links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAStE,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAQpD,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,EAAE,CACjC,KAAK,CAAC,QAAQ,CAAC,KAA+K,CAAA;AAWhM;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,IAAY,EAAE,IAAU;IAC/D,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IACxB,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,cAAc,IAAI,EAAE,CAAC,CAAA;IACpE,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAA;IAC/B,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3F,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,MAAM,IAAI,GAAG,CAAC,GAAW,EAAU,EAAE;QACnC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,EAAE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AK,UAAU,CAAC,CAAA;AAExI,iGAAiG;AACjG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { v3AttachmentsOf, v3BindingsOf } from '@hatiolab/figure-model'\nimport type { V3Asset, V3BindingPlace, V3Face } from '@hatiolab/figure-model'\n\n/*\n * What a V3 part is tied to — the readers behind the parts' size response, fastening and motion sections (parity rows\n * ④ ⑤ ⑥). Kept apart from the element so they can be tested without a browser.\n */\n\nexport type Axis = 'x' | 'y' | 'z'\nexport const AXES: readonly Axis[] = ['x', 'y', 'z']\n\ninterface Node {\n id: string\n op: string\n args: string[]\n outputs: Record<string, string>\n}\nconst modelOf = (asset: V3Asset) =>\n asset.document.model as unknown as { nodes: Node[]; inputs: Array<{ id: string; role?: string; unit?: string; min?: number; max?: number }>; constants: Array<{ id: string; value: number }> }\n\n/** What one dimension of a part is worked out from. */\nexport type Follow =\n | { of: 'own' }\n | { of: 'instance'; axis: Axis }\n | { of: 'part'; part: string; axis: Axis }\n | { of: 'input'; input: string }\n /** Worked out some other way (the converter writes expressions) — shown, not offered as a choice. */\n | { of: 'expression' }\n\n/**\n * `link-dimension` routes a part's dimension through `<part>.dimension.<axis>` and points its first argument at the\n * source, directly or through the nodes that scale it. Walking back through those nodes finds the source: the\n * instance size (`size.<axis>`), another part's dimension (`<part>.dimension.<axis>.value`) or a declared input.\n */\nexport function followOf(asset: V3Asset, part: string, axis: Axis): Follow {\n const m = modelOf(asset)\n const node = m.nodes.find(n => n.id === `${part}.dimension.${axis}`)\n if (!node) return { of: 'own' }\n const writerOf = (ref: string) => m.nodes.find(n => Object.values(n.outputs).includes(ref))\n const seen = new Set<string>()\n const walk = (ref: string): Follow => {\n if (seen.has(ref)) return { of: 'expression' }\n seen.add(ref)\n const instance = /^size\\.([xyz])$/.exec(ref)\n if (instance) return { of: 'instance', axis: instance[1] as Axis }\n const other = /^(.+)\\.dimension\\.([xyz])\\.value$/.exec(ref)\n if (other) return { of: 'part', part: other[1]!, axis: other[2] as Axis }\n const input = m.inputs.find(i => i.id === ref)\n if (input) return ref.startsWith(`${part}.`) ? { of: 'own' } : { of: 'input', input: ref }\n const writer = writerOf(ref)\n if (!writer) return { of: 'expression' }\n /* Follow the one argument that is not a constant factor. */\n const onward = writer.args.filter(arg => !m.constants.some(c => c.id === arg))\n return onward.length === 1 ? walk(onward[0]!) : { of: 'expression' }\n }\n return walk(node.args[0]!)\n}\n\n/** Whether the asset declares an instance size on an axis — only then can a dimension follow it. */\nexport const hasInstanceSize = (asset: V3Asset, axis: Axis) => modelOf(asset).inputs.some(i => i.id === `size.${axis}` && i.role === 'design')\n\n/** The part this one is fastened to, or `null`. The mounting plane counts as fastened (the model names no part). */\nexport function fastenedTo(asset: V3Asset, part: string): string | null {\n return v3AttachmentsOf(asset)[part] ?? null\n}\n\n/** Whether a dimension of this part can follow something — box-shaped, whose three sizes are X, Y and Z. */\nexport function canFollow(asset: V3Asset, part: string): boolean {\n const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`)\n return !!shape && (shape.op === 'box-shape@1' || shape.op === 'rounded-box@1')\n}\n\n/** Whether `attach` can take this part: a box, or a cylinder (figure-model measures its faces since 0.1.47). */\nexport function canFasten(asset: V3Asset, part: string): boolean {\n const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`)\n return canFollow(asset, part) || shape?.op === 'cylinder-shape@1'\n}\n\n/**\n * The axes on which the part's position is worked out from other values rather than being its own number — the\n * converter writes V2's anchor rules that way. `fix-position` makes one its own number where it is now.\n */\nexport function positionsWorkedOut(asset: V3Asset, part: string): Axis[] {\n const m = modelOf(asset)\n const pose = m.nodes.find(n => n.id === `${part}.pose`)\n if (!pose || pose.op !== 'rigid@1' || fastenedTo(asset, part)) return []\n const own = (ref: string) => ref.startsWith(`${part}.`) && m.inputs.some(i => i.id === ref && i.role === 'design')\n const constant = (ref: string) => m.constants.some(c => c.id === ref)\n return AXES.filter((_axis, i) => !own(pose.args[i]!) && !constant(pose.args[i]!))\n}\n\n/** How a part moves, if it does: slide or turn, along which axis, driven by which control. */\nexport interface Motion {\n kind: 'slide' | 'turn'\n axis: Axis | '?'\n control?: { id: string; unit?: string; min?: number; max?: number }\n}\n\nexport function motionOf(asset: V3Asset, part: string): Motion | undefined {\n const m = modelOf(asset)\n const node = m.nodes.find(n => n.id === `${part}.motion`)\n if (!node) return undefined\n const kind = node.op === 'axis-turn@1' ? 'turn' : 'slide'\n const unit = node.args.slice(0, 3).map(ref => m.constants.find(c => c.id === ref)?.value)\n const axis = AXES[unit.findIndex(v => v !== undefined && v !== 0)] ?? '?'\n /* The quantity is the fourth argument, a state input directly or through the nodes that scale it. */\n const quantity = node.args[3]\n const seen = new Set<string>()\n const control = (ref?: string): Motion['control'] => {\n if (!ref || seen.has(ref)) return undefined\n seen.add(ref)\n const input = m.inputs.find(i => i.id === ref && i.role === 'state')\n if (input) return { id: input.id, unit: input.unit, min: input.min, max: input.max }\n const writer = m.nodes.find(n => Object.values(n.outputs).includes(ref))\n for (const arg of writer?.args ?? []) {\n const found = control(arg)\n if (found) return found\n }\n return undefined\n }\n return { kind, axis, control: control(quantity) }\n}\n\n/** The select's value for what a dimension follows now. */\nexport function choiceOf(follow: Follow): string {\n switch (follow.of) {\n case 'own':\n return 'own'\n case 'instance':\n return `instance:${follow.axis}`\n case 'part':\n return `part:${follow.part}:${follow.axis}`\n case 'input':\n return `input:${follow.input}`\n case 'expression':\n return 'expression'\n }\n}\n\n/** The faces a place can sit on for this part: a box's six, a rounded box's top and bottom, none for a round body. */\nexport function placeFacesOf(asset: V3Asset, part: string): V3Face[] {\n const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`)\n if (shape?.op === 'box-shape@1') return ['left', 'right', 'bottom', 'top', 'back', 'front']\n if (shape?.op === 'rounded-box@1') return ['bottom', 'top']\n return []\n}\n\n/** The places things are held that sit on this part. */\nexport function placesOn(asset: V3Asset, part: string): V3BindingPlace[] {\n return v3BindingsOf(asset).filter(one => one.part === part)\n}\n\n/** An id for a new place on this part, not yet taken: `<part>-<role>`, then `-2`, `-3`. */\nexport function placeIdFor(asset: V3Asset, part: string, role: 'seat' | 'grip'): string {\n const taken = new Set(asset.document.capabilities.bindings.map(b => b.id))\n const base = `${part}-${role}`\n if (!taken.has(base)) return base\n let n = 2\n while (taken.has(`${base}-${n}`)) n++\n return `${base}-${n}`\n}\n\n/**\n * Whether a board will hand this figure anything: a place is a slot only on a figure that declares it holds things\n * (`Capacity`, or `FlowNode`, which includes it). Without it the places are declared and nothing arrives.\n */\nexport const holdsThings = (asset: V3Asset) => (asset.document.capabilities.names ?? []).some(n => n === 'Capacity' || n === 'FlowNode')\n\n/** What `accepts` a person typed: names split on commas, trimmed, blanks and repeats dropped. */\nexport const acceptsOf = (typed: string) => [...new Set(typed.split(',').map(one => one.trim()).filter(Boolean))]\n"]}
1
+ {"version":3,"file":"v3-links.js","sourceRoot":"","sources":["../../client/modeller/v3-links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,eAAe,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAU/J,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAQpD,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,EAAE,CACjC,KAAK,CAAC,QAAQ,CAAC,KAA+K,CAAA;AAYhM;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,IAAY,EAAE,IAAU;IAC/D,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IACxB;;;MA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,OAAO,EAAE,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAA;QACtD,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,QAAQ,EAAE,CAAA;QACpE,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;IACrB,CAAC;IACD,MAAM,KAAK,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAA;IAChD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,EAAE,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;IACzF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;AAC/B,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,CAAc,EAAE,CAAc;IACzD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AACpH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,aAAa,CAAC,CAAA;AAC/D,CAAC","sourcesContent":["import { compileV3Graph, defaultInstanceSizeRange, foldInstanceSizeRange, v3AttachmentsOf, v3BindingsOf, v3InstanceSizeLimitsOf } from '@hatiolab/figure-model'\nimport type { V3SizeRange } from '@hatiolab/figure-model'\nimport type { V3Asset, V3BindingPlace, V3Face } from '@hatiolab/figure-model'\n\n/*\n * What a V3 part is tied to — the readers behind the parts' size response, fastening and motion sections (parity rows\n * ④ ⑤ ⑥). Kept apart from the element so they can be tested without a browser.\n */\n\nexport type Axis = 'x' | 'y' | 'z'\nexport const AXES: readonly Axis[] = ['x', 'y', 'z']\n\ninterface Node {\n id: string\n op: string\n args: string[]\n outputs: Record<string, string>\n}\nconst modelOf = (asset: V3Asset) =>\n asset.document.model as unknown as { nodes: Node[]; inputs: Array<{ id: string; role?: string; unit?: string; min?: number; max?: number }>; constants: Array<{ id: string; value: number }> }\n\n/** What one dimension of a part is worked out from. */\nexport type Follow =\n | { of: 'own' }\n /** `times` 1 is the instance size itself; any other is a share of it -- V2's proportional rule. */\n | { of: 'instance'; axis: Axis; times: number }\n | { of: 'part'; part: string; axis: Axis }\n | { of: 'input'; input: string }\n /** Worked out some other way (the converter writes expressions) — shown, not offered as a choice. */\n | { of: 'expression' }\n\n/**\n * `link-dimension` routes a part's dimension through `<part>.dimension.<axis>` and points its first argument at the\n * source, directly or through the nodes that scale it. Walking back through those nodes finds the source: the\n * instance size (`size.<axis>`), another part's dimension (`<part>.dimension.<axis>.value`) or a declared input.\n */\nexport function followOf(asset: V3Asset, part: string, axis: Axis): Follow {\n const m = modelOf(asset)\n /*\n A link routes the dimension through `<part>.dimension.<axis>`; before any link the shape reads its measure directly,\n and that may already be worked out -- the converter writes V2's rules there (ROBOT_ARM's flange filled what was left).\n */\n const node = m.nodes.find(n => n.id === `${part}.dimension.${axis}`)\n const start = node ? node.args[0] : m.nodes.find(n => n.id === `${part}.shape`)?.args[AXES.indexOf(axis)]\n if (!start || m.constants.some(c => c.id === start)) return { of: 'own' }\n const writerOf = (ref: string) => m.nodes.find(n => Object.values(n.outputs).includes(ref))\n const seen = new Set<string>()\n const constant = (ref: string) => m.constants.find(c => c.id === ref)\n /* The constant factors met on the way back: a share of the instance size is `size × share`. */\n let times = 1\n const walk = (ref: string): Follow => {\n if (seen.has(ref)) return { of: 'expression' }\n seen.add(ref)\n const instance = /^size\\.([xyz])$/.exec(ref)\n if (instance) return { of: 'instance', axis: instance[1] as Axis, times: Math.round(times * 1e6) / 1e6 }\n const other = /^(.+)\\.dimension\\.([xyz])\\.value$/.exec(ref)\n if (other) return { of: 'part', part: other[1]!, axis: other[2] as Axis }\n const input = m.inputs.find(i => i.id === ref)\n if (input) return ref.startsWith(`${part}.`) ? { of: 'own' } : { of: 'input', input: ref }\n const writer = writerOf(ref)\n if (!writer) return { of: 'expression' }\n /* Follow the one argument that is not a constant factor. */\n const onward = writer.args.filter(arg => !constant(arg))\n if (onward.length !== 1) return { of: 'expression' }\n /*\n Only a product is a share of its source. A sum with a number is not (V2's 「fill what is left」 is the size plus a\n negative gap -- ROBOT_ARM's tool flange), nor anything else; those read as worked out some other way.\n */\n const factors = writer.args.filter(arg => constant(arg)).map(arg => constant(arg)!.value)\n if (writer.op === 'mul@1') times *= factors.reduce((a, b) => a * b, 1)\n else if (writer.op === 'div@1' && writer.args[0] === onward[0] && factors.length === 1 && factors[0] !== 0) times /= factors[0]!\n else if (factors.some(v => v !== 0) || !['mul@1', 'div@1', 'add@1', 'sub@1'].includes(writer.op)) return { of: 'expression' }\n return walk(onward[0]!)\n }\n return walk(start)\n}\n\n/** Whether the asset declares an instance size on an axis — only then can a dimension follow it. */\nexport const hasInstanceSize = (asset: V3Asset, axis: Axis) => modelOf(asset).inputs.some(i => i.id === `size.${axis}` && i.role === 'design')\n\n/** The part this one is fastened to, or `null`. The mounting plane counts as fastened (the model names no part). */\nexport function fastenedTo(asset: V3Asset, part: string): string | null {\n return v3AttachmentsOf(asset)[part] ?? null\n}\n\n/** Whether a dimension of this part can follow something — box-shaped, whose three sizes are X, Y and Z. */\nexport function canFollow(asset: V3Asset, part: string): boolean {\n return followableAxes(asset, part).length > 0\n}\n\n/**\n * The axes whose size can follow something, by the shape's own measures: a box's X · Y · Z; a cylinder's radius (read\n * as X) and length (Y) -- its shape takes those two, so it has no Z of its own (V2's sizing cards had the cylinder's\n * two as well).\n */\nexport function followableAxes(asset: V3Asset, part: string): Axis[] {\n const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`)\n if (!shape) return []\n if (shape.op === 'box-shape@1' || shape.op === 'rounded-box@1') return [...AXES]\n if (shape.op === 'cylinder-shape@1') return ['x', 'y']\n return []\n}\n\n/** 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. */\nexport function dimensionNow(asset: V3Asset, part: string, axis: Axis): number | undefined {\n const m = modelOf(asset)\n const ref = m.nodes.find(n => n.id === `${part}.shape`)?.args[AXES.indexOf(axis)]\n if (!ref) return undefined\n try {\n const values = compileV3Graph(asset.document.model as never).evaluate({ ...asset.designInputs, ...asset.stateDefaults }).values as Record<string, number>\n const value = values[ref]\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined\n } catch {\n return undefined\n }\n}\n\n/** Whether `attach` can take this part: a box, or a cylinder (figure-model measures its faces since 0.1.47). */\nexport function canFasten(asset: V3Asset, part: string): boolean {\n const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`)\n return canFollow(asset, part) || shape?.op === 'cylinder-shape@1'\n}\n\n/**\n * The axes on which the part's position is worked out from other values rather than being its own number — the\n * converter writes V2's anchor rules that way. `fix-position` makes one its own number where it is now.\n */\nexport function positionsWorkedOut(asset: V3Asset, part: string): Axis[] {\n const m = modelOf(asset)\n const pose = m.nodes.find(n => n.id === `${part}.pose`)\n if (!pose || pose.op !== 'rigid@1' || fastenedTo(asset, part)) return []\n const own = (ref: string) => ref.startsWith(`${part}.`) && m.inputs.some(i => i.id === ref && i.role === 'design')\n const constant = (ref: string) => m.constants.some(c => c.id === ref)\n return AXES.filter((_axis, i) => !own(pose.args[i]!) && !constant(pose.args[i]!))\n}\n\n/**\n * Whether the part's position on an axis is a share of the instance size (`scale-position`): `size.<axis> × share`.\n * Such a position is worked out too, but it already grows with the figure, so it is not offered again.\n */\nexport function positionIsShare(asset: V3Asset, part: string, axis: Axis): boolean {\n const m = modelOf(asset)\n const ref = m.nodes.find(n => n.id === `${part}.pose`)?.args[AXES.indexOf(axis)]\n const writer = ref ? m.nodes.find(n => Object.values(n.outputs).includes(ref)) : undefined\n return !!writer && writer.op === 'mul@1' && writer.args[0] === `size.${axis}` && m.constants.some(c => c.id === writer.args[1])\n}\n\n/** How a part moves, if it does: slide or turn, along which axis, driven by which control. */\nexport interface Motion {\n kind: 'slide' | 'turn'\n axis: Axis | '?'\n control?: { id: string; unit?: string; min?: number; max?: number }\n}\n\nexport function motionOf(asset: V3Asset, part: string): Motion | undefined {\n const m = modelOf(asset)\n const node = m.nodes.find(n => n.id === `${part}.motion`)\n if (!node) return undefined\n const kind = node.op === 'axis-turn@1' ? 'turn' : 'slide'\n const unit = node.args.slice(0, 3).map(ref => m.constants.find(c => c.id === ref)?.value)\n const axis = AXES[unit.findIndex(v => v !== undefined && v !== 0)] ?? '?'\n /* The quantity is the fourth argument, a state input directly or through the nodes that scale it. */\n const quantity = node.args[3]\n const seen = new Set<string>()\n const control = (ref?: string): Motion['control'] => {\n if (!ref || seen.has(ref)) return undefined\n seen.add(ref)\n const input = m.inputs.find(i => i.id === ref && i.role === 'state')\n if (input) return { id: input.id, unit: input.unit, min: input.min, max: input.max }\n const writer = m.nodes.find(n => Object.values(n.outputs).includes(ref))\n for (const arg of writer?.args ?? []) {\n const found = control(arg)\n if (found) return found\n }\n return undefined\n }\n return { kind, axis, control: control(quantity) }\n}\n\n/** The select's value for what a dimension follows now. */\nexport function choiceOf(follow: Follow): string {\n switch (follow.of) {\n case 'own':\n return 'own'\n case 'instance':\n return follow.times === 1 ? `instance:${follow.axis}` : `share:${follow.axis}`\n case 'part':\n return `part:${follow.part}:${follow.axis}`\n case 'input':\n return `input:${follow.input}`\n case 'expression':\n return 'expression'\n }\n}\n\n/** The faces a place can sit on for this part: a box's six, a rounded box's top and bottom, none for a round body. */\nexport function placeFacesOf(asset: V3Asset, part: string): V3Face[] {\n const shape = modelOf(asset).nodes.find(n => n.id === `${part}.shape`)\n if (shape?.op === 'box-shape@1') return ['left', 'right', 'bottom', 'top', 'back', 'front']\n if (shape?.op === 'rounded-box@1') return ['bottom', 'top']\n return []\n}\n\n/** The places things are held that sit on this part. */\nexport function placesOn(asset: V3Asset, part: string): V3BindingPlace[] {\n return v3BindingsOf(asset).filter(one => one.part === part)\n}\n\n/** An id for a new place on this part, not yet taken: `<part>-<role>`, then `-2`, `-3`. */\nexport function placeIdFor(asset: V3Asset, part: string, role: 'seat' | 'grip'): string {\n const taken = new Set(asset.document.capabilities.bindings.map(b => b.id))\n const base = `${part}-${role}`\n if (!taken.has(base)) return base\n let n = 2\n while (taken.has(`${base}-${n}`)) n++\n return `${base}-${n}`\n}\n\n/**\n * Whether a board will hand this figure anything: a place is a slot only on a figure that declares it holds things\n * (`Capacity`, or `FlowNode`, which includes it). Without it the places are declared and nothing arrives.\n */\nexport const holdsThings = (asset: V3Asset) => (asset.document.capabilities.names ?? []).some(n => n === 'Capacity' || n === 'FlowNode')\n\n/** What `accepts` a person typed: names split on commas, trimmed, blanks and repeats dropped. */\nexport const acceptsOf = (typed: string) => [...new Set(typed.split(',').map(one => one.trim()).filter(Boolean))]\n\n/**\n * The sizes a board may give this figure: the range it declares now, and the range measured afresh -- the default\n * (1 mm to ten times the authored size) narrowed only where the figure cannot follow, by the converter's own functions.\n * A range measured when a part filled what the others left (ROBOT_ARM: Y from 1,854 mm) stays narrow after the part is\n * made to grow with the figure; measuring again gives the figure its whole range back. Nothing when no size is declared.\n */\nexport function instanceRangeOf(asset: V3Asset): { declared: V3SizeRange; measured: V3SizeRange } | undefined {\n const inputs = modelOf(asset).inputs\n const declared = {} as V3SizeRange\n const authored = {} as Record<Axis, number>\n for (const axis of AXES) {\n const input = inputs.find(i => i.id === `size.${axis}` && i.role === 'design')\n const at = asset.designInputs[`size.${axis}`]\n if (!input || typeof at !== 'number') return undefined\n declared[axis] = { min: input.min ?? 0, max: input.max ?? Infinity }\n authored[axis] = at\n }\n const start = defaultInstanceSizeRange(authored)\n const measured = foldInstanceSizeRange(start, v3InstanceSizeLimitsOf(asset, start)).range\n return { declared, measured }\n}\n\n/** Whether measuring again would change the declared range (to a micrometre). */\nexport function rangeDiffers(a: V3SizeRange, b: V3SizeRange): boolean {\n return AXES.some(axis => Math.abs(a[axis].min - b[axis].min) > 1e-3 || Math.abs(a[axis].max - b[axis].max) > 1e-3)\n}\n\n/**\n * Whether the figure is a mechanism -- a part turns about a joint. Such a figure should grow by one ratio (chief\n * architect's ruling 2026-09-24); the modeller proposes it, the author declares it.\n */\nexport function turnsAboutAJoint(asset: V3Asset): boolean {\n return modelOf(asset).nodes.some(n => n.op === 'axis-turn@1')\n}\n\n"]}
@@ -0,0 +1,31 @@
1
+ import type { V3Asset, V3PartEdit } from '@hatiolab/figure-model';
2
+ import { type V3RenderPart } from './v3-renderer.js';
3
+ export interface LiveValues {
4
+ /** Input values in hand, design or state, by input id. */
5
+ values: Record<string, number>;
6
+ /** A part edit in hand, not yet committed. */
7
+ edit?: V3PartEdit;
8
+ }
9
+ export declare const NOTHING_LIVE: LiveValues;
10
+ /** Known inputs with a number, split by what they are. An id the figure does not declare is dropped. */
11
+ export declare function liveOverridesOf(asset: V3Asset, values: Record<string, number>): {
12
+ design: Record<string, number>;
13
+ state: Record<string, number>;
14
+ };
15
+ export declare function isLive(live: LiveValues): boolean;
16
+ /**
17
+ * The bodies to draw with what is in hand, or null when nothing is -- then the evaluation as it stands is drawn.
18
+ *
19
+ * Also null when the figure cannot take the value in hand (a size of 0 on the way to typing 0.5, a glow the material
20
+ * refuses): the canvas keeps the figure as it stands until the release, and the release reports why through the same
21
+ * refusal every committed edit gets. A preview never invents a figure the commit would not make.
22
+ */
23
+ export declare function livePartsOf(asset: V3Asset, live: LiveValues): V3RenderPart[] | null;
24
+ /**
25
+ * How much one pixel of a label drag moves a value: a degree for an angle, a hundredth for a ratio, and for a length a
26
+ * step that suits its size -- a millimetre under 100, ten over 1,000 -- so a 12 m wall and a 5 mm pin both scrub at a
27
+ * usable pace. Shift makes it ten times finer.
28
+ */
29
+ export declare function scrubStep(unit: string, value: number, fine?: boolean): number;
30
+ /** A scrubbed value on the step's grid, so a drag does not leave 1203.0000000002 behind. */
31
+ export declare function scrubbed(start: number, pixels: number, step: number): number;
@@ -0,0 +1,58 @@
1
+ import { compileV3Asset, editV3Part } from '@hatiolab/figure-model';
2
+ import { drawableV3Parts } from './v3-renderer.js';
3
+ export const NOTHING_LIVE = { values: {} };
4
+ /** Known inputs with a number, split by what they are. An id the figure does not declare is dropped. */
5
+ export function liveOverridesOf(asset, values) {
6
+ const roles = new Map(asset.document.model.inputs.map(i => [i.id, i.role]));
7
+ const design = {}, state = {};
8
+ for (const [id, value] of Object.entries(values)) {
9
+ if (!Number.isFinite(value))
10
+ continue;
11
+ const role = roles.get(id);
12
+ if (role === 'state')
13
+ state[id] = value;
14
+ else if (role !== undefined)
15
+ design[id] = value;
16
+ }
17
+ return { design, state };
18
+ }
19
+ export function isLive(live) {
20
+ return !!live.edit || Object.keys(live.values).length > 0;
21
+ }
22
+ /**
23
+ * The bodies to draw with what is in hand, or null when nothing is -- then the evaluation as it stands is drawn.
24
+ *
25
+ * Also null when the figure cannot take the value in hand (a size of 0 on the way to typing 0.5, a glow the material
26
+ * refuses): the canvas keeps the figure as it stands until the release, and the release reports why through the same
27
+ * refusal every committed edit gets. A preview never invents a figure the commit would not make.
28
+ */
29
+ export function livePartsOf(asset, live) {
30
+ if (!isLive(live))
31
+ return null;
32
+ const { design, state } = liveOverridesOf(asset, live.values);
33
+ try {
34
+ let next = live.edit ? editV3Part(asset, live.edit) : asset;
35
+ if (Object.keys(design).length)
36
+ next = { ...next, designInputs: { ...next.designInputs, ...design } };
37
+ return drawableV3Parts(compileV3Asset(next).evaluate(state).geometry);
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ }
43
+ /**
44
+ * How much one pixel of a label drag moves a value: a degree for an angle, a hundredth for a ratio, and for a length a
45
+ * step that suits its size -- a millimetre under 100, ten over 1,000 -- so a 12 m wall and a 5 mm pin both scrub at a
46
+ * usable pace. Shift makes it ten times finer.
47
+ */
48
+ export function scrubStep(unit, value, fine = false) {
49
+ const base = unit === 'deg' ? 1 : unit === 'ratio' ? 0.01 : Math.max(1, Math.pow(10, Math.floor(Math.log10(Math.max(1, Math.abs(value)))) - 2));
50
+ return fine ? base / 10 : base;
51
+ }
52
+ /** A scrubbed value on the step's grid, so a drag does not leave 1203.0000000002 behind. */
53
+ export function scrubbed(start, pixels, step) {
54
+ const value = start + pixels * step;
55
+ const digits = Math.max(0, -Math.floor(Math.log10(step)));
56
+ return Number(value.toFixed(digits));
57
+ }
58
+ //# sourceMappingURL=v3-live.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3-live.js","sourceRoot":"","sources":["../../client/modeller/v3-live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGnE,OAAO,EAAE,eAAe,EAAqB,MAAM,kBAAkB,CAAA;AAoBrE,MAAM,CAAC,MAAM,YAAY,GAAe,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;AAEtD,wGAAwG;AACxG,MAAM,UAAU,eAAe,CAAC,KAAc,EAAE,MAA8B;IAC5E,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC3E,MAAM,MAAM,GAA2B,EAAE,EACvC,KAAK,GAA2B,EAAE,CAAA;IACpC,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,SAAQ;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;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,IAAI,GAAG,KAAK;IACjE,MAAM,IAAI,GACR,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACpI,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAChC,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,MAAc,EAAE,IAAY;IAClE,MAAM,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACzD,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AACtC,CAAC","sourcesContent":["import { compileV3Asset, editV3Part } from '@hatiolab/figure-model'\nimport type { V3Asset, V3PartEdit } from '@hatiolab/figure-model'\n\nimport { drawableV3Parts, type V3RenderPart } from './v3-renderer.js'\n\n/*\n * The figure while a value is in hand: evaluated with the values being typed or dragged, drawn at once and written\n * nowhere. The panels committed on release only, so the canvas stood still while a number was typed, a spinner held,\n * a label scrubbed, a slider or the glow dragged (user, 2026-09-24: \"make the editor move naturally while the value\n * changes\"). The value in hand shows here; the release is the one step of the history.\n *\n * What is in hand is either input values -- a design value (a size, a position) or a pose -- or one part edit (the\n * glow of a material). A design value is a change of the figure's design, so it is shown by evaluating a copy with\n * that value; a pose is a state override, as the preview gives it.\n */\n\nexport interface LiveValues {\n /** Input values in hand, design or state, by input id. */\n values: Record<string, number>\n /** A part edit in hand, not yet committed. */\n edit?: V3PartEdit\n}\n\nexport const NOTHING_LIVE: LiveValues = { values: {} }\n\n/** Known inputs with a number, split by what they are. An id the figure does not declare is dropped. */\nexport function liveOverridesOf(asset: V3Asset, values: Record<string, number>): { design: Record<string, number>; state: Record<string, number> } {\n const roles = new Map(asset.document.model.inputs.map(i => [i.id, i.role]))\n const design: Record<string, number> = {},\n state: Record<string, number> = {}\n for (const [id, value] of Object.entries(values)) {\n if (!Number.isFinite(value)) continue\n const role = roles.get(id)\n if (role === 'state') state[id] = value\n else if (role !== undefined) design[id] = value\n }\n return { design, state }\n}\n\nexport function isLive(live: LiveValues): boolean {\n return !!live.edit || Object.keys(live.values).length > 0\n}\n\n/**\n * The bodies to draw with what is in hand, or null when nothing is -- then the evaluation as it stands is drawn.\n *\n * Also null when the figure cannot take the value in hand (a size of 0 on the way to typing 0.5, a glow the material\n * refuses): the canvas keeps the figure as it stands until the release, and the release reports why through the same\n * refusal every committed edit gets. A preview never invents a figure the commit would not make.\n */\nexport function livePartsOf(asset: V3Asset, live: LiveValues): V3RenderPart[] | null {\n if (!isLive(live)) return null\n const { design, state } = liveOverridesOf(asset, live.values)\n try {\n let next = live.edit ? editV3Part(asset, live.edit) : asset\n if (Object.keys(design).length) next = { ...next, designInputs: { ...next.designInputs, ...design } }\n return drawableV3Parts(compileV3Asset(next).evaluate(state).geometry)\n } catch {\n return null\n }\n}\n\n/**\n * How much one pixel of a label drag moves a value: a degree for an angle, a hundredth for a ratio, and for a length a\n * step that suits its size -- a millimetre under 100, ten over 1,000 -- so a 12 m wall and a 5 mm pin both scrub at a\n * usable pace. Shift makes it ten times finer.\n */\nexport function scrubStep(unit: string, value: number, fine = false): number {\n const base =\n unit === 'deg' ? 1 : unit === 'ratio' ? 0.01 : Math.max(1, Math.pow(10, Math.floor(Math.log10(Math.max(1, Math.abs(value)))) - 2))\n return fine ? base / 10 : base\n}\n\n/** A scrubbed value on the step's grid, so a drag does not leave 1203.0000000002 behind. */\nexport function scrubbed(start: number, pixels: number, step: number): number {\n const value = start + pixels * step\n const digits = Math.max(0, -Math.floor(Math.log10(step)))\n return Number(value.toFixed(digits))\n}\n"]}
@@ -0,0 +1,120 @@
1
+ import { V3_BUDGET_KEYS, V3_GRADE_SCALE, v3GradeOf } from '@hatiolab/figure-model';
2
+ import type { V3Asset, V3AssetGeometry, V3BudgetKey, V3BudgetUse, V3Cost, V3Geometry, V3Score } from '@hatiolab/figure-model';
3
+ import type { FigureCapacity } from './scene-budget.js';
4
+ export { V3_BUDGET_KEYS, V3_GRADE_SCALE as GRADE_SCALE, v3GradeOf as gradeOf };
5
+ export type { V3BudgetKey, V3BudgetUse, V3Score };
6
+ export type V3AxisKey = 'scale' | 'consistency' | 'reuse' | 'detail' | 'reactive' | 'readable';
7
+ /** One maturity axis. The same shape V2's `maturity.ts` gave the report. */
8
+ export interface V3MaturityAxis {
9
+ key: V3AxisKey;
10
+ /** 0–1. Absent when the axis cannot be measured. */
11
+ ratio?: number;
12
+ reading?: string;
13
+ /** A reading that is words, not a number. */
14
+ readingKey?: string;
15
+ because?: string;
16
+ /** Why the axis is not measured. When present there is no ratio — an unmeasured axis is not a zero. */
17
+ blocked?: string;
18
+ }
19
+ /** Instances on one screen, and what each series costs at that count. */
20
+ export interface V3CurvePoint {
21
+ instances: number;
22
+ triangles: number;
23
+ drawCalls: number;
24
+ /** Vertex buffers: one per distinct shape, shared by every instance of the same size. */
25
+ geometries: number;
26
+ materials: number;
27
+ }
28
+ export interface V3Report {
29
+ cost: V3Cost;
30
+ capacity: FigureCapacity;
31
+ score: V3Score;
32
+ /** Distinct shapes and materials among the drawn bodies — V2's 「그리는 비용」 rows. */
33
+ distinctShapes: number;
34
+ distinctMaterials: number;
35
+ reuse: {
36
+ distinct: number;
37
+ parts: number;
38
+ saved: number;
39
+ };
40
+ axes: V3MaturityAxis[];
41
+ curve: V3CurvePoint[];
42
+ }
43
+ /** V2's board target for the scale axis: 500 assets on one drawing (design document §4.15). */
44
+ export declare const BOARD_ASSETS = 500;
45
+ /**
46
+ * The report for one asset, or nothing when no body is drawn — then there is nothing to measure, and the screen
47
+ * says so rather than drawing zeros.
48
+ *
49
+ * Evaluated at the asset's own design and state defaults, as `v3CostOf` is.
50
+ */
51
+ export declare function v3ReportOf(asset: V3Asset): V3Report | undefined;
52
+ /**
53
+ * The key things-scene shares a body's geometry by (`figure-v3-geometry.ts` `keyOf`): provider, dimensions to a
54
+ * micrometre, segments (12 when unset), and a polygon's corners.
55
+ */
56
+ export declare function shapeKeyOf(body: V3AssetGeometry | V3Geometry): string;
57
+ /**
58
+ * The key things-scene shares a material by (`figure-v3-rig.ts` `materialFor`), within one asset: token, preset,
59
+ * transparency, and the light when it is on. The colour follows from the token, so it is not a second key.
60
+ */
61
+ export declare function materialKeyOf(body: V3AssetGeometry): string;
62
+ /** 1 · 2 · 5 per decade, as V2's trend (`cost-chart.ts`): even steps on a log axis. */
63
+ export declare function decadeSteps(from: number, to: number): number[];
64
+ export type V3CurveSeries = 'triangles' | 'drawCalls' | 'geometries' | 'materials';
65
+ /**
66
+ * The four lines V2 drew: two that grow with the instance count and two that stay flat — the flat ones are what the
67
+ * instances share. Materials are dashed and drawn last, so a line under them still shows where the two meet.
68
+ */
69
+ export declare const CURVE_SERIES: readonly {
70
+ key: V3CurveSeries;
71
+ flat: boolean;
72
+ dashed?: boolean;
73
+ }[];
74
+ /** V2's chart size. The chart is shown at this size in a sheet; shrunk into the side, its words are unreadable. */
75
+ export declare const CURVE_SIZE: {
76
+ readonly width: 680;
77
+ readonly height: 380;
78
+ readonly pad: {
79
+ readonly top: 52;
80
+ readonly right: 208;
81
+ readonly bottom: 44;
82
+ readonly left: 62;
83
+ };
84
+ };
85
+ export interface V3CurveLayout {
86
+ xTicks: {
87
+ x: number;
88
+ label: string;
89
+ }[];
90
+ yTicks: {
91
+ y: number;
92
+ label: string;
93
+ }[];
94
+ lines: {
95
+ key: V3CurveSeries;
96
+ d: string;
97
+ flat: boolean;
98
+ dashed: boolean;
99
+ last: number;
100
+ }[];
101
+ /** The value the flat lines share when they lie on one another, so the screen can say why one line is missing. */
102
+ overlap?: number;
103
+ }
104
+ /** 1, 10, 100 … written short. */
105
+ export declare function shortNumber(v: number): string;
106
+ /** Where V2's chart puts each line and tick. Both axes are logarithmic, as V2's are. */
107
+ export declare function curveLayout(points: V3CurvePoint[]): V3CurveLayout | undefined;
108
+ /** What the parts list shows under its title: the cost, how many fit, the grade and what decides it. */
109
+ export interface V3BudgetLine {
110
+ triangles: number;
111
+ groups: number;
112
+ instances: number;
113
+ grade: string;
114
+ tightest: {
115
+ key: string;
116
+ used: number;
117
+ limit: number;
118
+ };
119
+ }
120
+ export declare function budgetOf(report: V3Report | undefined): V3BudgetLine | undefined;
@@ -0,0 +1,317 @@
1
+ import { compileV3Asset, compileV3Document, LIMITS, SEGMENT_PRESETS, V3_BUDGET_KEYS, V3_GRADE_SCALE, v3CostOf, v3GradeOf, v3MaterialKeyOf, v3ScoreOf, v3WorldBoxesOf, v3WritersOf } from '@hatiolab/figure-model';
2
+ import { capacityFrom } from './scene-budget.js';
3
+ /*
4
+ * The V2 modeller's maturity report, read off a V3 asset (user, 2026-09-24: the V3 tab showed a count and nothing
5
+ * else — 「왜 이렇게 너프되었는지」).
6
+ *
7
+ * V2's report was `figure-report.ts` over `costOf` · `scoreOf` · `costCurveSvg` (figure-model) and `maturity.ts`
8
+ * (figure-ui). Those read a V2 blueprint. This module asks the same questions of the evaluated V3 asset and keeps
9
+ * V2's answers where the question still has one:
10
+ *
11
+ * grade A–D and its scale V2's bounds, over figure-model's `v3ScoreOf`: one screen's target shared per instance
12
+ * (groups, triangles) and V2's declared rule limits (independent, transparent)
13
+ * radar · axes V2's six axes; the two V2 could not measure stay unmeasured, detail has no V3 field
14
+ * drawing cost triangles, distinct shapes, distinct materials
15
+ * trend what grows with the instance count and what the instances share
16
+ *
17
+ * Kept apart from the element so it can be tested without a browser.
18
+ *
19
+ * ## What the V3 renderer shares, which is what the numbers count
20
+ *
21
+ * things-scene draws one mesh per drawn body (`figure-v3-rig.ts`) — no merging by material as V2 did — so a body is
22
+ * a draw call. It shares geometry by provider, dimensions, segments and profile (`figure-v3-geometry.ts`, `keyOf`)
23
+ * and materials by token, preset, transparency and light (`materialFor`). The keys below are those keys; a
24
+ * distinct-shape count that used another key would describe a renderer that does not exist.
25
+ *
26
+ * ## Budgets V3 does not have
27
+ *
28
+ * V2 had five. Two are not measured here, and are not shown as zero:
29
+ * - off-palette surfaces: the V3 material has no surface field, so there is nothing to count;
30
+ * - part count by detail level: V3 does not carry the detail level (chief architect, 2026-09-24, ADR-0087).
31
+ */
32
+ /*
33
+ The grade, its budgets and its bounds are figure-model's (`v3ScoreOf`), so the catalogue grades a figure as this tab
34
+ does. The grade is the headroom against one screen's target (`LIMITS.screenInstances`), not a draw-call limit.
35
+ */
36
+ export { V3_BUDGET_KEYS, V3_GRADE_SCALE as GRADE_SCALE, v3GradeOf as gradeOf };
37
+ /** V2's board target for the scale axis: 500 assets on one drawing (design document §4.15). */
38
+ export const BOARD_ASSETS = 500;
39
+ /**
40
+ * The report for one asset, or nothing when no body is drawn — then there is nothing to measure, and the screen
41
+ * says so rather than drawing zeros.
42
+ *
43
+ * Evaluated at the asset's own design and state defaults, as `v3CostOf` is.
44
+ */
45
+ export function v3ReportOf(asset) {
46
+ const cost = v3CostOf(asset);
47
+ const capacity = capacityFrom(cost.groups, cost.triangles);
48
+ if (!capacity)
49
+ return undefined;
50
+ const drawn = compileV3Asset(asset)
51
+ .evaluate()
52
+ .geometry.filter(body => body.visible !== false);
53
+ const plan = compileV3Document(asset.document);
54
+ const writers = v3WritersOf(asset);
55
+ const shapes = new Set(drawn.map(shapeKeyOf));
56
+ const materials = new Set(drawn.map(materialKeyOf));
57
+ const score = v3ScoreOf(asset);
58
+ const reuse = { distinct: shapes.size, parts: drawn.length, saved: drawn.length - shapes.size };
59
+ const axes = [
60
+ {
61
+ key: 'scale',
62
+ // The board target filled is 1; room beyond it is better spent on the other axes, so it does not count more.
63
+ ratio: Math.min(1, capacity.instances / BOARD_ASSETS),
64
+ reading: String(capacity.instances),
65
+ because: 'figure.text.maturity-scale-because'
66
+ },
67
+ consistency(asset, materials.size),
68
+ {
69
+ key: 'reuse',
70
+ // A low distinct-to-parts ratio is much reuse; turned over so that more is higher.
71
+ ratio: reuse.parts === 0 ? 0 : 1 - reuse.distinct / reuse.parts,
72
+ reading: String(reuse.saved),
73
+ because: 'figure.text.maturity-reuse-because'
74
+ },
75
+ { key: 'detail', blocked: 'figure.text.maturity-blocked-no-detail-level' },
76
+ { key: 'reactive', blocked: 'figure.text.maturity-blocked-no-binding' },
77
+ readable(asset, plan, drawn, writers)
78
+ ];
79
+ return {
80
+ cost,
81
+ capacity,
82
+ score,
83
+ distinctShapes: shapes.size,
84
+ distinctMaterials: materials.size,
85
+ reuse,
86
+ axes,
87
+ curve: decadeSteps(1, 10000).map(instances => ({
88
+ instances,
89
+ triangles: cost.triangles * instances,
90
+ drawCalls: cost.groups * instances,
91
+ geometries: shapes.size,
92
+ materials: materials.size
93
+ }))
94
+ };
95
+ }
96
+ /**
97
+ * The key things-scene shares a body's geometry by (`figure-v3-geometry.ts` `keyOf`): provider, dimensions to a
98
+ * micrometre, segments (12 when unset), and a polygon's corners.
99
+ */
100
+ export function shapeKeyOf(body) {
101
+ if (!('shape' in body)) {
102
+ // A scalar body has no mesh of its own; it is still one drawn body, told apart by what it declares.
103
+ const dims = Object.keys(body.dimensions).sort().map(k => `${k}=${body.dimensions[k]}`).join(',');
104
+ return `${body.provider}|${dims}`;
105
+ }
106
+ const shape = body.shape;
107
+ const round = (v) => Math.round(v * 1e6) / 1e6;
108
+ const dims = Object.keys(shape.dimensions)
109
+ .sort()
110
+ .map(k => `${k}=${round(shape.dimensions[k])}`)
111
+ .join(',');
112
+ const profile = shape.profile ? '|' + shape.profile.map(p => `${round(p.x)}:${round(p.y)}`).join(';') : '';
113
+ const segments = body.segments ?? 12;
114
+ return `${shape.provider}|${dims}|s${segments}${profile}`;
115
+ }
116
+ /**
117
+ * The key things-scene shares a material by (`figure-v3-rig.ts` `materialFor`), within one asset: token, preset,
118
+ * transparency, and the light when it is on. The colour follows from the token, so it is not a second key.
119
+ */
120
+ export function materialKeyOf(body) {
121
+ return v3MaterialKeyOf(body);
122
+ }
123
+ /**
124
+ * Does it look like one set — V2's baselines 3 and 4. V2 checks three things; V3 keeps the same three.
125
+ *
126
+ * Two of them hold by construction in V3: the material has no surface field, so there is no texture, and the
127
+ * format refuses a segment count outside the presets (`compileV3Asset`, `QUALITY`). They are still counted, as
128
+ * V2 counts them, so the ratio means what it meant: one fault in three.
129
+ */
130
+ function consistency(asset, distinctMaterials) {
131
+ const textures = 0;
132
+ const offPreset = asset.appearance.filter(look => look.segments !== undefined && !SEGMENT_PRESETS.includes(look.segments)).length;
133
+ const faults = (textures > 0 ? 1 : 0) + (offPreset > 0 ? 1 : 0) + (distinctMaterials > LIMITS.distinctMaterials ? 1 : 0);
134
+ return {
135
+ key: 'consistency',
136
+ ratio: (3 - faults) / 3,
137
+ readingKey: faults === 0 ? 'figure.text.maturity-consistency-clean' : 'figure.text.maturity-consistency-faults',
138
+ because: 'figure.text.maturity-consistency-because'
139
+ };
140
+ }
141
+ /** Seen from above, these do not fill their footprint box. V2's list, in V3's provider names. */
142
+ const ROUND_FOOTPRINT = ['cylinder', 'ellipticCylinder', 'frustum', 'sphere'];
143
+ /**
144
+ * Can it be told apart from above — V2's baseline 1, the same measure.
145
+ *
146
+ * Viewpoint entropy (Vázquez et al.) over the top view, counted by colour region rather than by face so that a
147
+ * finer segment count does not raise it: H = −Σ p·log p over each material's share of the footprint plus the
148
+ * background, divided by log(`LIMITS.distinctMaterials` + 1), the most this measure can reach.
149
+ *
150
+ * The footprint is V2's base box: the space the asset declares when it declares one (ADR-0044's box is V3's
151
+ * occupancy), otherwise the drawn bodies' own extent. Bodies are their axis-aligned world boxes
152
+ * (`v3WorldBoxesOf`, the gate's reading); the higher one covers the lower.
153
+ */
154
+ function readable(asset, plan, drawn, writers) {
155
+ const placed = drawn
156
+ .filter(body => 'pose' in body)
157
+ // One placed, drawn body gives exactly one box; boxes are taken one by one to keep each with its material.
158
+ .map(body => ({ body, box: v3WorldBoxesOf([body], writers)[0] }));
159
+ if (placed.length === 0)
160
+ return { key: 'readable', blocked: 'figure.text.maturity-blocked-no-parts' };
161
+ let frame;
162
+ if (asset.occupancy) {
163
+ const values = plan.evaluate({ ...asset.designInputs, ...asset.stateDefaults }).values;
164
+ const at = (ref) => values[ref];
165
+ const b = asset.occupancy.bounds;
166
+ frame = { x0: at(b.x.min), x1: at(b.x.max), z0: at(b.z.min), z1: at(b.z.max) };
167
+ }
168
+ else {
169
+ frame = { x0: Infinity, x1: -Infinity, z0: Infinity, z1: -Infinity };
170
+ for (const { box } of placed) {
171
+ frame.x0 = Math.min(frame.x0, box.centre.x - box.extent.x / 2);
172
+ frame.x1 = Math.max(frame.x1, box.centre.x + box.extent.x / 2);
173
+ frame.z0 = Math.min(frame.z0, box.centre.z - box.extent.z / 2);
174
+ frame.z1 = Math.max(frame.z1, box.centre.z + box.extent.z / 2);
175
+ }
176
+ }
177
+ const regions = topViewRegions(placed, frame);
178
+ if (regions.total === 0)
179
+ return { key: 'readable', blocked: 'figure.text.maturity-blocked-no-parts' };
180
+ const shares = [...regions.byMaterial.values(), regions.background].map(area => area / regions.footprint).filter(share => share > 0);
181
+ const entropy = -shares.reduce((sum, p) => sum + p * Math.log(p), 0);
182
+ const ceiling = Math.log(LIMITS.distinctMaterials + 1);
183
+ return {
184
+ key: 'readable',
185
+ // Clamped both ways: one region alone gives −0, which is not a reading anyone should see.
186
+ ratio: Math.max(0, Math.min(1, entropy / ceiling)),
187
+ reading: String(regions.byMaterial.size),
188
+ because: 'figure.text.maturity-readable-because'
189
+ };
190
+ }
191
+ /** Which material shows from above, on a 64 × 64 grid over the footprint. V2's `topViewRegions`, over world boxes. */
192
+ function topViewRegions(placed, frame) {
193
+ const GRID = 64;
194
+ const cells = new Array(GRID * GRID).fill(null);
195
+ const height = new Float64Array(GRID * GRID);
196
+ const sx = GRID / Math.max(frame.x1 - frame.x0, 1e-6);
197
+ const sz = GRID / Math.max(frame.z1 - frame.z0, 1e-6);
198
+ for (const { body, box } of placed) {
199
+ const top = box.centre.y + box.extent.y / 2;
200
+ const key = materialKeyOf(body);
201
+ const x0 = Math.max(0, Math.floor((box.centre.x - box.extent.x / 2 - frame.x0) * sx));
202
+ const x1 = Math.min(GRID, Math.ceil((box.centre.x + box.extent.x / 2 - frame.x0) * sx));
203
+ const y0 = Math.max(0, Math.floor((box.centre.z - box.extent.z / 2 - frame.z0) * sz));
204
+ const y1 = Math.min(GRID, Math.ceil((box.centre.z + box.extent.z / 2 - frame.z0) * sz));
205
+ const round = 'shape' in body && ROUND_FOOTPRINT.includes(body.shape.provider);
206
+ for (let y = y0; y < y1; y++) {
207
+ for (let x = x0; x < x1; x++) {
208
+ // A round body does not fill its box; the corners are cut, as V2 cuts them.
209
+ if (round) {
210
+ const cx = (x + 0.5 - (x0 + x1) / 2) / ((x1 - x0) / 2 || 1);
211
+ const cy = (y + 0.5 - (y0 + y1) / 2) / ((y1 - y0) / 2 || 1);
212
+ if (cx * cx + cy * cy > 1)
213
+ continue;
214
+ }
215
+ const i = y * GRID + x;
216
+ if (cells[i] === null || top > height[i]) {
217
+ cells[i] = key;
218
+ height[i] = top;
219
+ }
220
+ }
221
+ }
222
+ }
223
+ const byMaterial = new Map();
224
+ let covered = 0;
225
+ for (const key of cells) {
226
+ if (key === null)
227
+ continue;
228
+ covered++;
229
+ byMaterial.set(key, (byMaterial.get(key) ?? 0) + 1);
230
+ }
231
+ return { byMaterial, total: covered, background: GRID * GRID - covered, footprint: GRID * GRID };
232
+ }
233
+ /** 1 · 2 · 5 per decade, as V2's trend (`cost-chart.ts`): even steps on a log axis. */
234
+ export function decadeSteps(from, to) {
235
+ const out = [];
236
+ for (let decade = 1; decade <= to; decade *= 10) {
237
+ for (const m of [1, 2, 5]) {
238
+ const v = decade * m;
239
+ if (v >= from && v <= to)
240
+ out.push(v);
241
+ }
242
+ }
243
+ if (out.length === 0 || out[out.length - 1] !== to)
244
+ out.push(to);
245
+ return [...new Set(out)].sort((a, b) => a - b);
246
+ }
247
+ /**
248
+ * The four lines V2 drew: two that grow with the instance count and two that stay flat — the flat ones are what the
249
+ * instances share. Materials are dashed and drawn last, so a line under them still shows where the two meet.
250
+ */
251
+ export const CURVE_SERIES = [
252
+ { key: 'triangles', flat: false },
253
+ { key: 'drawCalls', flat: false },
254
+ { key: 'geometries', flat: true },
255
+ { key: 'materials', flat: true, dashed: true }
256
+ ];
257
+ /** V2's chart size. The chart is shown at this size in a sheet; shrunk into the side, its words are unreadable. */
258
+ export const CURVE_SIZE = { width: 680, height: 380, pad: { top: 52, right: 208, bottom: 44, left: 62 } };
259
+ const log10 = (v) => Math.log(Math.max(v, 1)) / Math.LN10;
260
+ /** 1, 10, 100 … written short. */
261
+ export function shortNumber(v) {
262
+ if (v >= 1_000_000)
263
+ return `${v / 1_000_000}M`;
264
+ if (v >= 1_000)
265
+ return `${v / 1_000}k`;
266
+ return String(v);
267
+ }
268
+ /** Where V2's chart puts each line and tick. Both axes are logarithmic, as V2's are. */
269
+ export function curveLayout(points) {
270
+ if (points.length === 0)
271
+ return undefined;
272
+ const { width, height, pad } = CURVE_SIZE;
273
+ const minX = points[0].instances;
274
+ const maxX = points[points.length - 1].instances;
275
+ let maxY = 1;
276
+ for (const p of points)
277
+ for (const s of CURVE_SERIES)
278
+ maxY = Math.max(maxY, p[s.key]);
279
+ const plotW = width - pad.left - pad.right;
280
+ const plotH = height - pad.top - pad.bottom;
281
+ const spanX = Math.max(log10(maxX) - log10(minX), 1e-9);
282
+ const spanY = Math.max(log10(maxY), 1e-9);
283
+ const px = (v) => pad.left + ((log10(v) - log10(minX)) / spanX) * plotW;
284
+ const py = (v) => pad.top + plotH - (log10(v) / spanY) * plotH;
285
+ const yTicks = [];
286
+ for (let e = 0; Math.pow(10, e) <= maxY * 1.001; e++)
287
+ yTicks.push({ y: py(Math.pow(10, e)), label: shortNumber(Math.pow(10, e)) });
288
+ const xTicks = [];
289
+ for (let e = 0; Math.pow(10, e) <= maxX * 1.001; e++) {
290
+ const v = Math.pow(10, e);
291
+ if (v >= minX)
292
+ xTicks.push({ x: px(v), label: shortNumber(v) });
293
+ }
294
+ const last = points[points.length - 1];
295
+ const lines = CURVE_SERIES.map(s => ({
296
+ key: s.key,
297
+ d: points.map((p, i) => `${i === 0 ? 'M' : 'L'}${px(p.instances).toFixed(1)},${py(p[s.key]).toFixed(1)}`).join(' '),
298
+ flat: s.flat,
299
+ dashed: !!s.dashed,
300
+ last: last[s.key]
301
+ }));
302
+ const flat = new Set(CURVE_SERIES.filter(s => s.flat).map(s => last[s.key]));
303
+ return { xTicks, yTicks, lines, overlap: flat.size === 1 ? [...flat][0] : undefined };
304
+ }
305
+ export function budgetOf(report) {
306
+ if (!report)
307
+ return undefined;
308
+ const { tightest } = report.score;
309
+ return {
310
+ triangles: report.cost.triangles,
311
+ groups: report.cost.groups,
312
+ instances: report.capacity.instances,
313
+ grade: report.score.grade,
314
+ tightest: { key: tightest.key, used: tightest.used, limit: Math.floor(tightest.limit) }
315
+ };
316
+ }
317
+ //# sourceMappingURL=v3-maturity.js.map