@things-factory/figure-ui 10.1.39 → 10.1.40

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 (33) hide show
  1. package/client/modeller/figure-v3-properties.ts +254 -0
  2. package/client/modeller/v3-canvas.ts +27 -3
  3. package/client/modeller/v3-editor.ts +39 -11
  4. package/client/modeller/v3-figure-facts.ts +53 -0
  5. package/client/modeller/v3-occupancy.ts +6 -2
  6. package/client/pages/figure-v3-modeller-page.ts +68 -13
  7. package/dist-client/modeller/figure-v3-properties.d.ts +46 -0
  8. package/dist-client/modeller/figure-v3-properties.js +259 -0
  9. package/dist-client/modeller/figure-v3-properties.js.map +1 -0
  10. package/dist-client/modeller/v3-canvas.d.ts +6 -0
  11. package/dist-client/modeller/v3-canvas.js +27 -3
  12. package/dist-client/modeller/v3-canvas.js.map +1 -1
  13. package/dist-client/modeller/v3-editor.js +39 -11
  14. package/dist-client/modeller/v3-editor.js.map +1 -1
  15. package/dist-client/modeller/v3-figure-facts.d.ts +26 -0
  16. package/dist-client/modeller/v3-figure-facts.js +34 -0
  17. package/dist-client/modeller/v3-figure-facts.js.map +1 -0
  18. package/dist-client/modeller/v3-occupancy.d.ts +5 -1
  19. package/dist-client/modeller/v3-occupancy.js +4 -2
  20. package/dist-client/modeller/v3-occupancy.js.map +1 -1
  21. package/dist-client/pages/figure-v3-modeller-page.d.ts +16 -2
  22. package/dist-client/pages/figure-v3-modeller-page.js +78 -22
  23. package/dist-client/pages/figure-v3-modeller-page.js.map +1 -1
  24. package/dist-client/route.d.ts +1 -1
  25. package/dist-client/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +4 -4
  27. package/test/v3-properties.test.ts +93 -0
  28. package/test/v3-theme.test.ts +67 -0
  29. package/translations/en.json +6 -0
  30. package/translations/ja.json +6 -0
  31. package/translations/ko.json +6 -0
  32. package/translations/ms.json +6 -0
  33. package/translations/zh.json +6 -0
