@things-factory/figure-viewer 10.1.302 → 10.1.303

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.
@@ -12,6 +12,6 @@ export declare class FigureFactsList extends FigureFactsList_base {
12
12
  static styles: import("lit").CSSResult;
13
13
  asset?: FigureAsset;
14
14
  row?: DetailFactsRow;
15
- render(): import("lit-html").TemplateResult<1> | typeof nothing;
15
+ render(): typeof nothing | import("lit-html").TemplateResult<1>;
16
16
  }
17
17
  export {};
@@ -0,0 +1,80 @@
1
+ import '@material/web/icon/icon.js';
2
+ import { LitElement, nothing } from 'lit';
3
+ import type { FigureAsset } from '@hatiolab/figure-model';
4
+ /** What a preview tells the figures standing in it, in the board's words: a board sets the same keys on a figure. */
5
+ export type MotionKey = 'clips' | 'parameters' | 'motion' | 'figureValues';
6
+ declare const FigureMotionControls_base: (new (...args: any[]) => LitElement) & typeof LitElement;
7
+ /**
8
+ * How a figure moves in a preview: the one set of controls every preview of a figure shows -- the modeller's and the
9
+ * catalogue's (figure-asset-viewer), a board server's library among them. Two previews played a figure two ways: the
10
+ * catalogue's played one clip at a time with a mark per clip, put the joints first and knew nothing of the data's states
11
+ * (the user, 2026-11-21: 「다른 미리보기에는 클립과 상태 우선이 적용이 안 되어 있다」).
12
+ *
13
+ * What plays comes first -- the data's states, each motion group's clips and speed, the clips of their own -- and the
14
+ * joints under it, folded from ten on (the user, 2026-11-21: 「클립위주로 배치를 바꿔주면 어떤가」). A group field the data
15
+ * writes is moved by the data's value, not offered on the group, as on a board (ADR-0051 §8).
16
+ *
17
+ * The values are the preview's, never the figure's: each change is told to the figures standing in the host as a
18
+ * `motion-tell` event (detail `{ key, values }`, the board's key and its whole value), and the host sets it on them.
19
+ * The look takes the host's colour (`currentColor`): light text on the modeller's stage, the panel's on the catalogue.
20
+ */
21
+ export declare class FigureMotionControls extends FigureMotionControls_base {
22
+ static styles: import("lit").CSSResult;
23
+ asset?: FigureAsset;
24
+ /** Data tried in the modeller's data tab, given to the figures as their `data`: a row it sets is said, not offered. */
25
+ sample: unknown;
26
+ /** Clip speeds of the clips in no group, by clip -- as a board's `clips`. */
27
+ private driving;
28
+ /** Control values tried, by input -- as a board's `parameters`. */
29
+ private giving;
30
+ /** Per motion group, the clip played and how fast (ADR-0051 §3.2) -- as a board's `motion`. */
31
+ private moving;
32
+ /** Data values given by accessor, as a board's saved `figureValues`: what moves a group whose clip or speed the data writes. */
33
+ private valuing;
34
+ private jointsFolded?;
35
+ /** The clip speeds tried here, by clip. */
36
+ get clipsTried(): Record<string, number>;
37
+ /** The control values tried here, by input. */
38
+ get controlsTried(): Record<string, number>;
39
+ /** The controls tried away from the default pose, those a starting-pose hold solves left out: a pose to keep. */
40
+ get poseChanged(): string[];
41
+ /** Every value tried let go: the figure stands in its default pose, and its clips move it again. */
42
+ clearTried(): void;
43
+ /**
44
+ * The values tried as the pose to keep, and let go here: the controls a starting-pose hold solves are left out -- the
45
+ * kernel refuses them (HOLD_OWNED) and solves them again for the pose kept (2026-11-21).
46
+ */
47
+ takePose(): Record<string, number>;
48
+ /** What plays let go, for figures stood up again: their clocks start over. The control values tried stay. */
49
+ stopPlaying(): void;
50
+ /** Everything tried let go, for another figure. */
51
+ reset(): void;
52
+ render(): typeof nothing | import("lit-html").TemplateResult<1>;
53
+ private renderControl;
54
+ /**
55
+ * A row's name that scrubs its value when dragged sideways, as the property panel's names do (\`scrubLabel\`): Shift for
56
+ * finer steps, held within the row's range. The values are tried, not recorded, so each move is the value. The sliders
57
+ * ran 360 degrees over 96 pixels, too coarse to land an angle (user 2026-11-12).
58
+ */
59
+ private scrubName;
60
+ /**
61
+ * A slider's value as a box to type in, the same on every row: the value a slider cannot land on, typed (a step of the
62
+ * range's hundredth, robot dog 2026-11-03); one column of boxes, not boxes over plain numbers (user 2026-11-12).
63
+ */
64
+ private typedBox;
65
+ /** A value the data's bindings read, as the board's saved values give it: a number on a slider when it has a range, a choice when it is closed. */
66
+ private renderDataValue;
67
+ private renderDial;
68
+ private value;
69
+ private move;
70
+ private drive;
71
+ private release;
72
+ private give;
73
+ private tell;
74
+ }
75
+ declare global {
76
+ interface HTMLElementTagNameMap {
77
+ 'figure-motion-controls': FigureMotionControls;
78
+ }
79
+ }
80
+ export {};
@@ -0,0 +1,534 @@
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 { dialShape } from './angle-dial.js';
7
+ import { controlsOf, heldAtStartOf } from './controls.js';
8
+ import { dataValueAt, domainOf, motionWrittenByData, sampledStatesOf, typedValueOf, valueRowsOf } from './data-values.js';
9
+ import { jointsFoldedOf, parametersForClip, playedControlsOf } from './detail-motion.js';
10
+ import { scrubLabel } from './scrub.js';
11
+ import { unitWord } from './unit-words.js';
12
+ /**
13
+ * How a figure moves in a preview: the one set of controls every preview of a figure shows -- the modeller's and the
14
+ * catalogue's (figure-asset-viewer), a board server's library among them. Two previews played a figure two ways: the
15
+ * catalogue's played one clip at a time with a mark per clip, put the joints first and knew nothing of the data's states
16
+ * (the user, 2026-11-21: 「다른 미리보기에는 클립과 상태 우선이 적용이 안 되어 있다」).
17
+ *
18
+ * What plays comes first -- the data's states, each motion group's clips and speed, the clips of their own -- and the
19
+ * joints under it, folded from ten on (the user, 2026-11-21: 「클립위주로 배치를 바꿔주면 어떤가」). A group field the data
20
+ * writes is moved by the data's value, not offered on the group, as on a board (ADR-0051 §8).
21
+ *
22
+ * The values are the preview's, never the figure's: each change is told to the figures standing in the host as a
23
+ * `motion-tell` event (detail `{ key, values }`, the board's key and its whole value), and the host sets it on them.
24
+ * The look takes the host's colour (`currentColor`): light text on the modeller's stage, the panel's on the catalogue.
25
+ */
26
+ let FigureMotionControls = class FigureMotionControls extends localize(i18next)(LitElement) {
27
+ constructor() {
28
+ super(...arguments);
29
+ /** Data tried in the modeller's data tab, given to the figures as their `data`: a row it sets is said, not offered. */
30
+ this.sample = null;
31
+ /** Clip speeds of the clips in no group, by clip -- as a board's `clips`. */
32
+ this.driving = {};
33
+ /** Control values tried, by input -- as a board's `parameters`. */
34
+ this.giving = {};
35
+ /** Per motion group, the clip played and how fast (ADR-0051 §3.2) -- as a board's `motion`. */
36
+ this.moving = {};
37
+ /** Data values given by accessor, as a board's saved `figureValues`: what moves a group whose clip or speed the data writes. */
38
+ this.valuing = {};
39
+ }
40
+ static { this.styles = css `
41
+ /*
42
+ One grid for every row, each row its subgrid: the rows' names in one column, so a value's field starts where the one
43
+ above it does whatever the names' lengths (sweep 2026-10-27 U7). The slider's column is the host's to widen.
44
+ */
45
+ :host {
46
+ display: grid;
47
+ grid-template-columns: max-content 20px var(--figure-motion-slider, 96px) 44px;
48
+ grid-template-rows: auto auto minmax(0, 1fr);
49
+ gap: 6px 8px;
50
+ align-items: center;
51
+ min-height: 0;
52
+ font-size: var(--ui-t-micro, 11px);
53
+ }
54
+ :host > * {
55
+ grid-column: 1 / -1;
56
+ }
57
+ div[playing],
58
+ div[joints] {
59
+ display: grid;
60
+ grid-template-columns: subgrid;
61
+ gap: 6px 8px;
62
+ align-items: center;
63
+ }
64
+ /*
65
+ With the joints open, what plays takes at most what the host gives it and scrolls inside it, so the joints keep the
66
+ rest: many clips or states took all of it, and the joints' rows, opened, had no height to show in (2026-11-21).
67
+ */
68
+ :host([joints-open]) div[playing] {
69
+ max-height: var(--figure-motion-playing-max, none);
70
+ overflow-y: auto;
71
+ overscroll-behavior: contain;
72
+ }
73
+ div[playing] > *,
74
+ div[joints] > * {
75
+ grid-column: 1 / -1;
76
+ }
77
+ div[joints] {
78
+ align-self: stretch;
79
+ min-height: 0;
80
+ overflow-y: auto;
81
+ overscroll-behavior: contain;
82
+ }
83
+ /* The joints' line: folds their rows alone, saying how many there are. */
84
+ button[fold-joints] {
85
+ display: flex;
86
+ align-items: center;
87
+ gap: 4px;
88
+ padding: 6px 0 0;
89
+ font: inherit;
90
+ color: inherit;
91
+ text-align: left;
92
+ background: none;
93
+ border: 0;
94
+ border-top: 1px solid color-mix(in srgb, currentColor 14%, transparent);
95
+ opacity: 0.8;
96
+ cursor: pointer;
97
+ }
98
+ button[fold-joints]:hover {
99
+ opacity: 1;
100
+ }
101
+ button[fold-joints] md-icon {
102
+ --md-icon-size: 16px;
103
+ }
104
+ label {
105
+ display: grid;
106
+ grid-template-columns: subgrid;
107
+ align-items: center;
108
+ }
109
+ /* A name and its unit on one line: 「position.x」 put its 「mm」 on a second line with room beside it (user 2026-11-12). */
110
+ label > span:first-child {
111
+ white-space: nowrap;
112
+ }
113
+ select {
114
+ grid-column: 2 / -1;
115
+ min-width: 0;
116
+ font: inherit;
117
+ color: inherit;
118
+ background-color: color-mix(in srgb, currentColor 14%, transparent);
119
+ border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
120
+ border-radius: 5px;
121
+ }
122
+ /* A motion group's clips as buttons: a list the system draws is not seen in a recording of the preview. */
123
+ span[clip-choices] {
124
+ grid-column: 2 / -1;
125
+ display: flex;
126
+ flex-wrap: wrap;
127
+ gap: 4px;
128
+ min-width: 0;
129
+ }
130
+ span[clip-choices] button {
131
+ font: inherit;
132
+ color: inherit;
133
+ padding: 1px 8px;
134
+ background-color: color-mix(in srgb, currentColor 8%, transparent);
135
+ border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
136
+ border-radius: 10px;
137
+ cursor: pointer;
138
+ }
139
+ span[clip-choices] button[aria-pressed='true'] {
140
+ background-color: color-mix(in srgb, currentColor 30%, transparent);
141
+ border-color: color-mix(in srgb, currentColor 60%, transparent);
142
+ font-weight: 600;
143
+ }
144
+ svg[dial] {
145
+ width: 20px;
146
+ height: 20px;
147
+ }
148
+ svg[dial] path {
149
+ fill: color-mix(in srgb, currentColor 22%, transparent);
150
+ }
151
+ svg[dial] line {
152
+ stroke: var(--md-sys-color-primary, #7cc6ff);
153
+ stroke-width: 2;
154
+ stroke-linecap: round;
155
+ }
156
+ svg[dial] circle {
157
+ fill: none;
158
+ stroke: color-mix(in srgb, currentColor 35%, transparent);
159
+ }
160
+ span[drive] {
161
+ opacity: 0.6;
162
+ }
163
+ input {
164
+ width: 100%;
165
+ accent-color: var(--md-sys-color-primary);
166
+ }
167
+ /* A name that scrubs its value, in the look the side panel gives it (side-panel-styles \`[scrub]\`). */
168
+ label > span[scrub] {
169
+ cursor: ew-resize;
170
+ user-select: none;
171
+ touch-action: none;
172
+ }
173
+ /* A check box in the dial's column, where every field starts. */
174
+ input[type='checkbox'] {
175
+ grid-column: 2 / -1;
176
+ justify-self: start;
177
+ width: auto;
178
+ margin: 0;
179
+ }
180
+ input:not([type='range']):not([type='checkbox']) {
181
+ box-sizing: border-box;
182
+ min-width: 0;
183
+ font: inherit;
184
+ color: inherit;
185
+ background-color: color-mix(in srgb, currentColor 14%, transparent);
186
+ border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
187
+ border-radius: 5px;
188
+ }
189
+ /*
190
+ Three widths only: a slider, its value's box, and a field that is the whole row's -- a choice, a text, a number with
191
+ no range -- from where the dial starts to the right edge, as the choices are (user 2026-11-12: every width differed).
192
+ */
193
+ input:not([type='range']):not([type='number']):not([type='checkbox']),
194
+ input[wide] {
195
+ grid-column: 2 / -1;
196
+ width: auto;
197
+ padding: 1px 4px;
198
+ }
199
+ /* A control's value, typed where the slider cannot land on it (a step of the range's hundredth, robot dog 2026-11-03). */
200
+ input[typed] {
201
+ padding: 0 3px;
202
+ text-align: right;
203
+ font-variant-numeric: tabular-nums;
204
+ }
205
+ label[sampled] output {
206
+ grid-column: 2 / -1;
207
+ text-align: left;
208
+ }
209
+ output {
210
+ font-variant-numeric: tabular-nums;
211
+ text-align: right;
212
+ opacity: 0.85;
213
+ }
214
+ p[hint] {
215
+ margin: 0;
216
+ opacity: 0.75;
217
+ }
218
+ `; }
219
+ /** The clip speeds tried here, by clip. */
220
+ get clipsTried() {
221
+ return { ...this.driving };
222
+ }
223
+ /** The control values tried here, by input. */
224
+ get controlsTried() {
225
+ return { ...this.giving };
226
+ }
227
+ /** The controls tried away from the default pose, those a starting-pose hold solves left out: a pose to keep. */
228
+ get poseChanged() {
229
+ const asset = this.asset;
230
+ if (!asset)
231
+ return [];
232
+ const held = heldAtStartOf(asset);
233
+ return Object.keys(this.giving).filter(id => !held.has(id) && this.giving[id] !== asset.stateDefaults[id]);
234
+ }
235
+ /** Every value tried let go: the figure stands in its default pose, and its clips move it again. */
236
+ clearTried() {
237
+ this.giving = {};
238
+ this.tell('parameters', this.giving);
239
+ }
240
+ /**
241
+ * The values tried as the pose to keep, and let go here: the controls a starting-pose hold solves are left out -- the
242
+ * kernel refuses them (HOLD_OWNED) and solves them again for the pose kept (2026-11-21).
243
+ */
244
+ takePose() {
245
+ const held = this.asset ? heldAtStartOf(this.asset) : new Map();
246
+ const values = Object.fromEntries(Object.entries(this.giving).filter(([id]) => !held.has(id)));
247
+ this.giving = {};
248
+ return values;
249
+ }
250
+ /** What plays let go, for figures stood up again: their clocks start over. The control values tried stay. */
251
+ stopPlaying() {
252
+ this.driving = {};
253
+ this.moving = {};
254
+ this.valuing = {};
255
+ }
256
+ /** Everything tried let go, for another figure. */
257
+ reset() {
258
+ this.stopPlaying();
259
+ this.giving = {};
260
+ }
261
+ render() {
262
+ const asset = this.asset;
263
+ if (!asset)
264
+ return nothing;
265
+ const controls = asset.document.model.inputs.filter(i => i.role === 'state');
266
+ /* Clips in a motion group are played by the group's choice of clip, not each by its own speed. */
267
+ const grouped = new Set((asset.motionGroups ?? []).flatMap(g => g.clips));
268
+ const clips = [...new Set((asset.drivers ?? []).map(d => d.clip))].filter(c => !grouped.has(c));
269
+ const rows = valueRowsOf(asset);
270
+ if (!controls.length && !clips.length && !(asset.motionGroups ?? []).length && !rows.length)
271
+ return html `<p hint>${i18next.t('figure.text.detail-no-motion')}</p>`;
272
+ const steps = new Map(controlsOf(asset).map(c => [c.id, c.step]));
273
+ const sampledStates = sampledStatesOf(asset, this.sample);
274
+ const played = playedControlsOf(asset, this.driving, this.moving);
275
+ const jointsFolded = jointsFoldedOf(this.jointsFolded, controls.length);
276
+ this.toggleAttribute('joints-open', !jointsFolded && controls.length > 0);
277
+ return html `<div playing>
278
+ <!-- What plays first -- the data's states, the motion groups' clips, the clips of their own -- and the controls
279
+ under them, scrolling (the user, 2026-11-21: 「클립위주로 배치를 바꿔주면 어떤가」). -->
280
+ ${rows.map(row => this.renderDataValue(row))}
281
+ ${(asset.motionGroups ?? []).map(group => {
282
+ const playing = this.moving[group.id] ?? { clip: group.defaultClip, speed: 0 };
283
+ /* A field the data writes wins over the group's own setting, here as on a board: it is moved by the data values above. */
284
+ const byData = motionWrittenByData(asset)[group.id] ?? { clip: false, speed: false };
285
+ return html `${byData.clip
286
+ ? nothing
287
+ : html `<label>
288
+ <span>${group.label} <span drive>${i18next.t('figure.label.clip')}</span></span>
289
+ <span clip-choices role="group" aria-label=${group.label}>
290
+ ${group.clips.map(c => html `<button type="button" aria-pressed=${String(c === playing.clip)} @click=${() => this.move(group.id, { ...playing, clip: c })}>${c}</button>`)}
291
+ </span>
292
+ </label>`}
293
+ ${byData.speed
294
+ ? nothing
295
+ : html `<label>
296
+ ${this.scrubName(html `${group.label} <span drive>${i18next.t('figure.label.playback-speed')}</span>`, 'ratio', playing.speed, 0, 3, v => this.move(group.id, { ...playing, speed: v }))}
297
+ <span></span>
298
+ <input type="range" min="0" max="3" step="0.05" .value=${String(playing.speed)} @input=${(e) => this.move(group.id, { ...playing, speed: Number(e.target.value) })} />
299
+ ${this.typedBox(group.label, playing.speed, 0, 3, typed => this.move(group.id, { ...playing, speed: typed }))}
300
+ </label>`}`;
301
+ })}
302
+ ${clips.map(clip => {
303
+ /*
304
+ A clip nothing has driven stands still, here as on a board: the instances get a speed only from \`drive\`. The
305
+ slider showed 1.00 over rollers that did not turn (2026-10-03). It shows what plays -- 0 until moved.
306
+ */
307
+ const value = this.driving[clip] ?? 0;
308
+ return html `<label>
309
+ ${this.scrubName(html `${clip} <span drive>${i18next.t('figure.label.playback-speed')}</span>`, 'ratio', value, 0, 3, v => this.drive(clip, v))}
310
+ <span></span>
311
+ <input type="range" min="0" max="3" step="0.05" .value=${String(value)} @input=${(e) => this.drive(clip, Number(e.target.value))} />
312
+ ${this.typedBox(clip, value, 0, 3, typed => this.drive(clip, typed))}
313
+ </label>`;
314
+ })}
315
+ </div>
316
+ ${controls.length
317
+ ? html `<button fold-joints aria-expanded=${String(!jointsFolded)} @click=${() => (this.jointsFolded = !jointsFolded)}>
318
+ <md-icon>${jointsFolded ? 'expand_more' : 'expand_less'}</md-icon>${i18next.t('figure.label.joints-count', { count: controls.length })}
319
+ </button>`
320
+ : nothing}
321
+ ${jointsFolded || !controls.length ? nothing : html `<div joints>${controls.map(control => this.renderControl(asset, control, steps, sampledStates, played))}</div>`}`;
322
+ }
323
+ renderControl(asset, control, steps, sampledStates, played) {
324
+ /* A control the data tab's sample sets is what the figure shows, as a value row the sample gives: said, not offered. */
325
+ const fromSample = sampledStates[control.id];
326
+ if (fromSample !== undefined)
327
+ return html `<label sampled title=${i18next.t('figure.text.data-value-from-sample')}>
328
+ <span>${asset.stateInputs?.[control.id]?.label ?? control.id} <span drive>${i18next.t('figure.label.data-value-from-sample')}</span></span>
329
+ <output>${Math.round(fromSample * 100) / 100} ${unitWord(control.unit)}</output>
330
+ </label>`;
331
+ const value = this.giving[control.id] ?? asset.stateDefaults[control.id] ?? control.min;
332
+ /* The step the editor's controls take (\`controlsOf\`): a degree for an angle, a hundredth of the range otherwise. */
333
+ const step = steps.get(control.id) ?? (control.max - control.min) / 100;
334
+ const label = asset.stateInputs?.[control.id]?.label ?? control.id;
335
+ /*
336
+ A control a playing clip drives moves on the figure while its row stood still at its last number -- 0 under a
337
+ walking leg (review 2026-11-11). The row says the clip has it, and is not given a value until the clip stops.
338
+ */
339
+ const by = played.get(control.id);
340
+ if (by)
341
+ return html `<label played title=${i18next.t('figure.text.control-played-explained', { clip: by })}>
342
+ <span>${label} <span drive>${unitWord(control.unit)}</span></span>
343
+ <span></span>
344
+ <input type="range" min=${control.min} max=${control.max} .value=${String(value)} disabled />
345
+ <output>${i18next.t('figure.text.control-played', { clip: by })}</output>
346
+ </label>`;
347
+ return html `<label>
348
+ ${this.scrubName(html `${label} <span drive>${unitWord(control.unit)}</span>`, control.unit, value, control.min, control.max, v => this.give(control.id, v))}
349
+ ${this.renderDial(control, value)}
350
+ <input type="range" min=${control.min} max=${control.max} step=${step} .value=${String(value)} @input=${(e) => this.give(control.id, Number(e.target.value))} />
351
+ ${this.typedBox(label, value, control.min, control.max, typed => this.give(control.id, typed))}
352
+ </label>`;
353
+ }
354
+ /**
355
+ * A row's name that scrubs its value when dragged sideways, as the property panel's names do (\`scrubLabel\`): Shift for
356
+ * finer steps, held within the row's range. The values are tried, not recorded, so each move is the value. The sliders
357
+ * ran 360 degrees over 96 pixels, too coarse to land an angle (user 2026-11-12).
358
+ */
359
+ scrubName(name, unit, value, min, max, set) {
360
+ const held = (v) => Math.min(Math.max(v, min), max);
361
+ return html `<span
362
+ scrub
363
+ @pointerdown=${(down) => {
364
+ /* A press that did not move gives nothing: an empty field is not given its slider's start by a click on its name. */
365
+ let moved = false;
366
+ scrubLabel(down, { value, unit }, {
367
+ move: v => ((moved = true), set(held(v))),
368
+ release: v => set(held(v)),
369
+ cancel: () => moved && set(value)
370
+ });
371
+ }}
372
+ >${name}</span
373
+ >`;
374
+ }
375
+ /**
376
+ * A slider's value as a box to type in, the same on every row: the value a slider cannot land on, typed (a step of the
377
+ * range's hundredth, robot dog 2026-11-03); one column of boxes, not boxes over plain numbers (user 2026-11-12).
378
+ */
379
+ typedBox(label, value, min, max, set) {
380
+ return html `<input
381
+ typed
382
+ type="number"
383
+ step="any"
384
+ min=${Number.isFinite(min) ? min : nothing}
385
+ max=${Number.isFinite(max) ? max : nothing}
386
+ aria-label=${label}
387
+ .value=${String(Math.round(value * 100) / 100)}
388
+ @change=${(e) => {
389
+ const typed = e.target.valueAsNumber;
390
+ if (Number.isFinite(typed))
391
+ set(Math.min(Math.max(typed, min), max));
392
+ }}
393
+ />`;
394
+ }
395
+ /** A value the data's bindings read, as the board's saved values give it: a number on a slider when it has a range, a choice when it is closed. */
396
+ renderDataValue(row) {
397
+ const node = row.node;
398
+ const label = row.label ?? row.path;
399
+ /*
400
+ The data tab's sample, when it gives the row, is what the figure shows: a value given here is not read. Said, and
401
+ the field not offered, rather than one that changes nothing (robot dog 2026-11-03).
402
+ */
403
+ const sampled = this.sample === null || this.sample === undefined ? undefined : dataValueAt(this.sample, row.path);
404
+ if (sampled !== undefined)
405
+ return html `<label sampled title=${i18next.t('figure.text.data-value-from-sample')}>
406
+ <span>${label} <span drive>${i18next.t('figure.label.data-value-from-sample')}</span></span>
407
+ <output>${typeof sampled === 'boolean' ? i18next.t(sampled ? 'figure.label.data-true' : 'figure.label.data-false') : typeof sampled === 'object' ? JSON.stringify(sampled) : String(sampled)}</output>
408
+ </label>`;
409
+ const fallback = 'default' in node ? node.default : undefined;
410
+ const value = this.valuing[row.path] ?? fallback;
411
+ if (node.kind === 'number') {
412
+ const ranged = node.min !== undefined && node.max !== undefined && node.max > node.min;
413
+ /* An angle with no range of its own slides over one turn; its box takes any angle. */
414
+ const angle = node.unit === 'deg';
415
+ const slide = ranged ? { min: node.min, max: node.max } : angle ? { min: 0, max: 360 } : undefined;
416
+ const scrubFrom = Number(value ?? slide?.min ?? 0);
417
+ return html `<label>
418
+ ${this.scrubName(html `${label} <span drive>${unitWord(node.unit)}</span>`, node.unit ?? '', Number.isFinite(scrubFrom) ? scrubFrom : 0, ranged ? node.min : -Infinity, ranged ? node.max : Infinity, v => this.value(row, String(v)))}
419
+ ${slide
420
+ ? html `${this.renderDial({ unit: node.unit ?? '', ...slide }, Number(value ?? slide.min))}
421
+ <input type="range" min=${slide.min} max=${slide.max} step=${angle ? 1 : Math.max((slide.max - slide.min) / 100, 0.01)} .value=${String(value ?? slide.min)} @input=${(e) => this.value(row, e.target.value)} />
422
+ ${ranged
423
+ ? this.typedBox(label, Number(value ?? slide.min), slide.min, slide.max, typed => this.value(row, String(typed)))
424
+ : this.typedBox(label, Number(value ?? slide.min), -Infinity, Infinity, typed => this.value(row, String(typed)))}`
425
+ : html `<input wide type="number" step="any" aria-label=${label} .value=${value === undefined ? '' : String(value)} @change=${(e) => this.value(row, e.target.value)} />`}
426
+ </label>`;
427
+ }
428
+ /* A yes or no is a check box, not a list of two words to open (user 2026-11-12). Unchecked is false, as the board reads it. */
429
+ if (node.kind === 'boolean')
430
+ return html `<label>
431
+ <span>${label}</span>
432
+ <input type="checkbox" aria-label=${label} .checked=${value === true} @change=${(e) => this.value(row, String(e.target.checked))} />
433
+ </label>`;
434
+ const domain = domainOf(node);
435
+ if (!domain.length)
436
+ return html `<label>
437
+ <span>${label}</span>
438
+ <input aria-label=${label} .value=${value === undefined ? '' : String(value)} @change=${(e) => this.value(row, e.target.value)} />
439
+ </label>`;
440
+ return html `<label>
441
+ <span>${label}</span>
442
+ <select aria-label=${label} @change=${(e) => this.value(row, e.target.value)}>
443
+ ${domain.map(v => html `<option value=${String(v)} ?selected=${v === value}>${typeof v === 'boolean' ? i18next.t(v ? 'figure.label.data-true' : 'figure.label.data-false') : v}</option>`)}
444
+ </select>
445
+ </label>`;
446
+ }
447
+ renderDial(control, value) {
448
+ if (control.unit !== 'deg')
449
+ return html `<span></span>`;
450
+ const dial = dialShape(control.min, control.max, value);
451
+ const span = dial.radius * 2 + 2;
452
+ return html `<svg dial viewBox="0 0 ${span} ${span}" aria-hidden="true">
453
+ <path d=${dial.sector}></path>
454
+ <circle cx=${dial.centre.x} cy=${dial.centre.y} r=${dial.radius}></circle>
455
+ <line x1=${dial.centre.x} y1=${dial.centre.y} x2=${dial.needle.x} y2=${dial.needle.y}></line>
456
+ </svg>`;
457
+ }
458
+ value(row, typed) {
459
+ const value = typedValueOf(row.node, typed);
460
+ const next = { ...this.valuing };
461
+ if (typeof value === 'number' && Number.isNaN(value))
462
+ delete next[row.path];
463
+ else
464
+ next[row.path] = value;
465
+ this.valuing = next;
466
+ this.tell('figureValues', this.valuing);
467
+ }
468
+ move(group, playing) {
469
+ this.moving = { ...this.moving, [group]: playing };
470
+ this.release(playing.clip);
471
+ this.tell('motion', Object.fromEntries(Object.entries(this.moving).map(([id, m]) => [id, { ...m, paused: false }])));
472
+ }
473
+ drive(clip, value) {
474
+ this.driving = { ...this.driving, [clip]: value };
475
+ if (value)
476
+ this.release(clip);
477
+ this.tell('clips', this.driving);
478
+ }
479
+ /*
480
+ A value given here wins over the clips for its control (things-scene's \`parameters\`), so a value left from trying held
481
+ the control still while a clip played (robot dog, 2026-11-03). A clip played lets go of the controls it drives
482
+ (\`parametersForClip\`).
483
+ */
484
+ release(clip) {
485
+ const asset = this.asset;
486
+ if (!asset)
487
+ return;
488
+ const next = parametersForClip(asset, this.giving, clip);
489
+ if (Object.keys(next).length === Object.keys(this.giving).length)
490
+ return;
491
+ this.giving = next;
492
+ this.tell('parameters', this.giving);
493
+ }
494
+ give(id, value) {
495
+ this.giving = { ...this.giving, [id]: value };
496
+ this.tell('parameters', this.giving);
497
+ }
498
+ tell(key, values) {
499
+ this.dispatchEvent(new CustomEvent('motion-tell', { detail: { key, values: { ...values } } }));
500
+ }
501
+ };
502
+ __decorate([
503
+ property({ attribute: false }),
504
+ __metadata("design:type", Object)
505
+ ], FigureMotionControls.prototype, "asset", void 0);
506
+ __decorate([
507
+ property({ attribute: false }),
508
+ __metadata("design:type", Object)
509
+ ], FigureMotionControls.prototype, "sample", void 0);
510
+ __decorate([
511
+ state(),
512
+ __metadata("design:type", Object)
513
+ ], FigureMotionControls.prototype, "driving", void 0);
514
+ __decorate([
515
+ state(),
516
+ __metadata("design:type", Object)
517
+ ], FigureMotionControls.prototype, "giving", void 0);
518
+ __decorate([
519
+ state(),
520
+ __metadata("design:type", Object)
521
+ ], FigureMotionControls.prototype, "moving", void 0);
522
+ __decorate([
523
+ state(),
524
+ __metadata("design:type", Object)
525
+ ], FigureMotionControls.prototype, "valuing", void 0);
526
+ __decorate([
527
+ state(),
528
+ __metadata("design:type", Boolean)
529
+ ], FigureMotionControls.prototype, "jointsFolded", void 0);
530
+ FigureMotionControls = __decorate([
531
+ customElement('figure-motion-controls')
532
+ ], FigureMotionControls);
533
+ export { FigureMotionControls };
534
+ //# sourceMappingURL=figure-motion-controls.js.map
@@ -1,6 +1,8 @@
1
+ export * from './angle-dial.js';
1
2
  export * from './capability-rung.js';
