@things-factory/figure-ui 10.1.113 → 10.1.115

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 (49) hide show
  1. package/client/modeller/canvas.ts +6 -0
  2. package/client/modeller/editor.ts +40 -5
  3. package/client/modeller/face-mapping.ts +39 -0
  4. package/client/modeller/figure-face-mapping.ts +78 -0
  5. package/client/modeller/figure-preview.ts +34 -10
  6. package/client/modeller/figure-section-editor.ts +12 -4
  7. package/client/modeller/figure-section-panel.ts +5 -1
  8. package/client/modeller/preview-model.ts +8 -0
  9. package/client/pages/figure-modeller-page.ts +7 -1
  10. package/dist-client/modeller/canvas.js +7 -0
  11. package/dist-client/modeller/canvas.js.map +1 -1
  12. package/dist-client/modeller/editor.d.ts +4 -0
  13. package/dist-client/modeller/editor.js +41 -5
  14. package/dist-client/modeller/editor.js.map +1 -1
  15. package/dist-client/modeller/face-mapping.d.ts +15 -0
  16. package/dist-client/modeller/face-mapping.js +20 -0
  17. package/dist-client/modeller/face-mapping.js.map +1 -0
  18. package/dist-client/modeller/figure-face-mapping.d.ts +16 -0
  19. package/dist-client/modeller/figure-face-mapping.js +85 -0
  20. package/dist-client/modeller/figure-face-mapping.js.map +1 -0
  21. package/dist-client/modeller/figure-preview.d.ts +2 -0
  22. package/dist-client/modeller/figure-preview.js +38 -10
  23. package/dist-client/modeller/figure-preview.js.map +1 -1
  24. package/dist-client/modeller/figure-section-editor.d.ts +4 -1
  25. package/dist-client/modeller/figure-section-editor.js +14 -3
  26. package/dist-client/modeller/figure-section-editor.js.map +1 -1
  27. package/dist-client/modeller/figure-section-panel.d.ts +4 -1
  28. package/dist-client/modeller/figure-section-panel.js +6 -0
  29. package/dist-client/modeller/figure-section-panel.js.map +1 -1
  30. package/dist-client/modeller/preview-model.d.ts +5 -0
  31. package/dist-client/modeller/preview-model.js +7 -0
  32. package/dist-client/modeller/preview-model.js.map +1 -1
  33. package/dist-client/pages/figure-modeller-page.d.ts +1 -0
  34. package/dist-client/pages/figure-modeller-page.js +7 -1
  35. package/dist-client/pages/figure-modeller-page.js.map +1 -1
  36. package/dist-client/route.d.ts +1 -1
  37. package/dist-client/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +6 -6
  39. package/test/browser/acceptance-page.js +11 -0
  40. package/test/clip-consent.test.ts +1 -1
  41. package/test/face-mapping.test.ts +80 -0
  42. package/test/modeller-route.test.ts +8 -0
  43. package/test/preview.test.ts +39 -1
  44. package/test/section-panel.test.ts +1 -1
  45. package/translations/en.json +7 -1
  46. package/translations/ja.json +7 -1
  47. package/translations/ko.json +7 -1
  48. package/translations/ms.json +7 -1
  49. package/translations/zh.json +7 -1