@@ -0,0 +1,46 @@
1
+ import '@material/web/icon/icon.js';
2
+ import { LitElement, nothing } from 'lit';
3
+ declare const FigureV3Properties_base: (new (...args: any[]) => LitElement) & typeof LitElement;
4
+ /**
5
+ * 속성 — the V3 modeller's figure properties (parity row ②).
6
+ *
7
+ * The V2 inspector opens with what the figure is: its name, the face it is placed by, the room it takes up, where
8
+ * the catalogue files it. The V3 page had only the type. The same rows, in the same order, drawn the way the V2
9
+ * inspector draws them.
10
+ *
11
+ * Two kinds of change leave this tab, and it does neither itself:
12
+ * - `v3-command` carries an authoring command (rename, declare the room, the mounting face). The page runs it
13
+ * through the session, so it is one step of the same undo history as every other edit, and is saved with it.
14
+ * - `v3-catalog` carries a change to the row (category, tags). Those are not in the asset; the page writes them
15
+ * to the saved row at once, so they need a saved figure.
16
+ *
17
+ * Not here yet, because V3 has no place for them: editing the declared room by hand (V3 declares it from the
18
+ * parts, as graph expressions), and the detail level (the converter records it as lost). Both wait on a V3 ruling.
19
+ */
20
+ export declare class FigureV3Properties extends FigureV3Properties_base {
21
+ static styles: import("lit").CSSResult;
22
+ /** The source being edited. */
23
+ source?: string;
24
+ /** The saved row, if any. Category and tags live on it. */
25
+ figureId?: string;
26
+ figureCategory?: string;
27
+ figureTags?: string[];
28
+ /** The part and face picked for the mounting face, before 「이 면으로」 is pressed. */
29
+ private pickedPart?;
30
+ private pickedFace?;
31
+ private facts;
32
+ render(): import("lit-html").TemplateResult<1> | typeof nothing;
33
+ private renderName;
34
+ /**
35
+ * The face the figure is placed by. In V3 it is part of the room declaration, so choosing one declares the room
36
+ * again from the parts — the only way V3 declares it — with the new face. The hint says so.
37
+ */
38
+ private renderPlacement;
39
+ private renderSpace;
40
+ private renderMounting;
41
+ private renderCatalog;
42
+ private declare;
43
+ private command;
44
+ private catalog;
45
+ }
46
+ export {};
@@ -0,0 +1,259 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@material/web/icon/icon.js';
3
+ import { css, html, LitElement, nothing } from 'lit';
4
+ import { customElement, property, state } from 'lit/decorators.js';
5
+ import { i18next, localize } from '@operato/i18n';
6
+ import { V3_FACES } from '@hatiolab/figure-model';
7
+ import { occupancyFromParts } from './v3-occupancy.js';
8
+ import { tagsOf, v3FigureFacts } from './v3-figure-facts.js';
9
+ const PLACEMENTS = ['floor', 'ceiling', 'center'];
10
+ const FACES = Object.keys(V3_FACES);
11
+ /**
12
+ * 속성 — the V3 modeller's figure properties (parity row ②).
13
+ *
14
+ * The V2 inspector opens with what the figure is: its name, the face it is placed by, the room it takes up, where
15
+ * the catalogue files it. The V3 page had only the type. The same rows, in the same order, drawn the way the V2
16
+ * inspector draws them.
17
+ *
18
+ * Two kinds of change leave this tab, and it does neither itself:
19
+ * - `v3-command` carries an authoring command (rename, declare the room, the mounting face). The page runs it
20
+ * through the session, so it is one step of the same undo history as every other edit, and is saved with it.
21
+ * - `v3-catalog` carries a change to the row (category, tags). Those are not in the asset; the page writes them
22
+ * to the saved row at once, so they need a saved figure.
23
+ *
24
+ * Not here yet, because V3 has no place for them: editing the declared room by hand (V3 declares it from the
25
+ * parts, as graph expressions), and the detail level (the converter records it as lost). Both wait on a V3 ruling.
26
+ */
27
+ let FigureV3Properties = class FigureV3Properties extends localize(i18next)(LitElement) {
28
+ static { this.styles = css `
29
+ :host {
30
+ display: flex;
31
+ flex-direction: column;
32
+ gap: 12px;
33
+ padding: 12px;
34
+ overflow: auto;
35
+ font-size: 0.76rem;
36
+ color: var(--md-sys-color-on-surface);
37
+ }
38
+ div[field] {
39
+ display: grid;
40
+ gap: 4px;
41
+ }
42
+ div[field] > label {
43
+ font-weight: 600;
44
+ }
45
+ div[row] {
46
+ display: flex;
47
+ gap: 6px;
48
+ align-items: center;
49
+ }
50
+ input,
51
+ select,
52
+ button {
53
+ font: inherit;
54
+ min-width: 0;
55
+ }
56
+ input,
57
+ select {
58
+ padding: 5px 8px;
59
+ border: 1px solid var(--md-sys-color-outline-variant);
60
+ border-radius: 4px;
61
+ background: var(--md-sys-color-surface);
62
+ color: var(--md-sys-color-on-surface);
63
+ }
64
+ div[row] > select {
65
+ flex: 1;
66
+ }
67
+ button {
68
+ display: inline-flex;
69
+ align-items: center;
70
+ gap: 4px;
71
+ padding: 4px 10px;
72
+ border: none;
73
+ border-radius: 999em;
74
+ cursor: pointer;
75
+ color: var(--md-sys-color-on-secondary-container);
76
+ background: var(--md-sys-color-secondary-container);
77
+ }
78
+ button:disabled,
79
+ input:disabled,
80
+ select:disabled {
81
+ opacity: 0.5;
82
+ cursor: default;
83
+ }
84
+ button md-icon {
85
+ font-size: 16px;
86
+ width: 16px;
87
+ height: 16px;
88
+ }
89
+ small {
90
+ color: var(--md-sys-color-on-surface-variant);
91
+ }
92
+ `; }
93
+ facts() {
94
+ try {
95
+ return this.source ? v3FigureFacts(this.source) : undefined;
96
+ }
97
+ catch {
98
+ /* A source the format refuses has no facts to show; the verdict tab says why. */
99
+ return undefined;
100
+ }
101
+ }
102
+ render() {
103
+ const facts = this.facts();
104
+ if (!facts)
105
+ return nothing;
106
+ return html `${this.renderName(facts)} ${this.renderPlacement(facts)} ${this.renderSpace(facts)} ${this.renderMounting(facts)}
107
+ ${this.renderCatalog()}`;
108
+ }
109
+ renderName(facts) {
110
+ return html `
111
+ <div field>
112
+ <label>${i18next.t('figure.label.name')}</label>
113
+ <input
114
+ .value=${facts.name}
115
+ placeholder=${i18next.t('figure.text.figure-display-name')}
116
+ @change=${(event) => {
117
+ const input = event.target;
118
+ if (!input.value.trim()) {
119
+ /* The format refuses a blank name; put the old one back rather than send a command that fails. */
120
+ input.value = facts.name;
121
+ return;
122
+ }
123
+ if (input.value.trim() !== facts.name)
124
+ this.command({ kind: 'rename', name: input.value });
125
+ }}
126
+ />
127
+ </div>
128
+ `;
129
+ }
130
+ /**
131
+ * The face the figure is placed by. In V3 it is part of the room declaration, so choosing one declares the room
132
+ * again from the parts — the only way V3 declares it — with the new face. The hint says so.
133
+ */
134
+ renderPlacement(facts) {
135
+ const current = facts.placement ?? 'floor';
136
+ return html `
137
+ <div field>
138
+ <label>${i18next.t('figure.label.figure-placement')}</label>
139
+ <select
140
+ ?disabled=${!facts.parts.length}
141
+ @change=${(event) => this.declare(event.target.value)}
142
+ >
143
+ ${PLACEMENTS.map(one => html `<option value=${one} ?selected=${one === current}>${i18next.t('figure.label.placement-' + one)}</option>`)}
144
+ </select>
145
+ <small>${i18next.t(facts.parts.length ? 'figure.text.placement-redeclares' : 'figure.text.fit-needs-parts')}</small>
146
+ </div>
147
+ `;
148
+ }
149
+ renderSpace(facts) {
150
+ return html `
151
+ <div field>
152
+ <label>${i18next.t('figure.label.declared-space')}</label>
153
+ <div row>
154
+ <span>${i18next.t(facts.declared ? 'figure.text.declared-space-declared' : 'figure.text.declared-space-none')}</span>
155
+ <button fit ?disabled=${!facts.parts.length} @click=${() => this.declare(facts.placement ?? 'floor')}>
156
+ <md-icon>fit_screen</md-icon>${i18next.t('figure.button.fit-base-to-parts')}
157
+ </button>
158
+ </div>
159
+ </div>
160
+ `;
161
+ }
162
+ renderMounting(facts) {
163
+ const mounting = facts.mounting;
164
+ const part = [this.pickedPart, mounting?.part, facts.parts[0]].find(one => one && facts.parts.includes(one));
165
+ const face = this.pickedFace ?? mounting?.face ?? 'bottom';
166
+ return html `
167
+ <div field>
168
+ <label>${i18next.t('figure.label.mounting-face')}</label>
169
+ <div row>
170
+ <select ?disabled=${!facts.declared} @change=${(e) => (this.pickedPart = e.target.value)}>
171
+ ${facts.parts.map(one => html `<option value=${one} ?selected=${one === part}>${one}</option>`)}
172
+ </select>
173
+ <select ?disabled=${!facts.declared} @change=${(e) => (this.pickedFace = e.target.value)}>
174
+ ${FACES.map(one => html `<option value=${one} ?selected=${one === face}>${i18next.t('figure.label.face-' + one)}</option>`)}
175
+ </select>
176
+ </div>
177
+ <div row>
178
+ <button ?disabled=${!facts.declared || !part} @click=${() => this.command({ kind: 'set-mounting-face', part: part, face })}>
179
+ ${i18next.t('figure.button.set-mounting-face')}
180
+ </button>
181
+ <button ?disabled=${!mounting} @click=${() => this.command({ kind: 'clear-mounting-face' })}>
182
+ ${i18next.t('figure.button.clear-mounting-face')}
183
+ </button>
184
+ </div>
185
+ <small>
186
+ ${facts.declared
187
+ ? mounting
188
+ ? `${mounting.part} · ${i18next.t('figure.label.face-' + mounting.face)}`
189
+ : i18next.t('figure.label.mounting-face-none')
190
+ : i18next.t('figure.text.mounting-face-needs-space')}
191
+ </small>
192
+ </div>
193
+ `;
194
+ }
195
+ renderCatalog() {
196
+ const saved = !!this.figureId;
197
+ return html `
198
+ <div field>
199
+ <label>${i18next.t('figure.label.category')}</label>
200
+ <input
201
+ .value=${this.figureCategory ?? ''}
202
+ ?disabled=${!saved}
203
+ placeholder=${i18next.t('figure.text.category-placeholder')}
204
+ @change=${(e) => this.catalog({ category: e.target.value.trim() })}
205
+ />
206
+ </div>
207
+ <div field>
208
+ <label>${i18next.t('figure.label.tags')}</label>
209
+ <input
210
+ .value=${(this.figureTags ?? []).join(', ')}
211
+ ?disabled=${!saved}
212
+ placeholder=${i18next.t('figure.text.tags-placeholder')}
213
+ @change=${(e) => this.catalog({ tags: tagsOf(e.target.value) })}
214
+ />
215
+ ${saved ? nothing : html `<small>${i18next.t('figure.text.catalog-needs-a-save')}</small>`}
216
+ </div>
217
+ `;
218
+ }
219
+ declare(placement) {
220
+ if (!this.source)
221
+ return;
222
+ this.command(occupancyFromParts(this.source, placement));
223
+ }
224
+ command(action) {
225
+ this.dispatchEvent(new CustomEvent('v3-command', { detail: { action }, bubbles: true, composed: true }));
226
+ }
227
+ catalog(patch) {
228
+ this.dispatchEvent(new CustomEvent('v3-catalog', { detail: patch, bubbles: true, composed: true }));
229
+ }
230
+ };
231
+ __decorate([
232
+ property({ type: String }),
233
+ __metadata("design:type", String)
234
+ ], FigureV3Properties.prototype, "source", void 0);
235
+ __decorate([
236
+ property({ type: String }),
237
+ __metadata("design:type", String)
238
+ ], FigureV3Properties.prototype, "figureId", void 0);
239
+ __decorate([
240
+ property({ type: String }),
241
+ __metadata("design:type", String)
242
+ ], FigureV3Properties.prototype, "figureCategory", void 0);
243
+ __decorate([
244
+ property({ type: Array }),
245
+ __metadata("design:type", Array)
246
+ ], FigureV3Properties.prototype, "figureTags", void 0);
247
+ __decorate([
248
+ state(),
249
+ __metadata("design:type", String)
250
+ ], FigureV3Properties.prototype, "pickedPart", void 0);
251
+ __decorate([
252
+ state(),
253
+ __metadata("design:type", String)
254
+ ], FigureV3Properties.prototype, "pickedFace", void 0);
255
+ FigureV3Properties = __decorate([
256
+ customElement('figure-v3-properties')
257
+ ], FigureV3Properties);
258
+ export { FigureV3Properties };
259
+ //# sourceMappingURL=figure-v3-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figure-v3-properties.js","sourceRoot":"","sources":["../../client/modeller/figure-v3-properties.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAGjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAsC,MAAM,sBAAsB,CAAA;AAEhG,MAAM,UAAU,GAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;AAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAa,CAAA;AAE/C;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;aAC5D,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAkC,CAAC,UAAU;;KAE5F,CAAA;IACH,CAAC;IAEO,OAAO,CAAC,SAAoB;QAClC,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAM;QACxB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;IAC1D,CAAC;IAEO,OAAO,CAAC,MAAyB;QACvC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC1G,CAAC;IAEO,OAAO,CAAC,KAA6C;QAC3D,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;;AAxJ2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAgB;AAEf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0DAAwB;AACxB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;sDAAsB;AAE/B;IAAhB,KAAK,EAAE;;sDAA4B;AACnB;IAAhB,KAAK,EAAE;;sDAA4B;AA3EzB,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CA6N9B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { V3_FACES } from '@hatiolab/figure-model'\nimport type { V3AuthoringAction, V3Face } from '@hatiolab/figure-model'\n\nimport { occupancyFromParts } from './v3-occupancy.js'\nimport { tagsOf, v3FigureFacts, type Placement, type V3FigureFacts } from './v3-figure-facts.js'\n\nconst PLACEMENTS: Placement[] = ['floor', 'ceiling', 'center']\nconst FACES = Object.keys(V3_FACES) as V3Face[]\n\n/**\n * 속성 — the V3 modeller's figure properties (parity row ②).\n *\n * The V2 inspector opens with what the figure is: its name, the face it is placed by, the room it takes up, where\n * the catalogue files it. The V3 page had only the type. The same rows, in the same order, drawn the way the V2\n * inspector draws them.\n *\n * Two kinds of change leave this tab, and it does neither itself:\n * - `v3-command` carries an authoring command (rename, declare the room, the mounting face). The page runs it\n * through the session, so it is one step of the same undo history as every other edit, and is saved with it.\n * - `v3-catalog` carries a change to the row (category, tags). Those are not in the asset; the page writes them\n * to the saved row at once, so they need a saved figure.\n *\n * Not here yet, because V3 has no place for them: editing the declared room by hand (V3 declares it from the\n * parts, as graph expressions), and the detail level (the converter records it as lost). Both wait on a V3 ruling.\n */\n@customElement('figure-v3-properties')\nexport class FigureV3Properties extends localize(i18next)(LitElement) {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px;\n overflow: auto;\n font-size: 0.76rem;\n color: var(--md-sys-color-on-surface);\n }\n div[field] {\n display: grid;\n gap: 4px;\n }\n div[field] > label {\n font-weight: 600;\n }\n div[row] {\n display: flex;\n gap: 6px;\n align-items: center;\n }\n input,\n select,\n button {\n font: inherit;\n min-width: 0;\n }\n input,\n select {\n padding: 5px 8px;\n border: 1px solid var(--md-sys-color-outline-variant);\n border-radius: 4px;\n background: var(--md-sys-color-surface);\n color: var(--md-sys-color-on-surface);\n }\n div[row] > select {\n flex: 1;\n }\n button {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 4px 10px;\n border: none;\n border-radius: 999em;\n cursor: pointer;\n color: var(--md-sys-color-on-secondary-container);\n background: var(--md-sys-color-secondary-container);\n }\n button:disabled,\n input:disabled,\n select:disabled {\n opacity: 0.5;\n cursor: default;\n }\n button md-icon {\n font-size: 16px;\n width: 16px;\n height: 16px;\n }\n small {\n color: var(--md-sys-color-on-surface-variant);\n }\n `\n\n /** The source being edited. */\n @property({ type: String }) source?: string\n /** The saved row, if any. Category and tags live on it. */\n @property({ type: String }) figureId?: string\n @property({ type: String }) figureCategory?: string\n @property({ type: Array }) figureTags?: string[]\n /** The part and face picked for the mounting face, before 「이 면으로」 is pressed. */\n @state() private pickedPart?: string\n @state() private pickedFace?: V3Face\n\n private facts(): V3FigureFacts | undefined {\n try {\n return this.source ? v3FigureFacts(this.source) : undefined\n } catch {\n /* A source the format refuses has no facts to show; the verdict tab says why. */\n return undefined\n }\n }\n\n render() {\n const facts = this.facts()\n if (!facts) return nothing\n return html`${this.renderName(facts)} ${this.renderPlacement(facts)} ${this.renderSpace(facts)} ${this.renderMounting(facts)}\n ${this.renderCatalog()}`\n }\n\n private renderName(facts: V3FigureFacts) {\n return html`\n <div field>\n <label>${i18next.t('figure.label.name')}</label>\n <input\n .value=${facts.name}\n placeholder=${i18next.t('figure.text.figure-display-name')}\n @change=${(event: Event) => {\n const input = event.target as HTMLInputElement\n if (!input.value.trim()) {\n /* The format refuses a blank name; put the old one back rather than send a command that fails. */\n input.value = facts.name\n return\n }\n if (input.value.trim() !== facts.name) this.command({ kind: 'rename', name: input.value })\n }}\n />\n </div>\n `\n }\n\n /**\n * The face the figure is placed by. In V3 it is part of the room declaration, so choosing one declares the room\n * again from the parts — the only way V3 declares it — with the new face. The hint says so.\n */\n private renderPlacement(facts: V3FigureFacts) {\n const current = facts.placement ?? 'floor'\n return html`\n <div field>\n <label>${i18next.t('figure.label.figure-placement')}</label>\n <select\n ?disabled=${!facts.parts.length}\n @change=${(event: Event) => this.declare((event.target as HTMLSelectElement).value as Placement)}\n >\n ${PLACEMENTS.map(\n one => html`<option value=${one} ?selected=${one === current}>${i18next.t('figure.label.placement-' + one)}</option>`\n )}\n </select>\n <small>${i18next.t(facts.parts.length ? 'figure.text.placement-redeclares' : 'figure.text.fit-needs-parts')}</small>\n </div>\n `\n }\n\n private renderSpace(facts: V3FigureFacts) {\n return html`\n <div field>\n <label>${i18next.t('figure.label.declared-space')}</label>\n <div row>\n <span>${i18next.t(facts.declared ? 'figure.text.declared-space-declared' : 'figure.text.declared-space-none')}</span>\n <button fit ?disabled=${!facts.parts.length} @click=${() => this.declare(facts.placement ?? 'floor')}>\n <md-icon>fit_screen</md-icon>${i18next.t('figure.button.fit-base-to-parts')}\n </button>\n </div>\n </div>\n `\n }\n\n private renderMounting(facts: V3FigureFacts) {\n const mounting = facts.mounting\n const part = [this.pickedPart, mounting?.part, facts.parts[0]].find(one => one && facts.parts.includes(one))\n const face: V3Face = this.pickedFace ?? mounting?.face ?? 'bottom'\n return html`\n <div field>\n <label>${i18next.t('figure.label.mounting-face')}</label>\n <div row>\n <select ?disabled=${!facts.declared} @change=${(e: Event) => (this.pickedPart = (e.target as HTMLSelectElement).value)}>\n ${facts.parts.map(one => html`<option value=${one} ?selected=${one === part}>${one}</option>`)}\n </select>\n <select ?disabled=${!facts.declared} @change=${(e: Event) => (this.pickedFace = (e.target as HTMLSelectElement).value as V3Face)}>\n ${FACES.map(one => html`<option value=${one} ?selected=${one === face}>${i18next.t('figure.label.face-' + one)}</option>`)}\n </select>\n </div>\n <div row>\n <button ?disabled=${!facts.declared || !part} @click=${() => this.command({ kind: 'set-mounting-face', part: part!, face })}>\n ${i18next.t('figure.button.set-mounting-face')}\n </button>\n <button ?disabled=${!mounting} @click=${() => this.command({ kind: 'clear-mounting-face' })}>\n ${i18next.t('figure.button.clear-mounting-face')}\n </button>\n </div>\n <small>\n ${facts.declared\n ? mounting\n ? `${mounting.part} · ${i18next.t('figure.label.face-' + mounting.face)}`\n : i18next.t('figure.label.mounting-face-none')\n : i18next.t('figure.text.mounting-face-needs-space')}\n </small>\n </div>\n `\n }\n\n private renderCatalog() {\n const saved = !!this.figureId\n return html`\n <div field>\n <label>${i18next.t('figure.label.category')}</label>\n <input\n .value=${this.figureCategory ?? ''}\n ?disabled=${!saved}\n placeholder=${i18next.t('figure.text.category-placeholder')}\n @change=${(e: Event) => this.catalog({ category: (e.target as HTMLInputElement).value.trim() })}\n />\n </div>\n <div field>\n <label>${i18next.t('figure.label.tags')}</label>\n <input\n .value=${(this.figureTags ?? []).join(', ')}\n ?disabled=${!saved}\n placeholder=${i18next.t('figure.text.tags-placeholder')}\n @change=${(e: Event) => this.catalog({ tags: tagsOf((e.target as HTMLInputElement).value) })}\n />\n ${saved ? nothing : html`<small>${i18next.t('figure.text.catalog-needs-a-save')}</small>`}\n </div>\n `\n }\n\n private declare(placement: Placement) {\n if (!this.source) return\n this.command(occupancyFromParts(this.source, placement))\n }\n\n private command(action: V3AuthoringAction) {\n this.dispatchEvent(new CustomEvent('v3-command', { detail: { action }, bubbles: true, composed: true }))\n }\n\n private catalog(patch: { category?: string; tags?: string[] }) {\n this.dispatchEvent(new CustomEvent('v3-catalog', { detail: patch, bubbles: true, composed: true }))\n }\n}\n"]}
@@ -12,6 +12,7 @@ export declare class FigureV3Canvas extends LitElement {
12
12
  private readonly camera;
13
13
  private controls?;
14
14
  private observer?;
15
+ private themeObserver?;
15
16
  private initialized;
16
17
  private contextAtRender;
17
18
  render(): import("lit-html").TemplateResult<1>;
@@ -21,6 +22,11 @@ export declare class FigureV3Canvas extends LitElement {
21
22
  protected updated(changed: PropertyValues): void;
22
23
  private updateGeometry;
23
24
  fit(): void;
25
+ /**
26
+ * The scene's background, taken from the host's computed background — the token resolved and normalised to
27
+ * `rgb(r, g, b)`, which THREE.Color reads. The token's own text may use the space-separated form it does not.
28
+ */
29
+ private paintBackground;
24
30
  private draw;
25
31
  private pick;
26
32
  thumbnail(): any;
@@ -33,7 +33,12 @@ let FigureV3Canvas = class FigureV3Canvas extends LitElement {
33
33
  min-width: 0;
34
34
  min-height: 0;
35
35
  position: relative;
36
- background: #eef2f4;
36
+ /*
37
+ The working board is one step above the surface in both themes (UX, 2026-09-24): surface-container is 238
38
+ in light and 31 in dark. The 3D background is read from this same value (paintBackground), so the
39
+ first paint and the scene agree and there is no flash between them.
40
+ */
41
+ background: var(--md-sys-color-surface-container);
37
42
  }
38
43
  canvas {
39
44
  display: block;
@@ -45,7 +50,7 @@ let FigureV3Canvas = class FigureV3Canvas extends LitElement {
45
50
  inset: 45% 1rem auto;
46
51
  text-align: center;
47
52
  pointer-events: none;
48
- color: #526773;
53
+ color: var(--md-sys-color-on-surface-variant);
49
54
  }
50
55
  `; }
51
56
  render() {
@@ -66,7 +71,16 @@ let FigureV3Canvas = class FigureV3Canvas extends LitElement {
66
71
  const canvas = this.renderRoot.querySelector('canvas');
67
72
  this.renderer = new THREE.WebGLRenderer({ canvas, antialias: true, preserveDrawingBuffer: true });
68
73
  this.renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
69
- this.scene.background = new THREE.Color('#eef2f4');
74
+ this.paintBackground();
75
+ /*
76
+ The app switches theme by the body's class (light · dark). Reading the colour once at start left a light
77
+ board in the middle of a dark screen after every switch (seen 2026-09-24), so it is read again then.
78
+ */
79
+ this.themeObserver = new MutationObserver(() => {
80
+ this.paintBackground();
81
+ this.draw();
82
+ });
83
+ this.themeObserver.observe(document.body, { attributes: true, attributeFilter: ['class'] });
70
84
  this.scene.add(this.group, new THREE.HemisphereLight(0xffffff, 0x62717d, 2.5));
71
85
  const light = new THREE.DirectionalLight(0xffffff, 3);
72
86
  light.position.set(1, 2, 3);
@@ -123,12 +137,22 @@ let FigureV3Canvas = class FigureV3Canvas extends LitElement {
123
137
  this.controls?.update();
124
138
  this.draw();
125
139
  }
140
+ /**
141
+ * The scene's background, taken from the host's computed background — the token resolved and normalised to
142
+ * `rgb(r, g, b)`, which THREE.Color reads. The token's own text may use the space-separated form it does not.
143
+ */
144
+ paintBackground() {
145
+ const colour = getComputedStyle(this).backgroundColor;
146
+ if (colour && colour !== 'rgba(0, 0, 0, 0)' && colour !== 'transparent')
147
+ this.scene.background = new THREE.Color(colour);
148
+ }
126
149
  thumbnail() {
127
150
  this.draw();
128
151
  return this.renderer?.domElement.toDataURL('image/png');
129
152
  }
130
153
  disconnectedCallback() {
131
154
  this.observer?.disconnect();
155
+ this.themeObserver?.disconnect();
132
156
  this.controls?.dispose();
133
157
  disposeV3Meshes(this.group);
134
158
  this.renderer?.dispose();
@@ -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,EAAuB,MAAM,KAAK,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAqB,MAAM,kBAAkB,CAAA;AAEtF,iGAAiG;AAE1F,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAsB2B,UAAK,GAAmB,EAAE,CAAA;QAC1B,YAAO,GAA2B,EAAE,CAAA;QACxD,YAAO,GAAG,EAAE,CAAA;QAEP,UAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAA;QACzB,UAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAA;QACzB,WAAM,GAAG,IAAI,KAAK,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAGlE,gBAAW,GAAG,KAAK,CAAA;QACnB,oBAAe,GAAG,EAAE,CAAA;QA2EpB,SAAI,GAAG,GAAG,EAAE;YAClB,IAAI,IAAI,CAAC,QAAQ;gBAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAClE,CAAC,CAAA;QACO,SAAI,GAAG,C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AAE;;+CAAa;AAxBb,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAwI1B","sourcesContent":["import { LitElement, html, css, type PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport * as THREE from 'three'\nimport { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'\nimport { replaceV3Meshes, disposeV3Meshes, type V3RenderPart } from './v3-renderer.js'\n\n/** Renders evaluated V3 geometry directly. There is no parts/base or things-scene conversion. */\n@customElement('figure-v3-canvas')\nexport class FigureV3Canvas extends LitElement {\n static styles = css`\n :host {\n display: block;\n min-width: 0;\n min-height: 0;\n position: relative;\n background: #eef2f4;\n }\n canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n p {\n position: absolute;\n inset: 45% 1rem auto;\n text-align: center;\n pointer-events: none;\n color: #526773;\n }\n `\n @property({ attribute: false }) parts: V3RenderPart[] = []\n @property({ attribute: false }) palette: Record<string, string> = {}\n @property() context = ''\n private renderer?: THREE.WebGLRenderer\n private readonly scene = new THREE.Scene()\n private readonly group = new THREE.Group()\n private readonly camera = new THREE.PerspectiveCamera(40, 1, 0.1, 1000000)\n private controls?: OrbitControls\n private observer?: ResizeObserver\n private initialized = false\n private contextAtRender = ''\n render() {\n return html`<canvas aria-label=\"Figure 3D 모델\" @pointerup=${this.pick}></canvas\n >${this.parts.length ? null : html`<p>도형을 추가해 모델링을 시작하세요.</p>`}`\n }\n protected firstUpdated() {\n this.initialize()\n }\n connectedCallback() {\n super.connectedCallback()\n if (this.hasUpdated) void this.updateComplete.then(() => this.initialize())\n }\n private initialize() {\n if (this.initialized || !this.isConnected) return\n const canvas = this.renderRoot.querySelector('canvas')!\n this.renderer = new THREE.WebGLRenderer({ canvas, antialias: true, preserveDrawingBuffer: true })\n this.renderer.setPixelRatio(Math.min(devicePixelRatio, 2))\n this.scene.background = new THREE.Color('#eef2f4')\n this.scene.add(this.group, new THREE.HemisphereLight(0xffffff, 0x62717d, 2.5))\n const light = new THREE.DirectionalLight(0xffffff, 3)\n light.position.set(1, 2, 3)\n this.scene.add(light)\n this.controls = new OrbitControls(this.camera, canvas)\n this.controls.addEventListener('change', this.draw)\n this.observer = new ResizeObserver(() => {\n const r = this.getBoundingClientRect()\n if (r.width && r.height) {\n this.renderer!.setSize(r.width, r.height, false)\n this.camera.aspect = r.width / r.height\n this.camera.updateProjectionMatrix()\n this.draw()\n }\n })\n this.observer.observe(this)\n this.initialized = true\n this.updateGeometry(true)\n }\n protected updated(changed: PropertyValues) {\n if (this.initialized && (changed.has('parts') || changed.has('palette') || changed.has('context')))\n this.updateGeometry(this.contextAtRender !== this.context)\n }\n private updateGeometry(fit: boolean) {\n try {\n const wasEmpty = this.group.children.length === 0\n replaceV3Meshes(this.group, this.parts, this.palette)\n this.contextAtRender = this.context\n if (fit || wasEmpty) this.fit()\n this.draw()\n } catch (error) {\n // Do not leave another model's geometry visible after a failed context switch.\n if (this.contextAtRender !== this.context) {\n disposeV3Meshes(this.group)\n this.draw()\n }\n this.dispatchEvent(new CustomEvent('render-error', { detail: error, bubbles: true, composed: true }))\n }\n }\n fit() {\n const bounds = new THREE.Box3().setFromObject(this.group),\n center = new THREE.Vector3(),\n size = new THREE.Vector3()\n if (!bounds.isEmpty()) {\n bounds.getCenter(center)\n bounds.getSize(size)\n }\n const radius = Math.max(size.length() / 2, 100),\n distance = (radius / Math.sin(THREE.MathUtils.degToRad(this.camera.fov / 2))) * 1.3\n this.camera.position.copy(center).add(new THREE.Vector3(1, 0.8, 1).normalize().multiplyScalar(distance))\n this.camera.near = Math.max(0.01, distance / 10000)\n this.camera.far = Math.max(10000, distance * 100)\n this.camera.updateProjectionMatrix()\n this.controls?.target.copy(center)\n this.controls?.update()\n this.draw()\n }\n private draw = () => {\n if (this.renderer) this.renderer.render(this.scene, this.camera)\n }\n private pick = (event: PointerEvent) => {\n const r = (event.currentTarget as HTMLCanvasElement).getBoundingClientRect(),\n ray = new THREE.Raycaster()\n ray.setFromCamera(\n new THREE.Vector2(((event.clientX - r.left) / r.width) * 2 - 1, (-(event.clientY - r.top) / r.height) * 2 + 1),\n this.camera\n )\n const hit = ray.intersectObjects(this.group.children)[0]\n this.dispatchEvent(\n new CustomEvent('part-selected', { detail: hit?.object.name ?? '', bubbles: true, composed: true })\n )\n }\n thumbnail() {\n this.draw()\n return this.renderer?.domElement.toDataURL('image/png')\n }\n disconnectedCallback() {\n this.observer?.disconnect()\n this.controls?.dispose()\n disposeV3Meshes(this.group)\n this.renderer?.dispose()\n this.renderer = undefined\n this.scene.clear()\n this.initialized = false\n super.disconnectedCallback()\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,EAAuB,MAAM,KAAK,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAqB,MAAM,kBAAkB,CAAA;AAEtF,iGAAiG;AAE1F,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QA2B2B,UAAK,GAAmB,EAAE,CAAA;QAC1B,YAAO,GAA2B,EAAE,CAAA;QACxD,YAAO,GAAG,EAAE,CAAA;QAEP,UAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAA;QACzB,UAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAA;QACzB,WAAM,GAAG,IAAI,KAAK,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAIlE,gBAAW,GAAG,KAAK,CAAA;QACnB,oBAAe,GAAG,EAAE,CAAA;QA4FpB,SAAI,GAAG,GAAG,EA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;IAgBD,SAAS;QACP,IAAI,CAAC,IAAI,EAAE,CAAA;QACX,OAAO,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACzD,CAAC;IACD,oBAAoB;QAClB,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;QAC3B,IAAI,CAAC,aAAa,EAAE,UAAU,EAAE,CAAA;QAChC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;QACxB,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC3B,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;QACzB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAClB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;QACxB,KAAK,CAAC,oBAAoB,EAAE,CAAA;IAC9B,CAAC;;AApI+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;6CAA2B;AAC1B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;+CAAqC;AACxD;IAAX,QAAQ,EAAE;;+CAAa;AA7Bb,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAgK1B","sourcesContent":["import { LitElement, html, css, type PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport * as THREE from 'three'\nimport { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'\nimport { replaceV3Meshes, disposeV3Meshes, type V3RenderPart } from './v3-renderer.js'\n\n/** Renders evaluated V3 geometry directly. There is no parts/base or things-scene conversion. */\n@customElement('figure-v3-canvas')\nexport class FigureV3Canvas extends LitElement {\n static styles = css`\n :host {\n display: block;\n min-width: 0;\n min-height: 0;\n position: relative;\n /*\n The working board is one step above the surface in both themes (UX, 2026-09-24): surface-container is 238\n in light and 31 in dark. The 3D background is read from this same value (paintBackground), so the\n first paint and the scene agree and there is no flash between them.\n */\n background: var(--md-sys-color-surface-container);\n }\n canvas {\n display: block;\n width: 100%;\n height: 100%;\n }\n p {\n position: absolute;\n inset: 45% 1rem auto;\n text-align: center;\n pointer-events: none;\n color: var(--md-sys-color-on-surface-variant);\n }\n `\n @property({ attribute: false }) parts: V3RenderPart[] = []\n @property({ attribute: false }) palette: Record<string, string> = {}\n @property() context = ''\n private renderer?: THREE.WebGLRenderer\n private readonly scene = new THREE.Scene()\n private readonly group = new THREE.Group()\n private readonly camera = new THREE.PerspectiveCamera(40, 1, 0.1, 1000000)\n private controls?: OrbitControls\n private observer?: ResizeObserver\n private themeObserver?: MutationObserver\n private initialized = false\n private contextAtRender = ''\n render() {\n return html`<canvas aria-label=\"Figure 3D 모델\" @pointerup=${this.pick}></canvas\n >${this.parts.length ? null : html`<p>도형을 추가해 모델링을 시작하세요.</p>`}`\n }\n protected firstUpdated() {\n this.initialize()\n }\n connectedCallback() {\n super.connectedCallback()\n if (this.hasUpdated) void this.updateComplete.then(() => this.initialize())\n }\n private initialize() {\n if (this.initialized || !this.isConnected) return\n const canvas = this.renderRoot.querySelector('canvas')!\n this.renderer = new THREE.WebGLRenderer({ canvas, antialias: true, preserveDrawingBuffer: true })\n this.renderer.setPixelRatio(Math.min(devicePixelRatio, 2))\n this.paintBackground()\n /*\n The app switches theme by the body's class (light · dark). Reading the colour once at start left a light\n board in the middle of a dark screen after every switch (seen 2026-09-24), so it is read again then.\n */\n this.themeObserver = new MutationObserver(() => {\n this.paintBackground()\n this.draw()\n })\n this.themeObserver.observe(document.body, { attributes: true, attributeFilter: ['class'] })\n this.scene.add(this.group, new THREE.HemisphereLight(0xffffff, 0x62717d, 2.5))\n const light = new THREE.DirectionalLight(0xffffff, 3)\n light.position.set(1, 2, 3)\n this.scene.add(light)\n this.controls = new OrbitControls(this.camera, canvas)\n this.controls.addEventListener('change', this.draw)\n this.observer = new ResizeObserver(() => {\n const r = this.getBoundingClientRect()\n if (r.width && r.height) {\n this.renderer!.setSize(r.width, r.height, false)\n this.camera.aspect = r.width / r.height\n this.camera.updateProjectionMatrix()\n this.draw()\n }\n })\n this.observer.observe(this)\n this.initialized = true\n this.updateGeometry(true)\n }\n protected updated(changed: PropertyValues) {\n if (this.initialized && (changed.has('parts') || changed.has('palette') || changed.has('context')))\n this.updateGeometry(this.contextAtRender !== this.context)\n }\n private updateGeometry(fit: boolean) {\n try {\n const wasEmpty = this.group.children.length === 0\n replaceV3Meshes(this.group, this.parts, this.palette)\n this.contextAtRender = this.context\n if (fit || wasEmpty) this.fit()\n this.draw()\n } catch (error) {\n // Do not leave another model's geometry visible after a failed context switch.\n if (this.contextAtRender !== this.context) {\n disposeV3Meshes(this.group)\n this.draw()\n }\n this.dispatchEvent(new CustomEvent('render-error', { detail: error, bubbles: true, composed: true }))\n }\n }\n fit() {\n const bounds = new THREE.Box3().setFromObject(this.group),\n center = new THREE.Vector3(),\n size = new THREE.Vector3()\n if (!bounds.isEmpty()) {\n bounds.getCenter(center)\n bounds.getSize(size)\n }\n const radius = Math.max(size.length() / 2, 100),\n distance = (radius / Math.sin(THREE.MathUtils.degToRad(this.camera.fov / 2))) * 1.3\n this.camera.position.copy(center).add(new THREE.Vector3(1, 0.8, 1).normalize().multiplyScalar(distance))\n this.camera.near = Math.max(0.01, distance / 10000)\n this.camera.far = Math.max(10000, distance * 100)\n this.camera.updateProjectionMatrix()\n this.controls?.target.copy(center)\n this.controls?.update()\n this.draw()\n }\n /**\n * The scene's background, taken from the host's computed background — the token resolved and normalised to\n * `rgb(r, g, b)`, which THREE.Color reads. The token's own text may use the space-separated form it does not.\n */\n private paintBackground() {\n const colour = getComputedStyle(this).backgroundColor\n if (colour && colour !== 'rgba(0, 0, 0, 0)' && colour !== 'transparent') this.scene.background = new THREE.Color(colour)\n }\n private draw = () => {\n if (this.renderer) this.renderer.render(this.scene, this.camera)\n }\n private pick = (event: PointerEvent) => {\n const r = (event.currentTarget as HTMLCanvasElement).getBoundingClientRect(),\n ray = new THREE.Raycaster()\n ray.setFromCamera(\n new THREE.Vector2(((event.clientX - r.left) / r.width) * 2 - 1, (-(event.clientY - r.top) / r.height) * 2 + 1),\n this.camera\n )\n const hit = ray.intersectObjects(this.group.children)[0]\n this.dispatchEvent(\n new CustomEvent('part-selected', { detail: hit?.object.name ?? '', bubbles: true, composed: true })\n )\n }\n thumbnail() {\n this.draw()\n return this.renderer?.domElement.toDataURL('image/png')\n }\n disconnectedCallback() {\n this.observer?.disconnect()\n this.themeObserver?.disconnect()\n this.controls?.dispose()\n disposeV3Meshes(this.group)\n this.renderer?.dispose()\n this.renderer = undefined\n this.scene.clear()\n this.initialized = false\n super.disconnectedCallback()\n }\n}\n"]}
@@ -44,6 +44,12 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
44
44
  flex-direction: column;
45
45
  min-height: 0;
46
46
  height: 100%;
47
+ /*
48
+ The editor folds by the width it is given, not the window's. The rail (208 open, 56 closed) and the page's
49
+ 320 side take their share first, so a window rule was wrong whenever either was there: at 945 with the rail
50
+ open the editor had 417 and still drew its 660 of columns, over the side (UX ruling, 2026-09-24).
51
+ */
52
+ container-type: inline-size;
47
53
  font: 13px sans-serif;
48
54
  color: var(--md-sys-color-on-surface, #22343f);
49
55
  }
@@ -52,7 +58,7 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
52
58
  align-items: center;
53
59
  gap: 8px;
54
60
  padding: 10px;
55
- border-bottom: 1px solid #d4dde2;
61
+ border-bottom: 1px solid var(--md-sys-color-outline-variant);
56
62
  flex-wrap: wrap;
57
63
  }
58
64
  main {
@@ -67,10 +73,10 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
67
73
  background: var(--md-sys-color-surface, #fff);
68
74
  }
69
75
  aside:first-child {
70
- border-right: 1px solid #d4dde2;
76
+ border-right: 1px solid var(--md-sys-color-outline-variant);
71
77
  }
72
78
  aside:last-child {
73
- border-left: 1px solid #d4dde2;
79
+ border-left: 1px solid var(--md-sys-color-outline-variant);
74
80
  }
75
81
  h3 {
76
82
  font-size: var(--ui-t-body, 13px);
@@ -85,7 +91,7 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
85
91
  font: inherit;
86
92
  box-sizing: border-box;
87
93
  height: 34px;
88
- border: 1px solid #cbd5dc;
94
+ border: 1px solid var(--md-sys-color-outline-variant);
89
95
  border-radius: 6px;
90
96
  background: var(--md-sys-color-surface, #fff);
91
97
  color: inherit;
@@ -100,8 +106,9 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
100
106
  cursor: default;
101
107
  }
102
108
  button[aria-pressed='true'] {
103
- background: #d6edf0;
104
- border-color: #337783;
109
+ background: var(--md-sys-color-secondary-container);
110
+ color: var(--md-sys-color-on-secondary-container);
111
+ border-color: var(--md-sys-color-primary);
105
112
  }
106
113
  .parts {
107
114
  display: grid;
@@ -124,25 +131,46 @@ let FigureV3Editor = class FigureV3Editor extends LitElement {
124
131
  }
125
132
  .error {
126
133
  padding: 10px;
127
- background: #fff0eb;
128
- color: #922716;
134
+ background: var(--md-sys-color-error-container);
135
+ color: var(--md-sys-color-on-error-container);
129
136
  white-space: pre-wrap;
130
137
  }
131
138
  .status {
132
139
  margin-left: auto;
133
140
  }
134
141
  .hint {
135
- color: #637783;
142
+ color: var(--md-sys-color-on-surface-variant);
136
143
  line-height: 1.5;
137
144
  }
138
- @media (max-width: 800px) {
145
+ /* 660 and over: parts | canvas | inputs. Below that the sum of the columns' least widths no longer fits. */
146
+ @container (max-width: 659px) {
139
147
  main {
140
148
  grid-template-columns: 140px minmax(160px, 1fr);
141
149
  }
142
150
  aside:last-child {
143
151
  grid-column: 1/-1;
144
152
  max-height: 260px;
145
- border-top: 1px solid #d4dde2;
153
+ border-left: none;
154
+ border-top: 1px solid var(--md-sys-color-outline-variant);
155
+ }
156
+ }
157
+ /* Under 420: one column. The canvas first — seeing what is being made comes before the lists — and main scrolls. */
158
+ @container (max-width: 419px) {
159
+ main {
160
+ grid-template-columns: minmax(0, 1fr);
161
+ grid-template-rows: minmax(240px, 45%);
162
+ grid-auto-rows: auto;
163
+ overflow-y: auto;
164
+ }
165
+ figure-v3-canvas {
166
+ order: -1;
167
+ }
168
+ aside:first-child {
169
+ border-right: none;
170
+ border-top: 1px solid var(--md-sys-color-outline-variant);
171
+ }
172
+ aside:last-child {
173
+ max-height: none;
146
174
  }
147
175
  }
148
176
  `; }