2
3
  export * from './controls.js';
3
4
  export * from './data-connection.js';
5
+ export * from './data-values.js';
4
6
  export * from './data-words.js';
5
7
  export * from './detail-facts.js';
6
8
  export * from './detail-motion.js';
@@ -8,8 +10,11 @@ export * from './figure-data-list.js';
8
10
  export * from './figure-data-report.js';
9
11
  export * from './figure-asset-viewer.js';
10
12
  export * from './figure-facts-list.js';
13
+ export * from './figure-motion-controls.js';
11
14
  export * from './figure-thumb-mark.js';
12
15
  export * from './figure-view.js';
13
16
  export * from './preview-model.js';
17
+ export * from './scrub.js';
14
18
  export * from './side-panel-styles.js';
19
+ export * from './travel-floor.js';
15
20
  export * from './unit-words.js';
@@ -2,9 +2,11 @@
2
2
  * A released figure on a live canvas, shared by figure-ui (the authoring catalogue) and figure-library (a board
3
3
  * server's library). Importers use the files by path (`@things-factory/figure-viewer/dist-client/<file>.js`).
4
4
  */
5
+ export * from './angle-dial.js';
5
6
  export * from './capability-rung.js';
6
7
  export * from './controls.js';
7
8
  export * from './data-connection.js';
9
+ export * from './data-values.js';
8
10
  export * from './data-words.js';
9
11
  export * from './detail-facts.js';
10
12
  export * from './detail-motion.js';
@@ -12,9 +14,12 @@ export * from './figure-data-list.js';
12
14
  export * from './figure-data-report.js';
13
15
  export * from './figure-asset-viewer.js';
14
16
  export * from './figure-facts-list.js';
17
+ export * from './figure-motion-controls.js';
15
18
  export * from './figure-thumb-mark.js';
16
19
  export * from './figure-view.js';
17
20
  export * from './preview-model.js';
21
+ export * from './scrub.js';
18
22
  export * from './side-panel-styles.js';
23
+ export * from './travel-floor.js';
19
24
  export * from './unit-words.js';
20
25
  //# sourceMappingURL=index.js.map