@@ -280,6 +280,12 @@ export class FigureCanvas extends LitElement {
280
280
  const root = layer?.root
281
281
  if (!layer || !root?.on || this.viewOnly) return
282
282
  root.on('selected', (after: unknown) => {
283
+ /*
284
+ A canvas taken off the screen disposes its scene, and the scene empties its selection as it goes. Told out,
285
+ that emptied the editor's choice whenever the middle turned to the preview (U03): the listener lit set on this
286
+ element hears it even after it left the page. A canvas not on the page has nothing to say about the choice.
287
+ */
288
+ if (!this.isConnected) return
283
289
  const name = (after as SceneComponent[] | undefined)?.[0]?.state?.name
284
290
  const id = typeof name === 'string' ? name : ''
285
291
  if (ownerOf(id) !== this.selected) this.dispatchEvent(new CustomEvent('part-selected', { detail: id, bubbles: true, composed: true }))
@@ -9,7 +9,7 @@ import { live } from 'lit/directives/live.js'
9
9
  import { PART_LIMIT, parseFigureRecipe, resolveFigureRecipe, figurePartCountOf, figureRecipeIdFor, parseFigureAsset, figureSizeEditChanges, figureScaleAnchorOf, figureSectionMeasuresOf, figurePlaneAlignChanges, type FigurePlaneContact, type FigureClipLoss, figurePartFaceOf, type FigureFaceArea, figureRowOf, type FigureRowReading, figureFaceOverhangOf, type FigureFaceOverhang, figureRoomOnlyInputsOf, figureRoomRefitOf } from '@hatiolab/figure-model'
10
10
  import type { RecipeTemplate } from './recipes.js'
11
11
  import './figure-recipe-catalog.js'
12
- import type { FigureAsset, FigureAuthoringAction, FigureEvaluatedShape, FigureInputChange, FigurePartEdit, FigurePrimitiveCreation, FigureProposalStep, FigureRecipe, FigureRecipeValue, FigurePlacement } from '@hatiolab/figure-model'
12
+ import type { FigureAsset, FigureAuthoringAction, FigureEvaluatedShape, FigureInputChange, FigurePartEdit, FigurePrimitiveCreation, FigureProposalStep, FigureRecipe, FigureRecipeValue, FigurePlacement, FigureFaceMappingNeed, FigureFaceRemap } from '@hatiolab/figure-model'
13
13
  import type { FigureProductSession } from './product-session.js'
14
14
  import { captureFigureThumbnail } from './thumbnail.js'
15
15
  import { drawableFigureParts } from './renderer.js'
@@ -396,6 +396,12 @@ export class FigureEditor extends LitElement {
396
396
  @property({ attribute: false }) firstSave?: (name: string) => Promise<FirstSave | undefined>
397
397
  @state() private selected = ''
398
398
  @state() private error = ''
399
+ /*
400
+ * An edit that takes a face away which something stands on (ADR-0100 A8): held, with what the kernel says stands
401
+ * there, until the author chooses where each goes -- then the same edit goes again with the remap. Shown where the
402
+ * edit was made (`from`).
403
+ */
404
+ @state() private faceMapping?: { action: FigureAuthoringAction; need: FigureFaceMappingNeed; from: 'section-editor' | 'panel' }
399
405
  /** The same link offered again with the size range narrowed, after a link the declared range could not hold. */
400
406
  @state() private retry?: { label: string; action?: FigureAuthoringAction; run?: () => void }
401
407
  @state() private tab: SideTab = 'properties'
@@ -1168,7 +1174,15 @@ export class FigureEditor extends LitElement {
1168
1174
  ></figure-clips>`
1169
1175
  }
1170
1176
  /** One command, one step of the history. A refusal a person can meet here is said in their words. */
1171
- private linkCommand(action: FigureAuthoringAction) {
1177
+ /** Where a held edit goes once the author has chosen where what stands on its lost faces goes. */
1178
+ private mapFaces(remap: FigureFaceRemap[]) {
1179
+ const held = this.faceMapping
1180
+ if (!held) return
1181
+ const done = this.linkCommand({ ...held.action, remap } as FigureAuthoringAction, held.from)
1182
+ if (done && held.from === 'section-editor') this.closeSectionEditor()
1183
+ }
1184
+ /** Runs a command; true when it was taken. */
1185
+ private linkCommand(action: FigureAuthoringAction, from: 'section-editor' | 'panel' = 'panel'): boolean {
1172
1186
  /* Committed or refused, a command in hand is let go of: the figure as it stands is drawn again. */
1173
1187
  this.holdAction(null)
1174
1188
  this.retry = undefined
@@ -1177,6 +1191,7 @@ export class FigureEditor extends LitElement {
1177
1191
  try {
1178
1192
  this.session!.command(action)
1179
1193
  this.error = ''
1194
+ this.faceMapping = undefined
1180
1195
  /* What the command did besides what was asked, in one line: the figure's size declared to follow (ADR ruling Q1). */
1181
1196
  if (action.kind === 'follow-size' && !hadSize) {
1182
1197
  const size = this.designValues()
@@ -1187,14 +1202,22 @@ export class FigureEditor extends LitElement {
1187
1202
  })
1188
1203
  }
1189
1204
  this.changed()
1205
+ return true
1190
1206
  } catch (error) {
1191
- if (this.askClipLoss(error, () => this.linkCommand(action))) return
1207
+ if (this.askClipLoss(error, () => this.linkCommand(action, from))) return false
1192
1208
  const code = (error as { code?: string })?.code
1209
+ /* Something stands on a face this takes away: ask where it goes, there, rather than only saying no. */
1210
+ const need = (error as { details?: FigureFaceMappingNeed }).details
1211
+ if (code === 'FEATURE_MAPPING_REQUIRED' && need?.lost?.length) {
1212
+ this.faceMapping = { action, need, from }
1213
+ this.error = ''
1214
+ return false
1215
+ }
1193
1216
  const narrowing = narrowingRetryOf(action, error, (key, params) => i18next.t(key, params))
1194
1217
  if (narrowing) {
1195
1218
  this.error = narrowing.message
1196
1219
  this.retry = { label: narrowing.label, action: narrowing.retry as FigureAuthoringAction }
1197
- return
1220
+ return false
1198
1221
  }
1199
1222
  this.error =
1200
1223
  code === 'DIMENSION_CYCLE'
@@ -1204,6 +1227,7 @@ export class FigureEditor extends LitElement {
1204
1227
  : sizeRangeRefusalOf(error, (key, params) => i18next.t(key, params)) ??
1205
1228
  placementRefusalOf(error, (key, params) => i18next.t(key, params)) ??
1206
1229
  this.said(error)
1230
+ return false
1207
1231
  }
1208
1232
  }
1209
1233
  private changeField(field: { id: string; unit: FigureInputChange['unit']; role?: string }, event: Event) {
@@ -1743,6 +1767,7 @@ export class FigureEditor extends LitElement {
1743
1767
  private choose(id: string) {
1744
1768
  /* A copy on the canvas selects its repeat: the part the author made. */
1745
1769
  this.selected = id ? ownerOf(id) : id
1770
+ this.faceMapping = undefined
1746
1771
  if (id && (this.tab === 'verdict' || this.tab === 'view' || this.tab === 'history')) this.tab = 'properties'
1747
1772
  }
1748
1773
  private asset(): unknown {
@@ -1801,8 +1826,14 @@ export class FigureEditor extends LitElement {
1801
1826
  .kept=${kept}
1802
1827
  .pointBlocked=${this.pointBlockedOf(drawn)}
1803
1828
  .revision=${this.session?.read().revision ?? 0}
1804
- @command=${(e: CustomEvent) => this.linkCommand(e.detail.action)}
1829
+ .faceMapping=${this.faceMapping?.from === 'section-editor' ? this.faceMapping.need : undefined}
1830
+ @command=${(e: CustomEvent) => {
1831
+ /* Held for a choice of where things go: the editor stays open, the choice shown in it. */
1832
+ if (!this.linkCommand(e.detail.action, 'section-editor')) e.detail.held = true
1833
+ }}
1805
1834
  @command-live=${(e: CustomEvent) => this.holdAction(e.detail.action)}
1835
+ @face-mapped=${(e: CustomEvent) => this.mapFaces(e.detail.remap)}
1836
+ @face-mapping-cancel=${() => (this.faceMapping = undefined)}
1806
1837
  @section-editor-close=${() => this.closeSectionEditor()}
1807
1838
  ></figure-section-editor>`
1808
1839
  }
@@ -2015,6 +2046,7 @@ export class FigureEditor extends LitElement {
2015
2046
  .asset=${asset}
2016
2047
  .context=${view.context ?? ''}
2017
2048
  .view=${this.view}
2049
+ .selected=${this.selected}
2018
2050
  @configure-size=${async (e: CustomEvent<{ part: string }>) => {
2019
2051
  this.middle = 'edit'
2020
2052
  this.selected = e.detail.part
@@ -2078,6 +2110,9 @@ export class FigureEditor extends LitElement {
2078
2110
  <figure-section-panel
2079
2111
  .body=${{ ...part, id: this.selected }}
2080
2112
  ?locked=${unavailable}
2113
+ .faceMapping=${this.faceMapping?.from === 'panel' ? this.faceMapping.need : undefined}
2114
+ @face-mapped=${(e: CustomEvent) => this.mapFaces(e.detail.remap)}
2115
+ @face-mapping-cancel=${() => (this.faceMapping = undefined)}
2081
2116
  @command=${(e: CustomEvent) => this.linkCommand(e.detail.action)}
2082
2117
  @command-live=${(e: CustomEvent) => this.holdAction(e.detail.action)}
2083
2118
  @section-editor-open=${() => (this.sectionEditing = this.selected)}
@@ -0,0 +1,39 @@
1
+ import type { FigureFaceMappingNeed, FigureFaceReference, FigureFaceRemap } from '@hatiolab/figure-model'
2
+
3
+ /*
4
+ * Where what stands on a face an edit takes away goes instead (ADR-0100 A8, user 2026-10-02): one row per thing that
5
+ * refers to a lost face, its choices the faces that remain looking the same way, and -- for a joint, never a named
6
+ * face -- let go where it stands. Nothing is chosen for the author: where it goes only they know.
7
+ */
8
+
9
+ export interface FaceMappingRow {
10
+ ref: FigureFaceReference
11
+ /** The face it is on now, which the edit takes away. */
12
+ lost: string
13
+ /** The faces it may go to: those that remain, looking the way the lost one did. */
14
+ faces: string[]
15
+ /** Whether it may be let go where it stands: a joint may, a named face may not. */
16
+ detach: boolean
17
+ }
18
+
19
+ export const DETACH = '__detach'
20
+
21
+ export function faceMappingRowsOf(need: FigureFaceMappingNeed): FaceMappingRow[] {
22
+ return need.lost.flatMap(lost => {
23
+ const faces = need.remain.filter(r => lost.axis === undefined || (r.axis === lost.axis && r.normal === lost.normal)).map(r => r.face)
24
+ return lost.refs.map(ref => ({ ref, lost: lost.face, faces, detach: ref.kind === 'joint' }))
25
+ })
26
+ }
27
+
28
+ /** The remap a command takes, once every row is chosen; undefined while one is not. */
29
+ export function remapOf(rows: readonly FaceMappingRow[], picks: Readonly<Record<string, string>>): FigureFaceRemap[] | undefined {
30
+ const out: FigureFaceRemap[] = []
31
+ for (const row of rows) {
32
+ const pick = picks[rowKey(row)]
33
+ if (!pick) return undefined
34
+ out.push({ ref: { kind: row.ref.kind, id: row.ref.id }, to: pick === DETACH ? 'detach' : { face: pick } })
35
+ }
36
+ return out
37
+ }
38
+
39
+ export const rowKey = (row: FaceMappingRow) => `${row.ref.kind}:${row.ref.id}:${row.lost}`
@@ -0,0 +1,78 @@
1
+ import { css, html, LitElement, nothing, type PropertyValues } from 'lit'
2
+ import { customElement, property, state } from 'lit/decorators.js'
3
+
4
+ import { i18next, localize } from '@operato/i18n'
5
+ import type { FigureFaceMappingNeed } from '@hatiolab/figure-model'
6
+
7
+ import { SidePanelStyles } from './side-panel-styles.js'
8
+ import { DETACH, faceMappingRowsOf, remapOf, rowKey } from './face-mapping.js'
9
+
10
+ /**
11
+ * 없어지는 면에 붙은 것을 옮길 곳 (ADR-0100 A8): shown where the edit was made, under it. Each thing on a lost face
12
+ * is a row; apply is held until every row is chosen, and then the same edit goes again with the remap, one step.
13
+ */
14
+ @customElement('figure-face-mapping')
15
+ export class FigureFaceMapping extends localize(i18next)(LitElement) {
16
+ static styles = [
17
+ SidePanelStyles,
18
+ css`
19
+ :host {
20
+ display: grid;
21
+ gap: 8px;
22
+ padding: 10px 12px;
23
+ border: 1px solid var(--md-sys-color-error);
24
+ border-radius: 8px;
25
+ }
26
+ div[row] {
27
+ display: grid;
28
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
29
+ gap: 8px;
30
+ align-items: center;
31
+ }
32
+ div[buttons] {
33
+ display: flex;
34
+ gap: 8px;
35
+ justify-content: flex-end;
36
+ }
37
+ `
38
+ ]
39
+
40
+ @property({ attribute: false }) need?: FigureFaceMappingNeed
41
+ @state() private picks: Record<string, string> = {}
42
+
43
+ protected willUpdate(changed: PropertyValues<this>) {
44
+ /* Another refusal is another question: what was chosen for the last one does not carry over. */
45
+ if (changed.has('need')) this.picks = {}
46
+ }
47
+
48
+ private face = (face: string) => i18next.t('figure.label.face-' + face, { defaultValue: face })
49
+
50
+ render() {
51
+ if (!this.need) return nothing
52
+ const rows = faceMappingRowsOf(this.need)
53
+ const remap = remapOf(rows, this.picks)
54
+ const lost = [...new Set(this.need.lost.map(l => this.face(l.face)))].join(', ')
55
+ return html`<p>${i18next.t('figure.text.face-mapping-lost', { faces: lost })}</p>
56
+ ${rows.map(
57
+ row => html`<div row>
58
+ <span>${row.ref.part ?? row.ref.id} · ${this.face(row.lost)}</span>
59
+ <select
60
+ aria-label=${i18next.t('figure.label.face-mapping-to', { part: row.ref.part ?? row.ref.id })}
61
+ @change=${(e: Event) => (this.picks = { ...this.picks, [rowKey(row)]: (e.target as HTMLSelectElement).value })}
62
+ >
63
+ <option value="" ?selected=${!this.picks[rowKey(row)]}>${i18next.t('figure.label.face-mapping-choose')}</option>
64
+ ${row.faces.map(f => html`<option value=${f}>${this.face(f)}</option>`)}
65
+ ${row.detach ? html`<option value=${DETACH}>${i18next.t('figure.label.face-mapping-detach')}</option>` : nothing}
66
+ </select>
67
+ </div>`
68
+ )}
69
+ <div buttons>
70
+ <button @click=${() => this.dispatchEvent(new CustomEvent('face-mapping-cancel', { bubbles: true, composed: true }))}>
71
+ ${i18next.t('figure.button.face-mapping-cancel')}
72
+ </button>
73
+ <button act ?disabled=${!remap} @click=${() => remap && this.dispatchEvent(new CustomEvent('face-mapped', { detail: { remap }, bubbles: true, composed: true }))}>
74
+ ${i18next.t('figure.button.face-mapping-apply')}
75
+ </button>
76
+ </div>`
77
+ }
78
+ }
@@ -8,7 +8,7 @@ import { create, registerFigure, unregisterFigure } from '@hatiolab/things-scene
8
8
 
9
9
  import { DEFAULT_VIEW, previewBoardDepth, sceneLook, WORKBENCH, type ViewSettings } from './figure-view.js'
10
10
  import { dialShape } from './angle-dial.js'
11
- import { authoredSizeOf, PREVIEW_FACTOR, PREVIEW_WAYS, previewClampsOf, previewInstances } from './preview-model.js'
11
+ import { authoredSizeOf, PREVIEW_FACTOR, PREVIEW_WAYS, previewClampsOf, previewInstances, setupPartOf } from './preview-model.js'
12
12
 
13
13
  /**
14
14
  * The figure placed on a board.
@@ -52,7 +52,25 @@ export class FigurePreview extends localize(i18next)(LitElement) {
52
52
  width: 100%;
53
53
  height: 100%;
54
54
  }
55
- div[setup] { position: absolute; bottom: 8px; left: 8px; max-width: min(320px, calc(100% - 16px)); padding: 12px; border-radius: 8px; background: rgba(28,28,30,.9); color: #fff; display: grid; gap: 8px; }
55
+ /*
56
+ The size help and the posing controls share the stage's bottom edge. Each stood in its own corner, so on a narrow
57
+ stage (the 1024 width, both side panels open) the controls lay over the help's button. One row that wraps keeps both
58
+ whole: side by side when there is room, the controls above the help when there is not.
59
+ */
60
+ div[foot] {
61
+ position: absolute;
62
+ left: 8px;
63
+ right: 8px;
64
+ bottom: 8px;
65
+ display: flex;
66
+ flex-wrap: wrap-reverse;
67
+ justify-content: space-between;
68
+ align-items: flex-end;
69
+ gap: 8px;
70
+ pointer-events: none;
71
+ }
72
+ div[foot] > * { pointer-events: auto; }
73
+ div[setup] { max-width: min(320px, 100%); padding: 12px; border-radius: 8px; background: rgba(28,28,30,.9); color: #fff; display: grid; gap: 8px; }
56
74
  div[setup] p { margin: 0; line-height: 1.5; }
57
75
  div[setup] select, div[setup] button { font: inherit; padding: 8px; min-width: 0; }
58
76
  /* Which is which: side by side means nothing without a legend. */
@@ -76,9 +94,7 @@ export class FigurePreview extends localize(i18next)(LitElement) {
76
94
  color: #ffcc80;
77
95
  }
78
96
  div[clips] {
79
- position: absolute;
80
- right: 8px;
81
- bottom: 8px;
97
+ margin-left: auto;
82
98
  display: flex;
83
99
  flex-direction: column;
84
100
  gap: 6px;
@@ -162,6 +178,8 @@ export class FigurePreview extends localize(i18next)(LitElement) {
162
178
  /** Clip speeds and control values given here -- the preview's, not the figure's. */
163
179
  @state() private driving: Record<string, number> = {}
164
180
  @state() private giving: Record<string, number> = {}
181
+ /** The part chosen in the editor. The size help starts on it, so the help speaks of the part the author was working on. */
182
+ @property() selected = ''
165
183
  @state() private setupPart = ''
166
184
 
167
185
  /** What is being tried here now -- clip speeds and control values -- for the AI dock to hear with a request; none when nothing is. */
@@ -186,6 +204,8 @@ export class FigurePreview extends localize(i18next)(LitElement) {
186
204
  } catch {
187
205
  clampsByWay = {}
188
206
  }
207
+ /* The part the help speaks of: the one picked in it, else the one chosen in the editor, else the first. */
208
+ const setupPart = setupPartOf(this.setupPart, this.selected, asset?.appearance.map(p => p.target) ?? [])
189
209
  return html`<div stage></div>
190
210
  ${this.cannot
191
211
  ? html`<div cannot>${this.cannot}</div>`
@@ -200,14 +220,14 @@ export class FigurePreview extends localize(i18next)(LitElement) {
200
220
  </span>`
201
221
  })}
202
222
  </div>
203
- ${asset?.appearance.length ? html`<div setup>
223
+ <div foot>${asset?.appearance.length ? html`<div setup>
204
224
  <p>${i18next.t('figure.text.preview-setup')}</p>
205
225
  <select aria-label=${i18next.t('figure.label.resize-part')} @change=${(e: Event) => this.setupPart = (e.target as HTMLSelectElement).value}>
206
- ${asset.appearance.map(p => html`<option value=${p.target} ?selected=${p.target === this.setupPart}>${p.target}</option>`)}
226
+ ${asset.appearance.map(p => html`<option value=${p.target} ?selected=${p.target === setupPart}>${p.target}</option>`)}
207
227
  </select>
208
- <button @click=${() => this.dispatchEvent(new CustomEvent('configure-size', { detail: { part: asset.appearance.some(p => p.target === this.setupPart) ? this.setupPart : asset.appearance[0]!.target }, bubbles: true, composed: true }))}>${i18next.t('figure.button.configure-size')}</button>
228
+ <button @click=${() => this.dispatchEvent(new CustomEvent('configure-size', { detail: { part: setupPart }, bubbles: true, composed: true }))}>${i18next.t('figure.button.configure-size')}</button>
209
229
  </div>` : nothing}
210
- ${controls.length + clips.length ? this.renderDrivers(asset!, controls, clips) : nothing}`}`
230
+ ${controls.length + clips.length ? this.renderDrivers(asset!, controls, clips) : nothing}</div>`}`
211
231
  }
212
232
 
213
233
  private renderDrivers(asset: FigureAsset, controls: FigureAsset['document']['model']['inputs'], clips: string[]) {
@@ -237,7 +257,11 @@ export class FigurePreview extends localize(i18next)(LitElement) {
237
257
  </label>`
238
258
  })}
239
259
  ${clips.map(clip => {
240
- const value = this.driving[clip] ?? 1
260
+ /*
261
+ A clip nothing has driven stands still, here as on a board: the instances get a speed only from `drive`. The
262
+ slider showed 1.00 over rollers that did not turn (2026-10-03). It shows what plays -- 0 until moved.
263
+ */
264
+ const value = this.driving[clip] ?? 0
241
265
  return html`<label>
242
266
  <span>${clip} <span drive>${i18next.t('figure.label.playback-speed')}</span></span>
243
267
  <span></span>
@@ -4,11 +4,12 @@ import { live } from 'lit/directives/live.js'
4
4
 
5
5
  import { i18next, localize } from '@operato/i18n'
6
6
  import { figureCavitySectionOf, figureSectionSidesOf } from '@hatiolab/figure-model'
7
- import type { FigureAuthoringAction, FigureEvaluatedShape, FigureSection, FigureSectionMeasure, FigureSectionPoint } from '@hatiolab/figure-model'
7
+ import type { FigureAuthoringAction, FigureEvaluatedShape, FigureFaceMappingNeed, FigureSection, FigureSectionMeasure, FigureSectionPoint } from '@hatiolab/figure-model'
8
8
  import { SidePanelStyles } from './side-panel-styles.js'
9
9
  import { apexOver, drawnOf, insertAfter, markedBy, movePoint, pointLabel, removePoint, sectionOf, workingIssuesOf, workingOf, workingShapeOf, type SectionWorking } from './section-drawing.js'
10
10
  import { cavityDepthOf, cavityRequestOf, cavityResultOf, END_FACE, sameOf, sidesOf } from './section-controls.js'
11
11
  import './figure-cavity-drawing.js'
12
+ import './figure-face-mapping.js'
12
13
  import { openPopup } from '@operato/layout'
13
14
  import './figure-section-close-choice.js'
14
15
  import type { SectionCloseChoice } from './figure-section-close-choice.js'
@@ -276,6 +277,8 @@ export class FigureSectionEditor extends localize(i18next)(LitElement) {
276
277
  @property({ attribute: false }) pointBlocked = ''
277
278
  /** The figure's revision now; the editor remembers the one it opened at. */
278
279
  @property({ type: Number }) revision = 0
280
+ /** What stands on the faces the last apply takes away (ADR-0100 A8): asked here, where the edit was made. */
281
+ @property({ attribute: false }) faceMapping?: FigureFaceMappingNeed
279
282
  /** Narrow: the outline or the solid behind. */
280
283
  @property({ reflect: true }) show: 'outline' | 'solid' = 'outline'
281
284
  /** Set when the space the editor stands in leaves too little beside it to see the solid. */
@@ -430,8 +433,10 @@ export class FigureSectionEditor extends localize(i18next)(LitElement) {
430
433
 
431
434
  private apply() {
432
435
  if (this.stale || !this.valid(this.working)) return
433
- this.dispatchEvent(new CustomEvent('command', { detail: { action: this.action(this.working) }, bubbles: true, composed: true }))
434
- this.close()
436
+ const detail: { action: FigureAuthoringAction; held?: boolean } = { action: this.action(this.working) }
437
+ this.dispatchEvent(new CustomEvent('command', { detail, bubbles: true, composed: true }))
438
+ /* Held for a choice of where what stands on a lost face goes: stays open, the choice shown below. */
439
+ if (!detail.held) this.close()
435
440
  }
436
441
 
437
442
  /** Whether anything was changed since the editor opened. */
@@ -526,7 +531,10 @@ export class FigureSectionEditor extends localize(i18next)(LitElement) {
526
531
  </nav>
527
532
  <div body>
528
533
  <div outline>${this.drawing(issues, words.length > 0)}</div>
529
- <aside>${this.list(issues, words)}</aside>
534
+ <aside>
535
+ ${this.faceMapping ? html`<figure-face-mapping .need=${this.faceMapping}></figure-face-mapping>` : nothing}
536
+ ${this.list(issues, words)}
537
+ </aside>
530
538
  </div>
531
539
  <footer>
532
540
  <button ?disabled=${!this.history.length} @click=${() => this.back()}>${i18next.t('figure.button.section-editor-back')}</button>
@@ -4,10 +4,11 @@ import { customElement, property, state } from 'lit/decorators.js'
4
4
  import { live } from 'lit/directives/live.js'
5
5
 
6
6
  import { i18next, localize } from '@operato/i18n'
7
- import type { FigureAuthoringAction, FigureEvaluatedShape } from '@hatiolab/figure-model'
7
+ import type { FigureAuthoringAction, FigureEvaluatedShape, FigureFaceMappingNeed } from '@hatiolab/figure-model'
8
8
  import { SidePanelStyles } from './side-panel-styles.js'
9
9
  import { drawnOf } from './section-drawing.js'
10
10
  import './figure-cavity-drawing.js'
11
+ import './figure-face-mapping.js'
11
12
  import { cavityDepthOf, cavityRequestOf, cavityResultOf, cornerLimitOf, cornerRefusalOf, mm, sameOf } from './section-controls.js'
12
13
 
13
14
  type Body = { id: string; shape: FigureEvaluatedShape }
@@ -59,6 +60,8 @@ export class FigureSectionPanel extends localize(i18next)(LitElement) {
59
60
 
60
61
  @property({ attribute: false }) body?: Body
61
62
  @property({ type: Boolean }) locked = false
63
+ /** What stands on the faces the last edit here takes away (ADR-0100 A8): asked here, where the edit was made. */
64
+ @property({ attribute: false }) faceMapping?: FigureFaceMappingNeed
62
65
  /** What each field would not take, by field, said under it. */
63
66
  @state() private refusals: Record<string, string> = {}
64
67
  /** What is typed in a field and not yet sent, by field: the figure drawn with it must not type over it. */
@@ -97,6 +100,7 @@ export class FigureSectionPanel extends localize(i18next)(LitElement) {
97
100
  : nothing}
98
101
  ${kind === 'rectangle' ? this.renderCorner(body) : nothing}
99
102
  ${/* No inside for a drawn section: the control is not there, rather than a line saying so. */ kind === 'rectangle' || kind === 'ellipse' ? this.renderCavity(body) : nothing}
103
+ ${this.faceMapping ? html`<figure-face-mapping .need=${this.faceMapping}></figure-face-mapping>` : nothing}
100
104
  </section>`
101
105
  }
102
106
 
@@ -74,3 +74,11 @@ export function previewClampsOf(asset: FigureAsset, size: { x: number; y: number
74
74
  ])
75
75
  )
76
76
  }
77
+
78
+ /**
79
+ * The part the preview's size help speaks of: the one picked in the help, else the one chosen in the editor, else the
80
+ * first that has a size rule. A choice that is not among the parts (removed, or a part with no rule) is passed over.
81
+ */
82
+ export function setupPartOf(picked: string, chosen: string, targets: string[]): string {
83
+ return [picked, chosen].find(id => !!id && targets.includes(id)) ?? targets[0] ?? ''
84
+ }
@@ -472,8 +472,14 @@ export class FigureModellerPage extends PageView {
472
472
  return answer
473
473
  }
474
474
  get context() {
475
+ const view = this.session.read()
475
476
  return {
476
- title: this.session.read().name ?? 'Figure',
477
+ title: view.name ?? 'Figure',
478
+ /*
479
+ A figure that has an id was opened from the catalog (or saved there), so the rail marks the catalog. Without this
480
+ the rail matches the page name and marks "new figure" while an existing one is being edited.
481
+ */
482
+ menu: view.id ? 'figure-list' : undefined,
477
483
  actions: [],
478
484
  /*
479
485
  No heading line: the canvas is what this page is for, and the name is already in the properties' first section
@@ -252,6 +252,13 @@ let FigureCanvas = class FigureCanvas extends LitElement {
252
252
  if (!layer || !root?.on || this.viewOnly)
253
253
  return;
254
254
  root.on('selected', (after) => {
255
+ /*
256
+ A canvas taken off the screen disposes its scene, and the scene empties its selection as it goes. Told out,
257
+ that emptied the editor's choice whenever the middle turned to the preview (U03): the listener lit set on this
258
+ element hears it even after it left the page. A canvas not on the page has nothing to say about the choice.
259
+ */
260
+ if (!this.isConnected)
261
+ return;
255
262
  const name = after?.[0]?.state?.name;
256
263
  const id = typeof name === 'string' ? name : '';
257
264
  if (ownerOf(id) !== this.selected)
@@ -1 +1 @@
1
- {"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../client/modeller/canvas.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAuB,MAAM,KAAK,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAIpE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAqB,MAAM,kBAAkB,CAAA;AACxF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAgC,MAAM,kBAAkB,CAAA;AAClH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAuCrC,iEAAiE;AACjE,MAAM,UAAU,GAAG,SAAS,CAAA;AAE5B,8FAA8F;AAC9F,MAAM,KAAK,GAAG,SAAS,CAAA;AAGhB,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAiB2B,UAAK,GAAuB,EAAE,CAAA;QAC9B,YAAO,GAA2B,EAAE,CAAA;QACpE,sHAAsH;QACtF,YAAO,GAAgC,EAA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AC;;6CAA0C;AAE7D;IAAX,QAAQ,EAAE;;6CAAa;AACZ;IAAX,QAAQ,EAAE;;8CAAc;AAEO;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;2CAAsE;AACrE;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;0CAAkC;AAMpC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;8CAAiB;AAEb;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;yCAAoC;AAKnC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;2CAA+B;AAC9B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;+CAA0C;AAE5C;IAA5B,KAAK,CAAC,YAAY,CAAC;8BAAiB,cAAc;2CAAA;AA1CxC,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAkUxB","sourcesContent":["import { LitElement, html, css, unsafeCSS, type PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { create, Model, niceGridStep } from '@hatiolab/things-scene'\n\nimport type { GizmoReach } from './gizmo.js'\nimport type { FigureRenderPart } from './renderer.js'\nimport { DEFAULT_VIEW, sceneLook, WORKBENCH, type ViewSettings } from './figure-view.js'\nimport { boardFor, changedKeys, componentOf, gizmoResultOf, type Board, type ScaleAnchor } from './stage-model.js'\nimport { JOINT_FAN } from './joint-fan.js'\nimport { PREVIEW, TARGET_FACE } from './command-preview.js'\nimport { ownerOf } from './fields.js'\n\n/*\n * The modeller's canvas -- a things-scene board in editing mode.\n *\n * Each body figure-model evaluates stands on the board as a `figure-part` component, so everything the canvas\n * has 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 (`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-canvas')\nexport class FigureCanvas 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 `\n @property({ attribute: false }) parts: FigureRenderPart[] = []\n @property({ attribute: false }) palette: Record<string, string> = {}\n /** The face a size drag keeps, per part (figure-model's `figureScaleAnchorOf`), so the drag shows what is written. */\n @property({ attribute: false }) anchors: Record<string, ScaleAnchor> = {}\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 (`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.\n */\n @property({ type: Boolean }) viewOnly = false\n /** Where the selected part turns and how far (`joint-fan`): shown, never picked, never saved. */\n @property({ attribute: false }) fan: FigureRenderPart | null = null\n /**\n * A command seen before it is done (ADR-0097 §5.5): the bodies it would move, where they would stand, translucent,\n * and the face they would be fastened to, lit. Shown, never picked, never saved; gone when the command is.\n */\n @property({ attribute: false }) ghost: FigureRenderPart[] = []\n @property({ attribute: false }) highlight: FigureRenderPart | 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 /*\n * No line of its own over an empty stage: a new figure's start card says how to begin, and an empty stage otherwise\n * is one loading, or with every part hidden -- where 「도형을 추가해…」 flashed and said the wrong thing (2026-10-02).\n */\n return html`<div stage></div>`\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 (['parts', 'palette', 'context', 'fan', 'anchors', 'ghost', 'highlight'].some(key => changed.has(key))) 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), 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 (user, 2026-09-24: no card had a picture after this canvas moved onto the scene).\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. */\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. */\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. */\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!, this.anchors[ownerOf(part.id)])).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 const accent = this.palette['palette.accent'] ?? FAN_COLOUR\n const shown = [...(fan ? [fan] : []), ...this.ghost.map(part => componentOf(part, { ...this.palette, [PREVIEW]: accent, [TARGET_FACE]: accent }, this.board!)), ...(this.highlight ? [componentOf(this.highlight, { ...this.palette, [TARGET_FACE]: accent }, this.board!)] : [])]\n return [...parts, ...shown.filter((c): c is Record<string, unknown> => !!c).map(c => ({ ...c, capturable: false, locked: true }))]\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.\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 part placed by a rule\n became 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"]}
1
+ {"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../client/modeller/canvas.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAuB,MAAM,KAAK,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAIpE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAqB,MAAM,kBAAkB,CAAA;AACxF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAgC,MAAM,kBAAkB,CAAA;AAClH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAuCrC,iEAAiE;AACjE,MAAM,UAAU,GAAG,SAAS,CAAA;AAE5B,8FAA8F;AAC9F,MAAM,KAAK,GAAG,SAAS,CAAA;AAGhB,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAiB2B,UAAK,GAAuB,EAAE,CAAA;QAC9B,YAAO,GAA2B,EAAE,CAAA;QACpE,sHAAsH;QACtF,YAAO,GAAgC,EAAE,CAAA;QACzE,mEAAmE;QACvD,YAAO,GAAG,EAAE,CAAA;QACZ,aAAQ,GAAG,EAAE,CAAA;QACzB,mHAAmH;QACnF,UAAK,GAAe,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;QACrE,SAAI,GAAiB,YAAY,CAAA;QACjE;;;;WAIG;QAC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SAAS,EAAE,KAAK,EAAE,CAAC;;0CAAkC;AAMpC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;8CAAiB;AAEb;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;yCAAoC;AAKnC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;2CAA+B;AAC9B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;+CAA0C;AAE5C;IAA5B,KAAK,CAAC,YAAY,CAAC;8BAAiB,cAAc;2CAAA;AA1CxC,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAwUxB","sourcesContent":["import { LitElement, html, css, unsafeCSS, type PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { create, Model, niceGridStep } from '@hatiolab/things-scene'\n\nimport type { GizmoReach } from './gizmo.js'\nimport type { FigureRenderPart } from './renderer.js'\nimport { DEFAULT_VIEW, sceneLook, WORKBENCH, type ViewSettings } from './figure-view.js'\nimport { boardFor, changedKeys, componentOf, gizmoResultOf, type Board, type ScaleAnchor } from './stage-model.js'\nimport { JOINT_FAN } from './joint-fan.js'\nimport { PREVIEW, TARGET_FACE } from './command-preview.js'\nimport { ownerOf } from './fields.js'\n\n/*\n * The modeller's canvas -- a things-scene board in editing mode.\n *\n * Each body figure-model evaluates stands on the board as a `figure-part` component, so everything the canvas\n * has 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 (`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-canvas')\nexport class FigureCanvas 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 `\n @property({ attribute: false }) parts: FigureRenderPart[] = []\n @property({ attribute: false }) palette: Record<string, string> = {}\n /** The face a size drag keeps, per part (figure-model's `figureScaleAnchorOf`), so the drag shows what is written. */\n @property({ attribute: false }) anchors: Record<string, ScaleAnchor> = {}\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 (`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.\n */\n @property({ type: Boolean }) viewOnly = false\n /** Where the selected part turns and how far (`joint-fan`): shown, never picked, never saved. */\n @property({ attribute: false }) fan: FigureRenderPart | null = null\n /**\n * A command seen before it is done (ADR-0097 §5.5): the bodies it would move, where they would stand, translucent,\n * and the face they would be fastened to, lit. Shown, never picked, never saved; gone when the command is.\n */\n @property({ attribute: false }) ghost: FigureRenderPart[] = []\n @property({ attribute: false }) highlight: FigureRenderPart | 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 /*\n * No line of its own over an empty stage: a new figure's start card says how to begin, and an empty stage otherwise\n * is one loading, or with every part hidden -- where 「도형을 추가해…」 flashed and said the wrong thing (2026-10-02).\n */\n return html`<div stage></div>`\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 (['parts', 'palette', 'context', 'fan', 'anchors', 'ghost', 'highlight'].some(key => changed.has(key))) 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), 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 (user, 2026-09-24: no card had a picture after this canvas moved onto the scene).\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. */\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. */\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. */\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!, this.anchors[ownerOf(part.id)])).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 const accent = this.palette['palette.accent'] ?? FAN_COLOUR\n const shown = [...(fan ? [fan] : []), ...this.ghost.map(part => componentOf(part, { ...this.palette, [PREVIEW]: accent, [TARGET_FACE]: accent }, this.board!)), ...(this.highlight ? [componentOf(this.highlight, { ...this.palette, [TARGET_FACE]: accent }, this.board!)] : [])]\n return [...parts, ...shown.filter((c): c is Record<string, unknown> => !!c).map(c => ({ ...c, capturable: false, locked: true }))]\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 /*\n A canvas taken off the screen disposes its scene, and the scene empties its selection as it goes. Told out,\n that emptied the editor's choice whenever the middle turned to the preview (U03): the listener lit set on this\n element hears it even after it left the page. A canvas not on the page has nothing to say about the choice.\n */\n if (!this.isConnected) return\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.\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 part placed by a rule\n became 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"]}