@things-factory/figure-ui 10.1.49 → 10.1.51

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 (97) hide show
  1. package/client/graphql/v3-store.ts +2 -1
  2. package/client/modeller/figure-history-panel.ts +9 -1
  3. package/client/modeller/figure-v3-first-save.ts +98 -0
  4. package/client/modeller/figure-v3-links.ts +177 -31
  5. package/client/modeller/figure-v3-parts.ts +1 -0
  6. package/client/modeller/figure-v3-properties.ts +2 -1
  7. package/client/modeller/v3-canvas.ts +61 -7
  8. package/client/modeller/v3-editor.ts +96 -21
  9. package/client/modeller/v3-first-save.ts +34 -0
  10. package/client/modeller/v3-gizmo.ts +52 -3
  11. package/client/modeller/v3-joint-drag.ts +116 -0
  12. package/client/modeller/v3-joint-fan.ts +24 -11
  13. package/client/modeller/v3-keys.ts +12 -1
  14. package/client/modeller/v3-links.ts +119 -8
  15. package/client/modeller/v3-live.ts +11 -0
  16. package/client/modeller/v3-product-session.ts +4 -2
  17. package/client/modeller/v3-refusals.ts +21 -0
  18. package/client/pages/figure-v3-modeller-page.ts +57 -8
  19. package/dist-client/graphql/v3-store.js +2 -1
  20. package/dist-client/graphql/v3-store.js.map +1 -1
  21. package/dist-client/modeller/figure-history-panel.js +9 -1
  22. package/dist-client/modeller/figure-history-panel.js.map +1 -1
  23. package/dist-client/modeller/figure-v3-capability.d.ts +1 -1
  24. package/dist-client/modeller/figure-v3-clips.d.ts +1 -1
  25. package/dist-client/modeller/figure-v3-controls.d.ts +1 -1
  26. package/dist-client/modeller/figure-v3-first-save.d.ts +20 -0
  27. package/dist-client/modeller/figure-v3-first-save.js +118 -0
  28. package/dist-client/modeller/figure-v3-first-save.js.map +1 -0
  29. package/dist-client/modeller/figure-v3-links.d.ts +14 -1
  30. package/dist-client/modeller/figure-v3-links.js +169 -28
  31. package/dist-client/modeller/figure-v3-links.js.map +1 -1
  32. package/dist-client/modeller/figure-v3-material.d.ts +1 -1
  33. package/dist-client/modeller/figure-v3-parts.js +1 -0
  34. package/dist-client/modeller/figure-v3-parts.js.map +1 -1
  35. package/dist-client/modeller/figure-v3-properties.d.ts +1 -1
  36. package/dist-client/modeller/figure-v3-properties.js +2 -1
  37. package/dist-client/modeller/figure-v3-properties.js.map +1 -1
  38. package/dist-client/modeller/v3-canvas.d.ts +11 -0
  39. package/dist-client/modeller/v3-canvas.js +61 -7
  40. package/dist-client/modeller/v3-canvas.js.map +1 -1
  41. package/dist-client/modeller/v3-clips.d.ts +1 -1
  42. package/dist-client/modeller/v3-editor.d.ts +13 -1
  43. package/dist-client/modeller/v3-editor.js +96 -21
  44. package/dist-client/modeller/v3-editor.js.map +1 -1
  45. package/dist-client/modeller/v3-first-save.d.ts +17 -0
  46. package/dist-client/modeller/v3-first-save.js +27 -0
  47. package/dist-client/modeller/v3-first-save.js.map +1 -0
  48. package/dist-client/modeller/v3-gizmo.d.ts +18 -0
  49. package/dist-client/modeller/v3-gizmo.js +45 -2
  50. package/dist-client/modeller/v3-gizmo.js.map +1 -1
  51. package/dist-client/modeller/v3-joint-drag.d.ts +19 -0
  52. package/dist-client/modeller/v3-joint-drag.js +97 -0
  53. package/dist-client/modeller/v3-joint-drag.js.map +1 -0
  54. package/dist-client/modeller/v3-joint-fan.js +24 -11
  55. package/dist-client/modeller/v3-joint-fan.js.map +1 -1
  56. package/dist-client/modeller/v3-keys.d.ts +9 -1
  57. package/dist-client/modeller/v3-keys.js +3 -0
  58. package/dist-client/modeller/v3-keys.js.map +1 -1
  59. package/dist-client/modeller/v3-links.d.ts +72 -3
  60. package/dist-client/modeller/v3-links.js +89 -6
  61. package/dist-client/modeller/v3-links.js.map +1 -1
  62. package/dist-client/modeller/v3-live.d.ts +6 -0
  63. package/dist-client/modeller/v3-live.js +10 -0
  64. package/dist-client/modeller/v3-live.js.map +1 -1
  65. package/dist-client/modeller/v3-product-session.d.ts +4 -1
  66. package/dist-client/modeller/v3-product-session.js +2 -2
  67. package/dist-client/modeller/v3-product-session.js.map +1 -1
  68. package/dist-client/modeller/v3-refusals.d.ts +4 -0
  69. package/dist-client/modeller/v3-refusals.js +21 -0
  70. package/dist-client/modeller/v3-refusals.js.map +1 -0
  71. package/dist-client/pages/figure-v3-modeller-page.d.ts +4 -0
  72. package/dist-client/pages/figure-v3-modeller-page.js +56 -8
  73. package/dist-client/pages/figure-v3-modeller-page.js.map +1 -1
  74. package/dist-client/tsconfig.tsbuildinfo +1 -1
  75. package/package.json +7 -5
  76. package/test/browser/build.mjs +62 -0
  77. package/test/browser/modeller-page.js +198 -0
  78. package/test/browser/modeller.check.mjs +358 -0
  79. package/test/browser/serve.mjs +43 -0
  80. package/test/joints.ts +33 -0
  81. package/test/v3-clips.test.ts +3 -2
  82. package/test/v3-controls.test.ts +3 -2
  83. package/test/v3-fields.test.ts +3 -2
  84. package/test/v3-first-save.test.ts +84 -0
  85. package/test/v3-gizmo.test.ts +38 -5
  86. package/test/v3-joint-drag.test.ts +93 -0
  87. package/test/v3-joint-fan.test.ts +16 -6
  88. package/test/v3-keys.test.ts +15 -2
  89. package/test/v3-links.test.ts +114 -14
  90. package/test/v3-live.test.ts +23 -4
  91. package/test/v3-maturity.test.ts +2 -6
  92. package/test/v3-refusals.test.ts +28 -0
  93. package/translations/en.json +40 -5
  94. package/translations/ja.json +39 -4
  95. package/translations/ko.json +39 -4
  96. package/translations/ms.json +39 -4
  97. package/translations/zh.json +39 -4
@@ -32,6 +32,19 @@ let FigureV3Canvas = class FigureV3Canvas extends LitElement {
32
32
  this.fan = null;
33
33
  /** Set while this canvas writes to components, so the scene's echo of it is not taken for a drag. */
34
34
  this.writing = false;
35
+ /** Components the gizmo changed since the last commit, by part name. */
36
+ this.pending = new Map();
37
+ this.pointerDown = false;
38
+ this.onPointerDown = () => {
39
+ this.pointerDown = true;
40
+ };
41
+ this.onPointerUp = () => {
42
+ if (!this.pointerDown)
43
+ return;
44
+ this.pointerDown = false;
45
+ /* After the scene's own drag end (it settles the depth and rebuilds the geometry on release). */
46
+ this.commitSoon(0);
47
+ };
35
48
  }
36
49
  static { this.styles = css `
37
50
  :host {
@@ -106,6 +119,10 @@ let FigureV3Canvas = class FigureV3Canvas extends LitElement {
106
119
  this.scene?.fit?.('ratio');
107
120
  this.scene?.root?.fitCameraToModel?.();
108
121
  }
122
+ /** The gizmo in a mode on the selected part, as W, E and R do with the canvas focused -- the scene's toggle. */
123
+ gizmo(mode) {
124
+ this.scene?.root?.setGizmoMode?.(mode);
125
+ }
109
126
  /**
110
127
  * Stand the board up for this figure, or bring the one standing up to date. A new board only for another figure or
111
128
  * one that has outgrown it -- standing up again loses the selection and the camera.
@@ -238,21 +255,53 @@ let FigureV3Canvas = class FigureV3Canvas extends LitElement {
238
255
  A change comes up to the board with the component in the last argument's `origin` (the scene appends
239
256
  { origin, name, deliverer } as it bubbles). Reading the first argument as the component does nothing (V2).
240
257
  */
258
+ /*
259
+ A drag is written once, when it ends. The scene's gizmo writes the component on every move -- a size anchored on
260
+ the opposite face, from the scale it captured when the drag began -- and writing each move back through the
261
+ editor (and the evaluation back onto the component) fought it: the scale gizmo did not work (user, 2026-09-24).
262
+ While a pointer is down the changes are only kept; on release the last one is told, and the board is brought to
263
+ the evaluation. A change with no pointer down (the arrow keys) is told after a short pause.
264
+ */
241
265
  layer.on?.('change', (...args) => {
242
266
  if (this.writing)
243
267
  return;
244
268
  const origin = args[args.length - 1]?.origin;
245
269
  const name = origin?.state?.name;
246
- const part = typeof name === 'string' ? this.parts.find(p => p.id === name) : undefined;
247
- if (!part || !this.board)
270
+ if (typeof name !== 'string' || !this.parts.some(p => p.id === name))
248
271
  return;
249
- const result = gizmoResultOf(part, origin.state, this.board);
272
+ this.pending.set(name, origin);
273
+ if (!this.pointerDown)
274
+ this.commitSoon(80);
275
+ });
276
+ this.stage.addEventListener('pointerdown', this.onPointerDown, true);
277
+ window.addEventListener('pointerup', this.onPointerUp, true);
278
+ window.addEventListener('pointercancel', this.onPointerUp, true);
279
+ }
280
+ commitSoon(delay) {
281
+ clearTimeout(this.commitTimer);
282
+ this.commitTimer = setTimeout(() => this.commit(), delay);
283
+ }
284
+ /** Tell each changed part once, in the inputs' terms; then put the board where the inputs say (a refusal springs back). */
285
+ commit() {
286
+ /*
287
+ Not while a pointer is down: a pause set by a change just before the press (the arrow keys, the scene settling
288
+ the pick) fired in the middle of the drag and wrote where the part was then -- a drag on a converted part became
289
+ two steps, the first one a few millimetres in (browser check, 2026-09-25). What is pending waits for the release.
290
+ */
291
+ if (this.pointerDown || !this.board || !this.pending.size)
292
+ return;
293
+ const changed = [...this.pending];
294
+ this.pending.clear();
295
+ for (const [name, component] of changed) {
296
+ const part = this.parts.find(p => p.id === name);
297
+ if (!part)
298
+ continue;
299
+ const result = gizmoResultOf(part, component.state, this.board);
250
300
  if (!result.position && !result.rotation && !result.scale)
251
- return;
301
+ continue;
252
302
  this.dispatchEvent(new CustomEvent('part-transformed', { detail: { id: part.id, result }, bubbles: true, composed: true }));
253
- /* After the editor has applied (or refused) it: a refused change springs back to where the inputs put it. */
254
- setTimeout(() => this.sync());
255
- });
303
+ }
304
+ setTimeout(() => this.sync());
256
305
  }
257
306
  showSelected() {
258
307
  const layer = this.scene?.root;
@@ -276,6 +325,11 @@ let FigureV3Canvas = class FigureV3Canvas extends LitElement {
276
325
  layer.invalidate?.();
277
326
  }
278
327
  teardown() {
328
+ clearTimeout(this.commitTimer);
329
+ this.pending.clear();
330
+ this.stage?.removeEventListener('pointerdown', this.onPointerDown, true);
331
+ window.removeEventListener('pointerup', this.onPointerUp, true);
332
+ window.removeEventListener('pointercancel', this.onPointerUp, true);
279
333
  this.scene?.dispose?.();
280
334
  this.scene = undefined;
281
335
  this.standingFor = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"v3-canvas.js","sourceRoot":"","sources":["../../client/modeller/v3-canvas.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAuB,MAAM,KAAK,CAAA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Q;QACd,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAA;QACvB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;QAC5B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;IACxB,CAAC;;AA7O+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;6CAA2B;AAC1B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;+CAAqC;AAExD;IAAX,QAAQ,EAAE;;+CAAa;AACZ;IAAX,QAAQ,EAAE;;gDAAc;AAEO;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;6CAAsE;AACrE;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;4CAAkC;AAMpC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;gDAAiB;AAEb;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;2CAAgC;AAElC;IAA5B,KAAK,CAAC,YAAY,CAAC;8BAAiB,cAAc;6CAAA;AA1CxC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAuQ1B","sourcesContent":["import { LitElement, html, css, nothing, unsafeCSS, type PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { i18next } from '@operato/i18n'\nimport { create, Model, niceGridStep } from '@hatiolab/things-scene'\n\nimport type { GizmoReach } from './v3-gizmo.js'\nimport type { V3RenderPart } from './v3-renderer.js'\nimport { DEFAULT_VIEW, sceneLook, WORKBENCH, type ViewSettings } from './figure-view.js'\nimport { boardFor, changedKeys, componentOf, gizmoResultOf, type Board } from './v3-stage-model.js'\nimport { JOINT_FAN } from './v3-joint-fan.js'\nimport { ownerOf } from './v3-fields.js'\n\n/*\n * The V3 modeller's canvas -- a things-scene board in editing mode, as the V2 modeller's was.\n *\n * Each body figure-model evaluates stands on the board as a `figure-v3-part` component, so everything the V2 canvas\n * had comes from the scene, not from code of our own: picking and the orange outline, the gizmo with its snapping and\n * live readout, box and shift selection, the camera (damping, zoom toward the cursor, double-click to fit, the six\n * view presets and their keys), the studio environment, the coordinate ground, lights and shadows, supersampling.\n * An earlier canvas drew the bodies with three.js directly and lost all of that (user, 2026-09-24: \"why nerf it?\").\n *\n * What the gizmo writes back to a component comes out as `part-transformed` in the inputs' terms (`v3-stage-model`),\n * and the editor turns it into one step of the history; the next evaluation puts the component where the inputs say,\n * so a change a part cannot take (a fastened part moved) springs back.\n */\n\ninterface SceneComponent {\n state: Record<string, unknown>\n set: (props: Record<string, unknown>) => void\n dispose?: () => void\n}\ninterface SceneLayer extends SceneComponent {\n components?: SceneComponent[]\n root?: { on?: (event: string, handler: (...args: unknown[]) => void) => void; selected?: SceneComponent[] }\n on?: (event: string, handler: (...args: unknown[]) => void) => void\n addComponent?: (component: SceneComponent) => void\n removeComponent?: (component: SceneComponent) => void\n invalidate?: () => void\n fitCameraToModel?: () => void\n app?: unknown\n}\ninterface SceneHandle {\n dispose?: () => void\n resize?: () => void\n fit?: (type?: string) => void\n root?: SceneLayer\n}\n\n/* The fan's colour when the figure's palette names no accent. */\nconst FAN_COLOUR = '#ff8a00'\n\n/* The 2D side of the board, which the author never sees on this page but the scene paints. */\nconst PAPER = '#ffffff'\n\n@customElement('figure-v3-canvas')\nexport class FigureV3Canvas extends LitElement {\n static styles = css`\n :host {\n position: relative;\n display: flex;\n min-height: 0;\n overflow: hidden;\n background-color: ${unsafeCSS(WORKBENCH)};\n }\n /* The scene sets position: relative inline on its target; the size is given so it still fills the host. */\n div[stage] {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n }\n p {\n position: absolute;\n inset: 45% 1rem auto;\n margin: 0;\n text-align: center;\n pointer-events: none;\n color: #f4f4f4;\n }\n `\n @property({ attribute: false }) parts: V3RenderPart[] = []\n @property({ attribute: false }) palette: Record<string, string> = {}\n /** Which figure is open. Another one stands the board up again. */\n @property() context = ''\n @property() selected = ''\n /** What the gizmo may write for the selected part; a change beyond it is not applied and the part springs back. */\n @property({ attribute: false }) reach: GizmoReach = { translate: false, rotate: false, scale: false }\n @property({ attribute: false }) view: ViewSettings = DEFAULT_VIEW\n /**\n * View only: nothing that happens on the board is told out. The card's picture is taken from a second canvas stood up\n * off screen (`v3-thumbnail.ts`); the scene settles its components as it builds them, and a change told from there\n * would reach the editor as an edit (V2's `viewOnly`, for the same reason).\n */\n @property({ type: Boolean }) viewOnly = false\n /** Where the selected part turns and how far (`v3-joint-fan`): shown, never picked, never saved. */\n @property({ attribute: false }) fan: V3RenderPart | null = null\n\n @query('div[stage]') private stage!: HTMLDivElement\n\n private scene?: SceneHandle\n private board?: Board & { depth: number }\n private standingFor?: string\n private watcher?: ResizeObserver\n /** Set while this canvas writes to components, so the scene's echo of it is not taken for a drag. */\n private writing = false\n\n render() {\n return html`<div stage></div>${this.parts.length ? nothing : html`<p>${i18next.t('figure.text.add-a-shape-to-start')}</p>`}`\n }\n\n firstUpdated() {\n this.standUp()\n this.watcher = new ResizeObserver(() => this.scene?.resize?.())\n this.watcher.observe(this)\n }\n\n protected updated(changed: PropertyValues) {\n if (!this.hasUpdated) return\n if (changed.has('parts') || changed.has('palette') || changed.has('context') || changed.has('fan')) this.standUp()\n if (changed.has('view')) this.applyView()\n if (changed.has('selected')) this.showSelected()\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this.watcher?.disconnect()\n this.watcher = undefined\n this.teardown()\n }\n\n /**\n * The board as a picture, for the card: the 3D view at this size, or nothing when it cannot be taken. The scene's\n * `toDataURL` renders the 2D board (a white sheet, V2 found), and the 3D renderer keeps no drawing buffer, so the\n * scene's own `snapshot3d` draws and reads in one task. A picture that cannot be taken is not an error and is not\n * faked (V2's `snapshot`, lost when this canvas moved onto the scene -- no card had a picture since, user 2026-09-24).\n */\n async snapshot(width = 480, height = 360): Promise<string | undefined> {\n const layer = this.scene?.root as (SceneLayer & { snapshot3d?: (w?: number, h?: number, type?: string, quality?: number) => Promise<string | undefined> }) | undefined\n if (!layer?.snapshot3d) return undefined\n try {\n /* webp: a card needs no alpha, and png is three or four times heavier in every list response. */\n const url = await layer.snapshot3d(width, height, 'image/webp', 0.85)\n return typeof url === 'string' && url.startsWith('data:') ? url : undefined\n } catch (e) {\n console.warn(`[thumbnail] could not take the picture -- ${(e as Error).message}`)\n return undefined\n }\n }\n\n /** The whole figure in view: the board's fit, then the 3D camera's own, as V2 did. */\n fit() {\n this.scene?.fit?.('ratio')\n this.scene?.root?.fitCameraToModel?.()\n }\n\n /**\n * Stand the board up for this figure, or bring the one standing up to date. A new board only for another figure or\n * one that has outgrown it -- standing up again loses the selection and the camera.\n */\n private standUp() {\n if (!this.stage) return\n const needed = boardFor(this.parts, this.board)\n const outgrown = !this.board || needed.width > this.board.width || needed.height > this.board.height || needed.depth > this.board.depth\n if (this.scene && this.standingFor === this.context) {\n /*\n A part dragged past the board's edge grows the board where it stands. Standing it up again lost the selection,\n the gizmo and the camera after every such drag -- the gizmo seemed not to work at all (user, 2026-09-24).\n */\n if (outgrown) this.grow(needed)\n this.sync()\n return\n }\n this.teardown()\n if (!this.parts.length) return\n this.board = needed\n try {\n this.scene = create({\n target: this.stage,\n model: {\n type: 'model-layer',\n width: needed.width,\n height: needed.height,\n depth: needed.depth,\n threed: true,\n /* Two samples a pixel: MSAA alone leaves steps on the silhouettes of one asset shown large (V2). */\n pixelRatio: Math.min(3, (window.devicePixelRatio || 1) * 2),\n ...sceneLook(this.view ?? DEFAULT_VIEW),\n gridStep: niceGridStep(Math.max(needed.width, needed.height)),\n sky: 'color',\n fillStyle: PAPER,\n components: this.components()\n },\n /* Editing mode: the camera view buttons, gizmo modes, help and keys V2's canvas had. */\n mode: 1\n }) as SceneHandle\n this.standingFor = this.context\n this.watchScene()\n this.scene.resize?.()\n this.fit()\n this.showSelected()\n } catch (error) {\n this.dispatchEvent(new CustomEvent('render-error', { detail: error, bubbles: true, composed: true }))\n }\n }\n\n private components(): Record<string, unknown>[] {\n const parts = this.parts.map(part => componentOf(part, this.palette, this.board!)).filter((c): c is Record<string, unknown> => !!c)\n /* The fan in the accent colour, translucent; `capturable: false` keeps clicks, the marquee and the gizmo off it. */\n const fan = this.fan ? componentOf(this.fan, { ...this.palette, [JOINT_FAN]: this.palette['palette.accent'] ?? FAN_COLOUR }, this.board!) : null\n return fan ? [...parts, { ...fan, capturable: false, locked: true }] : parts\n }\n\n /** The components standing now, by name. Not held between calls: the scene stands its board up again at times. */\n private standing(): Map<string, SceneComponent> {\n const found = new Map<string, SceneComponent>()\n for (const component of this.scene?.root?.components ?? []) {\n const name = component.state?.name\n if (typeof name === 'string') found.set(name, component)\n }\n return found\n }\n\n /** A larger board under the same scene: its size, and the grid that suits it. Components are re-placed by `sync`. */\n private grow(needed: Board & { depth: number }) {\n const layer = this.scene?.root\n this.board = needed\n if (!layer) return\n this.writing = true\n try {\n layer.set({ width: needed.width, height: needed.height, depth: needed.depth, gridStep: niceGridStep(Math.max(needed.width, needed.height)) })\n } finally {\n this.writing = false\n }\n }\n\n /** Bring the components to the evaluation: remove the gone, write only what differs, add the new. */\n private sync() {\n const layer = this.scene?.root\n if (!layer || !this.board) return\n const wanted = new Map(this.components().map(c => [c.name as string, c]))\n const standing = this.standing()\n this.writing = true\n try {\n for (const [name, component] of standing) {\n if (wanted.has(name)) continue\n layer.removeComponent?.(component)\n component.dispose?.()\n }\n for (const [name, state] of wanted) {\n const found = standing.get(name)\n if (found) {\n const diff = changedKeys(found.state, state)\n if (diff) found.set(diff)\n continue\n }\n const made = Model.compile({ ...state }, layer.app as never) as SceneComponent | null\n if (made) layer.addComponent?.(made)\n }\n } finally {\n this.writing = false\n }\n layer.invalidate?.()\n }\n\n /** Selection and drags, told out by the part's name -- never by its place in the list, which may change meanwhile. */\n private watchScene() {\n const layer = this.scene?.root\n const root = layer?.root\n if (!layer || !root?.on || this.viewOnly) return\n root.on('selected', (after: unknown) => {\n const name = (after as SceneComponent[] | undefined)?.[0]?.state?.name\n const id = typeof name === 'string' ? name : ''\n if (ownerOf(id) !== this.selected) this.dispatchEvent(new CustomEvent('part-selected', { detail: id, bubbles: true, composed: true }))\n })\n /*\n A change comes up to the board with the component in the last argument's `origin` (the scene appends\n { origin, name, deliverer } as it bubbles). Reading the first argument as the component does nothing (V2).\n */\n layer.on?.('change', (...args: unknown[]) => {\n if (this.writing) return\n const origin = (args[args.length - 1] as { origin?: SceneComponent } | undefined)?.origin\n const name = origin?.state?.name\n const part = typeof name === 'string' ? this.parts.find(p => p.id === name) : undefined\n if (!part || !this.board) return\n const result = gizmoResultOf(part, origin!.state, this.board)\n if (!result.position && !result.rotation && !result.scale) return\n this.dispatchEvent(new CustomEvent('part-transformed', { detail: { id: part.id, result }, bubbles: true, composed: true }))\n /* After the editor has applied (or refused) it: a refused change springs back to where the inputs put it. */\n setTimeout(() => this.sync())\n })\n }\n\n private showSelected() {\n const layer = this.scene?.root\n const root = layer?.root\n if (!layer || !root) return\n /* A repeat is selected whole: every copy of it (the editor selects the part the author made). */\n const wanted = this.selected ? [...this.standing()].filter(([name]) => ownerOf(name) === this.selected).map(([, component]) => component) : []\n const now = root.selected ?? []\n if (now.length === wanted.length && wanted.every((one, i) => now[i] === one)) return\n root.selected = wanted\n layer.invalidate?.()\n }\n\n /** View settings go into the scene as they are: they are the board's own state names. Nothing is stood up again. */\n private applyView() {\n const layer = this.scene?.root\n if (!layer) return\n layer.set(sceneLook(this.view ?? DEFAULT_VIEW))\n layer.invalidate?.()\n }\n\n private teardown() {\n this.scene?.dispose?.()\n this.scene = undefined\n this.standingFor = undefined\n this.board = undefined\n }\n}\n"]}
1
+ {"version":3,"file":"v3-canvas.js","sourceRoot":"","sources":["../../client/modeller/v3-canvas.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,E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B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;4CAAkC;AAMpC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;gDAAiB;AAEb;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;2CAAgC;AAElC;IAA5B,KAAK,CAAC,YAAY,CAAC;8BAAiB,cAAc;6CAAA;AA1CxC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA4T1B","sourcesContent":["import { LitElement, html, css, nothing, unsafeCSS, type PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { i18next } from '@operato/i18n'\nimport { create, Model, niceGridStep } from '@hatiolab/things-scene'\n\nimport type { GizmoReach } from './v3-gizmo.js'\nimport type { V3RenderPart } from './v3-renderer.js'\nimport { DEFAULT_VIEW, sceneLook, WORKBENCH, type ViewSettings } from './figure-view.js'\nimport { boardFor, changedKeys, componentOf, gizmoResultOf, type Board } from './v3-stage-model.js'\nimport { JOINT_FAN } from './v3-joint-fan.js'\nimport { ownerOf } from './v3-fields.js'\n\n/*\n * The V3 modeller's canvas -- a things-scene board in editing mode, as the V2 modeller's was.\n *\n * Each body figure-model evaluates stands on the board as a `figure-v3-part` component, so everything the V2 canvas\n * had comes from the scene, not from code of our own: picking and the orange outline, the gizmo with its snapping and\n * live readout, box and shift selection, the camera (damping, zoom toward the cursor, double-click to fit, the six\n * view presets and their keys), the studio environment, the coordinate ground, lights and shadows, supersampling.\n * An earlier canvas drew the bodies with three.js directly and lost all of that (user, 2026-09-24: \"why nerf it?\").\n *\n * What the gizmo writes back to a component comes out as `part-transformed` in the inputs' terms (`v3-stage-model`),\n * and the editor turns it into one step of the history; the next evaluation puts the component where the inputs say,\n * so a change a part cannot take (a fastened part moved) springs back.\n */\n\ninterface SceneComponent {\n state: Record<string, unknown>\n set: (props: Record<string, unknown>) => void\n dispose?: () => void\n}\ninterface SceneLayer extends SceneComponent {\n components?: SceneComponent[]\n root?: { on?: (event: string, handler: (...args: unknown[]) => void) => void; selected?: SceneComponent[] }\n on?: (event: string, handler: (...args: unknown[]) => void) => void\n addComponent?: (component: SceneComponent) => void\n removeComponent?: (component: SceneComponent) => void\n invalidate?: () => void\n fitCameraToModel?: () => void\n setGizmoMode?: (mode: 'translate' | 'rotate' | 'scale') => void\n app?: unknown\n}\ninterface SceneHandle {\n dispose?: () => void\n resize?: () => void\n fit?: (type?: string) => void\n root?: SceneLayer\n}\n\n/* The fan's colour when the figure's palette names no accent. */\nconst FAN_COLOUR = '#ff8a00'\n\n/* The 2D side of the board, which the author never sees on this page but the scene paints. */\nconst PAPER = '#ffffff'\n\n@customElement('figure-v3-canvas')\nexport class FigureV3Canvas extends LitElement {\n static styles = css`\n :host {\n position: relative;\n display: flex;\n min-height: 0;\n overflow: hidden;\n background-color: ${unsafeCSS(WORKBENCH)};\n }\n /* The scene sets position: relative inline on its target; the size is given so it still fills the host. */\n div[stage] {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n }\n p {\n position: absolute;\n inset: 45% 1rem auto;\n margin: 0;\n text-align: center;\n pointer-events: none;\n color: #f4f4f4;\n }\n `\n @property({ attribute: false }) parts: V3RenderPart[] = []\n @property({ attribute: false }) palette: Record<string, string> = {}\n /** Which figure is open. Another one stands the board up again. */\n @property() context = ''\n @property() selected = ''\n /** What the gizmo may write for the selected part; a change beyond it is not applied and the part springs back. */\n @property({ attribute: false }) reach: GizmoReach = { translate: false, rotate: false, scale: false }\n @property({ attribute: false }) view: ViewSettings = DEFAULT_VIEW\n /**\n * View only: nothing that happens on the board is told out. The card's picture is taken from a second canvas stood up\n * off screen (`v3-thumbnail.ts`); the scene settles its components as it builds them, and a change told from there\n * would reach the editor as an edit (V2's `viewOnly`, for the same reason).\n */\n @property({ type: Boolean }) viewOnly = false\n /** Where the selected part turns and how far (`v3-joint-fan`): shown, never picked, never saved. */\n @property({ attribute: false }) fan: V3RenderPart | null = null\n\n @query('div[stage]') private stage!: HTMLDivElement\n\n private scene?: SceneHandle\n private board?: Board & { depth: number }\n private standingFor?: string\n private watcher?: ResizeObserver\n /** Set while this canvas writes to components, so the scene's echo of it is not taken for a drag. */\n private writing = false\n\n render() {\n return html`<div stage></div>${this.parts.length ? nothing : html`<p>${i18next.t('figure.text.add-a-shape-to-start')}</p>`}`\n }\n\n firstUpdated() {\n this.standUp()\n this.watcher = new ResizeObserver(() => this.scene?.resize?.())\n this.watcher.observe(this)\n }\n\n protected updated(changed: PropertyValues) {\n if (!this.hasUpdated) return\n if (changed.has('parts') || changed.has('palette') || changed.has('context') || changed.has('fan')) this.standUp()\n if (changed.has('view')) this.applyView()\n if (changed.has('selected')) this.showSelected()\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this.watcher?.disconnect()\n this.watcher = undefined\n this.teardown()\n }\n\n /**\n * The board as a picture, for the card: the 3D view at this size, or nothing when it cannot be taken. The scene's\n * `toDataURL` renders the 2D board (a white sheet, V2 found), and the 3D renderer keeps no drawing buffer, so the\n * scene's own `snapshot3d` draws and reads in one task. A picture that cannot be taken is not an error and is not\n * faked (V2's `snapshot`, lost when this canvas moved onto the scene -- no card had a picture since, user 2026-09-24).\n */\n async snapshot(width = 480, height = 360): Promise<string | undefined> {\n const layer = this.scene?.root as (SceneLayer & { snapshot3d?: (w?: number, h?: number, type?: string, quality?: number) => Promise<string | undefined> }) | undefined\n if (!layer?.snapshot3d) return undefined\n try {\n /* webp: a card needs no alpha, and png is three or four times heavier in every list response. */\n const url = await layer.snapshot3d(width, height, 'image/webp', 0.85)\n return typeof url === 'string' && url.startsWith('data:') ? url : undefined\n } catch (e) {\n console.warn(`[thumbnail] could not take the picture -- ${(e as Error).message}`)\n return undefined\n }\n }\n\n /** The whole figure in view: the board's fit, then the 3D camera's own, as V2 did. */\n fit() {\n this.scene?.fit?.('ratio')\n this.scene?.root?.fitCameraToModel?.()\n }\n\n /** The gizmo in a mode on the selected part, as W, E and R do with the canvas focused -- the scene's toggle. */\n gizmo(mode: 'translate' | 'rotate' | 'scale') {\n this.scene?.root?.setGizmoMode?.(mode)\n }\n\n /**\n * Stand the board up for this figure, or bring the one standing up to date. A new board only for another figure or\n * one that has outgrown it -- standing up again loses the selection and the camera.\n */\n private standUp() {\n if (!this.stage) return\n const needed = boardFor(this.parts, this.board)\n const outgrown = !this.board || needed.width > this.board.width || needed.height > this.board.height || needed.depth > this.board.depth\n if (this.scene && this.standingFor === this.context) {\n /*\n A part dragged past the board's edge grows the board where it stands. Standing it up again lost the selection,\n the gizmo and the camera after every such drag -- the gizmo seemed not to work at all (user, 2026-09-24).\n */\n if (outgrown) this.grow(needed)\n this.sync()\n return\n }\n this.teardown()\n if (!this.parts.length) return\n this.board = needed\n try {\n this.scene = create({\n target: this.stage,\n model: {\n type: 'model-layer',\n width: needed.width,\n height: needed.height,\n depth: needed.depth,\n threed: true,\n /* Two samples a pixel: MSAA alone leaves steps on the silhouettes of one asset shown large (V2). */\n pixelRatio: Math.min(3, (window.devicePixelRatio || 1) * 2),\n ...sceneLook(this.view ?? DEFAULT_VIEW),\n gridStep: niceGridStep(Math.max(needed.width, needed.height)),\n sky: 'color',\n fillStyle: PAPER,\n components: this.components()\n },\n /* Editing mode: the camera view buttons, gizmo modes, help and keys V2's canvas had. */\n mode: 1\n }) as SceneHandle\n this.standingFor = this.context\n this.watchScene()\n this.scene.resize?.()\n this.fit()\n this.showSelected()\n } catch (error) {\n this.dispatchEvent(new CustomEvent('render-error', { detail: error, bubbles: true, composed: true }))\n }\n }\n\n private components(): Record<string, unknown>[] {\n const parts = this.parts.map(part => componentOf(part, this.palette, this.board!)).filter((c): c is Record<string, unknown> => !!c)\n /* The fan in the accent colour, translucent; `capturable: false` keeps clicks, the marquee and the gizmo off it. */\n const fan = this.fan ? componentOf(this.fan, { ...this.palette, [JOINT_FAN]: this.palette['palette.accent'] ?? FAN_COLOUR }, this.board!) : null\n return fan ? [...parts, { ...fan, capturable: false, locked: true }] : parts\n }\n\n /** The components standing now, by name. Not held between calls: the scene stands its board up again at times. */\n private standing(): Map<string, SceneComponent> {\n const found = new Map<string, SceneComponent>()\n for (const component of this.scene?.root?.components ?? []) {\n const name = component.state?.name\n if (typeof name === 'string') found.set(name, component)\n }\n return found\n }\n\n /** A larger board under the same scene: its size, and the grid that suits it. Components are re-placed by `sync`. */\n private grow(needed: Board & { depth: number }) {\n const layer = this.scene?.root\n this.board = needed\n if (!layer) return\n this.writing = true\n try {\n layer.set({ width: needed.width, height: needed.height, depth: needed.depth, gridStep: niceGridStep(Math.max(needed.width, needed.height)) })\n } finally {\n this.writing = false\n }\n }\n\n /** Bring the components to the evaluation: remove the gone, write only what differs, add the new. */\n private sync() {\n const layer = this.scene?.root\n if (!layer || !this.board) return\n const wanted = new Map(this.components().map(c => [c.name as string, c]))\n const standing = this.standing()\n this.writing = true\n try {\n for (const [name, component] of standing) {\n if (wanted.has(name)) continue\n layer.removeComponent?.(component)\n component.dispose?.()\n }\n for (const [name, state] of wanted) {\n const found = standing.get(name)\n if (found) {\n const diff = changedKeys(found.state, state)\n if (diff) found.set(diff)\n continue\n }\n const made = Model.compile({ ...state }, layer.app as never) as SceneComponent | null\n if (made) layer.addComponent?.(made)\n }\n } finally {\n this.writing = false\n }\n layer.invalidate?.()\n }\n\n /** Selection and drags, told out by the part's name -- never by its place in the list, which may change meanwhile. */\n private watchScene() {\n const layer = this.scene?.root\n const root = layer?.root\n if (!layer || !root?.on || this.viewOnly) return\n root.on('selected', (after: unknown) => {\n const name = (after as SceneComponent[] | undefined)?.[0]?.state?.name\n const id = typeof name === 'string' ? name : ''\n if (ownerOf(id) !== this.selected) this.dispatchEvent(new CustomEvent('part-selected', { detail: id, bubbles: true, composed: true }))\n })\n /*\n A change comes up to the board with the component in the last argument's `origin` (the scene appends\n { origin, name, deliverer } as it bubbles). Reading the first argument as the component does nothing (V2).\n */\n /*\n A drag is written once, when it ends. The scene's gizmo writes the component on every move -- a size anchored on\n the opposite face, from the scale it captured when the drag began -- and writing each move back through the\n editor (and the evaluation back onto the component) fought it: the scale gizmo did not work (user, 2026-09-24).\n While a pointer is down the changes are only kept; on release the last one is told, and the board is brought to\n the evaluation. A change with no pointer down (the arrow keys) is told after a short pause.\n */\n layer.on?.('change', (...args: unknown[]) => {\n if (this.writing) return\n const origin = (args[args.length - 1] as { origin?: SceneComponent } | undefined)?.origin\n const name = origin?.state?.name\n if (typeof name !== 'string' || !this.parts.some(p => p.id === name)) return\n this.pending.set(name, origin!)\n if (!this.pointerDown) this.commitSoon(80)\n })\n this.stage.addEventListener('pointerdown', this.onPointerDown, true)\n window.addEventListener('pointerup', this.onPointerUp, true)\n window.addEventListener('pointercancel', this.onPointerUp, true)\n }\n\n /** Components the gizmo changed since the last commit, by part name. */\n private pending = new Map<string, SceneComponent>()\n private pointerDown = false\n private commitTimer?: ReturnType<typeof setTimeout>\n private onPointerDown = () => {\n this.pointerDown = true\n }\n private onPointerUp = () => {\n if (!this.pointerDown) return\n this.pointerDown = false\n /* After the scene's own drag end (it settles the depth and rebuilds the geometry on release). */\n this.commitSoon(0)\n }\n private commitSoon(delay: number) {\n clearTimeout(this.commitTimer)\n this.commitTimer = setTimeout(() => this.commit(), delay)\n }\n /** Tell each changed part once, in the inputs' terms; then put the board where the inputs say (a refusal springs back). */\n private commit() {\n /*\n Not while a pointer is down: a pause set by a change just before the press (the arrow keys, the scene settling\n the pick) fired in the middle of the drag and wrote where the part was then -- a drag on a converted part became\n two steps, the first one a few millimetres in (browser check, 2026-09-25). What is pending waits for the release.\n */\n if (this.pointerDown || !this.board || !this.pending.size) return\n const changed = [...this.pending]\n this.pending.clear()\n for (const [name, component] of changed) {\n const part = this.parts.find(p => p.id === name)\n if (!part) continue\n const result = gizmoResultOf(part, component.state, this.board)\n if (!result.position && !result.rotation && !result.scale) continue\n this.dispatchEvent(new CustomEvent('part-transformed', { detail: { id: part.id, result }, bubbles: true, composed: true }))\n }\n setTimeout(() => this.sync())\n }\n\n private showSelected() {\n const layer = this.scene?.root\n const root = layer?.root\n if (!layer || !root) return\n /* A repeat is selected whole: every copy of it (the editor selects the part the author made). */\n const wanted = this.selected ? [...this.standing()].filter(([name]) => ownerOf(name) === this.selected).map(([, component]) => component) : []\n const now = root.selected ?? []\n if (now.length === wanted.length && wanted.every((one, i) => now[i] === one)) return\n root.selected = wanted\n layer.invalidate?.()\n }\n\n /** View settings go into the scene as they are: they are the board's own state names. Nothing is stood up again. */\n private applyView() {\n const layer = this.scene?.root\n if (!layer) return\n layer.set(sceneLook(this.view ?? DEFAULT_VIEW))\n layer.invalidate?.()\n }\n\n private teardown() {\n clearTimeout(this.commitTimer)\n this.pending.clear()\n this.stage?.removeEventListener('pointerdown', this.onPointerDown, true)\n window.removeEventListener('pointerup', this.onPointerUp, true)\n window.removeEventListener('pointercancel', this.onPointerUp, true)\n this.scene?.dispose?.()\n this.scene = undefined\n this.standingFor = undefined\n this.board = undefined\n }\n}\n"]}
@@ -34,6 +34,6 @@ export declare const trackEdit: (clip: Clip, track: ClipTrack, patch?: Partial<P
34
34
  state: string;
35
35
  clip: string;
36
36
  keys: ClipKey[];
37
- loop: "hold" | "wrap";
37
+ loop: "wrap" | "hold";
38
38
  interpolation: "linear" | "step";
39
39
  };
@@ -11,6 +11,7 @@ import './figure-v3-preview.js';
11
11
  import './figure-settings.js';
12
12
  import './figure-v3-capability.js';
13
13
  import type { V3BudgetLine } from './v3-maturity.js';
14
+ import type { FirstSave } from './v3-first-save.js';
14
15
  /** Product editor surface. The injected session is shared by page persistence and AI commands. */
15
16
  export declare class FigureV3Editor extends LitElement {
16
17
  static styles: import("lit").CSSResult[];
@@ -20,6 +21,11 @@ export declare class FigureV3Editor extends LitElement {
20
21
  instances?: number;
21
22
  /** The cost line the parts list shows, from the maturity report. */
22
23
  budget?: V3BudgetLine;
24
+ /**
25
+ * Asks the type and name of a figure saved for the first time (the host has the catalogue's names); undefined
26
+ * when the author cancels, and then nothing is saved. Without it a new figure is saved under a temporary type.
27
+ */
28
+ firstSave?: (name: string) => Promise<FirstSave | undefined>;
23
29
  private selected;
24
30
  private error;
25
31
  private tab;
@@ -42,7 +48,7 @@ export declare class FigureV3Editor extends LitElement {
42
48
  /** A value in hand -- typed, held on a spinner, scrubbed, dragged -- drawn at once and recorded on release. */
43
49
  private live;
44
50
  private lastContext;
45
- /** The modeller's keys (`v3-keys.ts`): undo, redo, duplicate, remove, back to the whole figure. */
51
+ /** The modeller's keys (`v3-keys.ts`): undo, redo, duplicate, remove, back to the whole figure, the gizmo's modes. */
46
52
  private onKey;
47
53
  connectedCallback(): void;
48
54
  disconnectedCallback(): void;
@@ -55,6 +61,12 @@ export declare class FigureV3Editor extends LitElement {
55
61
  * fan follows the arm while a control is dragged. Its size comes from what the joint turns (`v3-joint-fan`).
56
62
  */
57
63
  private fanOf;
64
+ /**
65
+ * Every input as the session holds it now -- the pose the author has set with the controls, and design values. The
66
+ * asset's source carries only the saved defaults, so drawing a value in hand over it put every other joint back to its
67
+ * saved angle while one slider moved, and the arm jumped when released (user, 2026-09-24).
68
+ */
69
+ private currentInputs;
58
70
  /** A value in hand: an input's value (design or pose) or a part edit. Nothing is recorded. */
59
71
  private hold;
60
72
  private changed;
@@ -21,12 +21,15 @@ import { gizmoChanges, gizmoReachOf } from './v3-gizmo.js';
21
21
  import { keyActionOf } from './v3-keys.js';
22
22
  import { groupFields, ownerOf, partLabelOf, repeatOf } from './v3-fields.js';
23
23
  import { SidePanelStyles } from './side-panel-styles.js';
24
+ import { ScrollbarStyles } from '@operato/styles';
24
25
  import { alignChanges, boxOf, canMirror, mirrorChanges } from './v3-align.js';
25
26
  import { paletteRecipe } from './v3-palette.js';
26
27
  import { nudgeOf } from './v3-stage-model.js';
28
+ import { sizeRangeRefusalOf } from './v3-refusals.js';
27
29
  import { instanceRangeOf, rangeDiffers, turnsAboutAJoint } from './v3-links.js';
28
30
  import { jointFanOf } from './v3-joint-fan.js';
29
- import { isLive, livePartsOf, NOTHING_LIVE, scrubbed, scrubStep } from './v3-live.js';
31
+ import { jointDragOf } from './v3-joint-drag.js';
32
+ import { liveOverSession, NOTHING_LIVE, scrubbed, scrubStep } from './v3-live.js';
30
33
  /** Product editor surface. The injected session is shared by page persistence and AI commands. */
31
34
  let FigureV3Editor = class FigureV3Editor extends LitElement {
32
35
  constructor() {
@@ -50,16 +53,26 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
50
53
  /** A value in hand -- typed, held on a spinner, scrubbed, dragged -- drawn at once and recorded on release. */
51
54
  this.live = NOTHING_LIVE;
52
55
  this.lastContext = null;
53
- /** The modeller's keys (`v3-keys.ts`): undo, redo, duplicate, remove, back to the whole figure. */
56
+ /** The modeller's keys (`v3-keys.ts`): undo, redo, duplicate, remove, back to the whole figure, the gizmo's modes. */
54
57
  this.onKey = (e) => {
55
58
  const view = this.session?.read();
56
59
  if (!view || view.loading || view.saving || !view.context || !this.isConnected)
57
60
  return;
58
- const action = keyActionOf({ key: e.key, ctrlKey: e.ctrlKey, metaKey: e.metaKey, shiftKey: e.shiftKey, altKey: e.altKey, target: e.composedPath()[0] }, this.selected);
61
+ const canvas = this.renderRoot.querySelector('figure-v3-canvas');
62
+ const path = e.composedPath();
63
+ const action = keyActionOf({ key: e.key, ctrlKey: e.ctrlKey, metaKey: e.metaKey, shiftKey: e.shiftKey, altKey: e.altKey, target: path[0], inScene: !!canvas && path.includes(canvas) }, this.selected);
59
64
  if (!action)
60
65
  return;
61
66
  e.preventDefault();
62
- if (action === 'undo')
67
+ /*
68
+ The session's history is the only one. With the canvas focused the scene took Ctrl+Z as well, undoing on its own
69
+ board the last value the canvas had written -- which the canvas then told as a drag: an undo of a drag on a
70
+ converted part wrote the drag again (2026-09-25). Heard first (capture) and kept from the scene.
71
+ */
72
+ e.stopPropagation();
73
+ if (action === 'translate' || action === 'rotate' || action === 'scale')
74
+ canvas?.gizmo(action);
75
+ else if (action === 'undo')
63
76
  view.canUndo && this.run(() => this.session.undo());
64
77
  else if (action === 'redo')
65
78
  view.canRedo && this.run(() => this.session.redo());
@@ -72,7 +85,8 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
72
85
  };
73
86
  }
74
87
  static { FigureV3Editor_1 = this; }
75
- static { this.styles = [SidePanelStyles, css `
88
+ /* The operato scrollbar, as every scrolling panel of the app has it -- the side panel scrolled with the browser's own. */
89
+ static { this.styles = [ScrollbarStyles, SidePanelStyles, css `
76
90
  :host {
77
91
  display: flex;
78
92
  flex-direction: column;
@@ -268,10 +282,10 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
268
282
  }
269
283
  connectedCallback() {
270
284
  super.connectedCallback();
271
- window.addEventListener('keydown', this.onKey);
285
+ window.addEventListener('keydown', this.onKey, true);
272
286
  }
273
287
  disconnectedCallback() {
274
- window.removeEventListener('keydown', this.onKey);
288
+ window.removeEventListener('keydown', this.onKey, true);
275
289
  super.disconnectedCallback();
276
290
  }
277
291
  willUpdate(_changed) {
@@ -292,7 +306,7 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
292
306
  this.changed();
293
307
  }
294
308
  catch (error) {
295
- this.error = error instanceof Error ? error.message : String(error);
309
+ this.error = sizeRangeRefusalOf(error, (key, params) => i18next.t(key, params)) ?? (error instanceof Error ? error.message : String(error));
296
310
  }
297
311
  finally {
298
312
  /* Committed or refused, the value in hand is gone: the figure as it stands is drawn again. */
@@ -301,7 +315,7 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
301
315
  }
302
316
  /** What the canvas draws: the figure with the value in hand when there is one, and without the parts hidden on the workbench. */
303
317
  drawnParts(geometry, asset) {
304
- const parts = (isLive(this.live) && asset ? livePartsOf(asset, this.live) : null) ?? drawableV3Parts(geometry ?? []);
318
+ const parts = (asset ? liveOverSession(asset, this.currentInputs(), this.live) : null) ?? drawableV3Parts(geometry ?? []);
305
319
  return parts.filter(body => !this.hiddenParts.has(ownerOf(body.id)));
306
320
  }
307
321
  /**
@@ -312,12 +326,21 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
312
326
  if (!asset || !this.selected || this.hiddenParts.has(this.selected))
313
327
  return null;
314
328
  try {
315
- return jointFanOf(asset, this.selected, this.live.values);
329
+ return jointFanOf(asset, this.selected, { ...this.currentInputs(), ...this.live.values });
316
330
  }
317
331
  catch {
318
332
  return null;
319
333
  }
320
334
  }
335
+ /**
336
+ * Every input as the session holds it now -- the pose the author has set with the controls, and design values. The
337
+ * asset's source carries only the saved defaults, so drawing a value in hand over it put every other joint back to its
338
+ * saved angle while one slider moved, and the arm jumped when released (user, 2026-09-24).
339
+ */
340
+ currentInputs() {
341
+ const view = this.session?.read();
342
+ return view ? Object.fromEntries(view.fields.map(field => [field.id, field.value])) : {};
343
+ }
321
344
  /** A value in hand: an input's value (design or pose) or a part edit. Nothing is recorded. */
322
345
  hold(values, edit) {
323
346
  this.live = { values: { ...this.live.values, ...values }, ...(edit ? { edit } : this.live.edit ? { edit: this.live.edit } : {}) };
@@ -335,9 +358,21 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
335
358
  not from the one on screen, which stands wherever the author left it turned. A picture that cannot
336
359
  be taken is not an error: the save goes on without it (see `v3-thumbnail.ts`).
337
360
  */
361
+ let type;
362
+ if (!this.session.read().id && this.firstSave) {
363
+ const answer = await this.firstSave(this.session.read().name ?? '');
364
+ if (!answer)
365
+ return;
366
+ /* The name is the figure's own, in the asset: one step of the history, like typing it in the properties. */
367
+ if (answer.name !== this.session.read().name) {
368
+ this.session.command({ kind: 'rename', name: answer.name });
369
+ this.changed();
370
+ }
371
+ type = answer.type;
372
+ }
338
373
  const view = this.session.read();
339
374
  const thumbnail = await captureV3Thumbnail(drawableV3Parts(view.geometry ?? []), view.palette ?? {});
340
- const promise = this.session.save({ thumbnail });
375
+ const promise = this.session.save({ thumbnail, type });
341
376
  this.changed();
342
377
  await promise;
343
378
  this.error = '';
@@ -418,12 +453,39 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
418
453
  /** A drag, written back as the part's own inputs — one step of the history, like typing the numbers. */
419
454
  transformed(id, result) {
420
455
  const view = this.session.read();
456
+ /* A part hanging from a joint: the drag edits the joint -- its value, or where it sits (ADR-0093). */
457
+ const asset = JSON.parse(this.session.source());
458
+ const drawn = view.geometry.find(g => g.id === id);
459
+ const drag = drawn ? jointDragOf(asset, ownerOf(id), drawn, result, this.currentInputs()) : null;
460
+ if (drag) {
461
+ if (drag.kind === 'value')
462
+ this.run(() => this.session.apply([{ kind: 'set-state', input: drag.input, unit: drag.unit, value: drag.value }]));
463
+ else if (drag.kind === 'joint')
464
+ this.run(() => this.session.command({ kind: 'set-joint', joint: drag.joint }));
465
+ else {
466
+ this.error = i18next.t(`figure.text.gizmo-joint-${drag.reason}`, { joint: drag.joint, leader: drag.leader ?? '', axis: drag.axis ?? '' });
467
+ this.requestUpdate();
468
+ }
469
+ return;
470
+ }
421
471
  const sizes = Object.fromEntries(view.fields.map(field => [field.id, field.value]));
422
- const changes = gizmoChanges(id, this.reachOf(id), result, sizes);
472
+ /*
473
+ A part a joint places, scaled: only its measures change. The shift of its centre that an anchored scale makes is
474
+ the joint's to give -- the face on the joint stays there by itself (user, 2026-09-25: 「'R'모드에서 크기가 변하지 않는다」;
475
+ the shift had been taken for a move of the joint, and the size was dropped).
476
+ */
477
+ const jointed = !!asset.joints?.some(j => j.body1.part === ownerOf(id));
478
+ const changes = gizmoChanges(id, this.reachOf(id), jointed && result.scale ? { scale: result.scale } : result, sizes);
423
479
  if (changes.length) {
424
480
  this.run(() => this.session.apply(changes));
425
481
  return;
426
482
  }
483
+ if (jointed && result.scale) {
484
+ /* Only measures that follow another were pulled: the relation says their size, and it is not broken here. */
485
+ const axes = ['x', 'y', 'z'].filter((_, i) => Math.abs(result.scale[i] - 1) > 1e-4);
486
+ this.error = i18next.t('figure.text.gizmo-size-follows', { part: partLabelOf(id), axis: axes.join(', ').toUpperCase() });
487
+ return this.requestUpdate();
488
+ }
427
489
  /*
428
490
  A part whose place is worked out (a converted one) has no numbers for the gizmo to write: the drag is added beside
429
491
  its rule (`nudge-part`). A part a joint or a fastening places, or a size that is worked out, is refused -- said in
@@ -432,15 +494,21 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
432
494
  const body = view.geometry.find(g => g.id === id);
433
495
  if (!body)
434
496
  return this.requestUpdate();
435
- if (result.scale && !result.position && !result.rotation) {
436
- this.error = i18next.t('figure.text.gizmo-size-worked-out', { part: partLabelOf(id) });
437
- return this.requestUpdate();
438
- }
439
497
  const { by, turn } = nudgeOf(body, result);
440
- if (!Object.keys(by).length && !Object.keys(turn).length)
498
+ /* A size worked out from the figure's: the drag's factor beside its rule, so it still follows (V2 scaled any part). */
499
+ const grow = {};
500
+ if (result.scale)
501
+ ['x', 'y', 'z'].forEach((axis, i) => Math.abs(result.scale[i] - 1) > 1e-6 && (grow[axis] = Math.round(result.scale[i] * 1e6) / 1e6));
502
+ if (!Object.keys(by).length && !Object.keys(turn).length && !Object.keys(grow).length)
441
503
  return this.requestUpdate();
442
504
  try {
443
- this.session.command({ kind: 'nudge-part', part: id, ...(Object.keys(by).length ? { by } : {}), ...(Object.keys(turn).length ? { turn } : {}) });
505
+ this.session.command({
506
+ kind: 'nudge-part',
507
+ part: id,
508
+ ...(Object.keys(by).length ? { by } : {}),
509
+ ...(Object.keys(turn).length ? { turn } : {}),
510
+ ...(Object.keys(grow).length ? { grow } : {})
511
+ });
444
512
  this.error = '';
445
513
  this.changed();
446
514
  }
@@ -611,9 +679,7 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
611
679
  ? i18next.t('figure.text.follow-would-loop')
612
680
  : code === 'FASTEN_CYCLE' || code === 'ATTACH_CYCLE'
613
681
  ? i18next.t('figure.text.fasten-would-loop')
614
- : error instanceof Error
615
- ? error.message
616
- : String(error);
682
+ : sizeRangeRefusalOf(error, (key, params) => i18next.t(key, params)) ?? (error instanceof Error ? error.message : String(error));
617
683
  }
618
684
  }
619
685
  changeField(field, event) {
@@ -803,6 +869,11 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
803
869
  })
804
870
  : i18next.t(fits ? 'figure.text.repeat-fits-length' : 'figure.text.repeat-fixed-count')}
805
871
  </p>
872
+ ${asset.joints?.some(j => j.body1.part === this.selected && j.repeat)
873
+ ? html `<button act ?disabled=${unavailable} @click=${() => this.run(() => this.session.command({ kind: 'remove-repeat', part: this.selected }))}>
874
+ <md-icon>close</md-icon>${i18next.t('figure.button.remove-repeat')}
875
+ </button>`
876
+ : nothing}
806
877
  </section>`;
807
878
  }
808
879
  /**
@@ -1079,6 +1150,10 @@ __decorate([
1079
1150
  property({ attribute: false }),
1080
1151
  __metadata("design:type", Object)
1081
1152
  ], FigureV3Editor.prototype, "budget", void 0);
1153
+ __decorate([
1154
+ property({ attribute: false }),
1155
+ __metadata("design:type", Function)
1156
+ ], FigureV3Editor.prototype, "firstSave", void 0);
1082
1157
  __decorate([
1083
1158
  state(),
1084
1159
  __metadata("design:type", Object)