@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.
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 막대 옆에 서는 **각도 눈**. 지금 각이 범위의 어디인지를 한 눈에 보인다.
3
+ *
4
+ * ## 왜 3D 로는 모자랐나
5
+ *
6
+ * 관절이 돌아도 화면이 그대로인 경우가 있다 — 제 축에서 대칭인 부품이 그렇다. 그래서 관절이
7
+ * 모는 부품에 바늘을 달아 미리보기에서 함께 돌게 했는데(`joint-gizmo.ts` 의 `jointNeedles`),
8
+ * **미리보기에서는 그 바늘이 4 × 2 픽셀이다**(잰 값: 부품 100mm · 바늘 60 × 12mm · 여덟 대를
9
+ * 한 화면에 세운 상태). 미리보기는 크기 반응을 보려고 여덟 대를 나란히 놓는 자리라 한 대가
10
+ * 20 픽셀쯤이고, 그 위의 어떤 표시도 몇 픽셀을 넘지 못한다.
11
+ *
12
+ * 각을 읽는 일은 3D 의 배율에서 떼어 놓는다. 눈은 막대 옆 24 픽셀 자리에 서고, 피규어가 아무리
13
+ * 작게 서 있어도 같은 크기로 읽힌다.
14
+ */
15
+ export interface DialShape {
16
+ /** 가동 범위를 채운 부채꼴. SVG path 의 `d`. */
17
+ sector: string;
18
+ /** 지금 값이 가리키는 끝점. */
19
+ needle: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ centre: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ radius: number;
28
+ }
29
+ /**
30
+ * 눈의 모양. 값이 범위를 벗어나면 범위 끝에 세운다 — 밖을 가리키는 바늘은 없는 값을 말한다.
31
+ */
32
+ export declare function dialShape(min: number, max: number, value: number, radius?: number): DialShape;
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ /** 0 도가 위를 가리키고, 값이 커지면 시계 방향으로 돈다 — 화면의 각과 같은 방향이다. */
5
+ function at(centre, radius, degrees) {
6
+ const rad = (degrees * Math.PI) / 180;
7
+ return {
8
+ x: +(centre.x + radius * Math.sin(rad)).toFixed(2),
9
+ y: +(centre.y - radius * Math.cos(rad)).toFixed(2)
10
+ };
11
+ }
12
+ /** 한 바퀴에 가까우면 부채꼴 대신 온전한 원이다. */
13
+ const FULL = 359.9;
14
+ /**
15
+ * 눈의 모양. 값이 범위를 벗어나면 범위 끝에 세운다 — 밖을 가리키는 바늘은 없는 값을 말한다.
16
+ */
17
+ export function dialShape(min, max, value, radius = 9) {
18
+ const centre = { x: radius + 1, y: radius + 1 };
19
+ const span = Math.abs(max - min);
20
+ const held = Math.min(Math.max(value, Math.min(min, max)), Math.max(min, max));
21
+ if (span >= FULL) {
22
+ const top = at(centre, radius, 0);
23
+ const bottom = at(centre, radius, 180);
24
+ return {
25
+ sector: `M ${top.x} ${top.y} A ${radius} ${radius} 0 1 1 ${bottom.x} ${bottom.y} A ${radius} ${radius} 0 1 1 ${top.x} ${top.y} Z`,
26
+ needle: at(centre, radius, held),
27
+ centre,
28
+ radius
29
+ };
30
+ }
31
+ const from = at(centre, radius, min);
32
+ const to = at(centre, radius, max);
33
+ const large = span > 180 ? 1 : 0;
34
+ return {
35
+ sector: `M ${centre.x} ${centre.y} L ${from.x} ${from.y} A ${radius} ${radius} 0 ${large} 1 ${to.x} ${to.y} Z`,
36
+ needle: at(centre, radius, held),
37
+ centre,
38
+ radius
39
+ };
40
+ }
41
+ //# sourceMappingURL=angle-dial.js.map
@@ -0,0 +1,43 @@
1
+ import type { FigureAsset, FigureDataNode, FigureDataRow, FigureDataValue, FigureDataValueIssue } from '@hatiolab/figure-model';
2
+ import { type FigureDataResult, type FigureRuntimeIssue, type FigureTableUse } from '@hatiolab/things-scene';
3
+ export declare const isValue: (n: FigureDataNode) => n is Extract<FigureDataNode, {
4
+ kind: "number" | "boolean" | "text";
5
+ }>;
6
+ /** The values a closed field takes: a closed text's values, both booleans. Empty when open. */
7
+ export declare const domainOf: (node: FigureDataNode) => FigureDataValue[];
8
+ /** The rows of the schema, each with the bindings that read it (figure-model's view). */
9
+ export declare const schemaRowsOf: (asset: FigureAsset) => FigureDataRow[];
10
+ /**
11
+ * What a sample of data would do on this figure, read the one way a placed figure reads it (things-scene's figure
12
+ * inputs): what it moves, or why it is refused, each value's reason; each table's look and where it came from, and what
13
+ * of a legend was left out. `legends`: sample legends by role, as a scene's legend of the role's name would be.
14
+ */
15
+ export declare function sampleOf(asset: FigureAsset, sample: unknown, legends?: Record<string, unknown>): {
16
+ issues: FigureDataValueIssue[];
17
+ result: FigureDataResult;
18
+ uses: Readonly<Record<string, FigureTableUse>>;
19
+ notes: FigureRuntimeIssue[];
20
+ };
21
+ /**
22
+ * The state inputs a sample of data sets on this figure, by id: what the preview shows for them instead of a slider. None
23
+ * when there is no sample, or the figure refuses it.
24
+ */
25
+ export declare function sampledStatesOf(asset: FigureAsset, sample: unknown): Record<string, number>;
26
+ /** The rows a person gives a value by hand, as a board's saved values: one value, read by a binding, not inside a list. */
27
+ export declare const valueRowsOf: (asset: FigureAsset) => FigureDataRow[];
28
+ /**
29
+ * What the data gives a row, read the way a placed figure reads its data: when it is there, it is what the figure shows,
30
+ * and a value saved by hand for the row is not read (things-scene's FigureDataReader: live data first). Undefined when
31
+ * the data leaves the row out, or gives it null.
32
+ */
33
+ export declare function dataValueAt(data: unknown, path: string): unknown;
34
+ /** A value typed or chosen for a row, as its kind reads it: a number (NaN when empty), true or false, or the text. */
35
+ export declare function typedValueOf(node: FigureDataNode, typed: string): FigureDataValue;
36
+ /**
37
+ * Which fields of each motion group the data binds: its clip, its speed. A field bound wins over the group's own setting
38
+ * whenever the data, a saved value or the schema's default gives it a value, so the preview drives it through the data.
39
+ */
40
+ export declare function motionWrittenByData(asset: FigureAsset): Record<string, {
41
+ clip: boolean;
42
+ speed: boolean;
43
+ }>;
@@ -0,0 +1,99 @@
1
+ /*
2
+ * A figure's data as the person gives it by hand in a preview, read the one way a placed figure reads it: the rows that
3
+ * take a value, what a sample sets, and which motion-group fields the data writes. Shared by the modeller's preview and
4
+ * the catalogue's (figure-asset-viewer) through figure-motion-controls; the modeller's data tab reads them too.
5
+ */
6
+ import { figureDataRows, parseFigureAccessor } from '@hatiolab/figure-model';
7
+ import { FigureInputs } from '@hatiolab/things-scene';
8
+ export const isValue = (n) => n.kind === 'number' || n.kind === 'boolean' || n.kind === 'text';
9
+ /** The values a closed field takes: a closed text's values, both booleans. Empty when open. */
10
+ export const domainOf = (node) => (node.kind === 'boolean' ? [false, true] : node.kind === 'text' && node.values ? [...node.values] : []);
11
+ /** The rows of the schema, each with the bindings that read it (figure-model's view). */
12
+ export const schemaRowsOf = (asset) => (asset.dataInterface ? figureDataRows(asset.dataInterface) : []);
13
+ /**
14
+ * What a sample of data would do on this figure, read the one way a placed figure reads it (things-scene's figure
15
+ * inputs): what it moves, or why it is refused, each value's reason; each table's look and where it came from, and what
16
+ * of a legend was left out. `legends`: sample legends by role, as a scene's legend of the role's name would be.
17
+ */
18
+ export function sampleOf(asset, sample, legends = {}) {
19
+ const inputs = new FigureInputs(asset);
20
+ inputs.setThemes({ legends: Object.fromEntries(Object.entries(legends).map(([role, legend]) => [role, { legend, source: 'domain', name: role }])) });
21
+ const taken = inputs.setData(sample);
22
+ return {
23
+ issues: taken.accepted ? [] : (taken.issues[0]?.issues ?? []),
24
+ result: inputs.data,
25
+ uses: inputs.tableUses,
26
+ notes: inputs.diagnostics().filter(i => i.severity === 'note')
27
+ };
28
+ }
29
+ /**
30
+ * The state inputs a sample of data sets on this figure, by id: what the preview shows for them instead of a slider. None
31
+ * when there is no sample, or the figure refuses it.
32
+ */
33
+ export function sampledStatesOf(asset, sample) {
34
+ if (sample === null || sample === undefined || !asset.dataInterface)
35
+ return {};
36
+ try {
37
+ const read = sampleOf(asset, sample);
38
+ return read.issues.length ? {} : Object.fromEntries(Object.entries(read.result.states).map(([id, s]) => [id, s.value]));
39
+ }
40
+ catch {
41
+ return {};
42
+ }
43
+ }
44
+ /** The rows a person gives a value by hand, as a board's saved values: one value, read by a binding, not inside a list. */
45
+ export const valueRowsOf = (asset) => schemaRowsOf(asset).filter(r => isValue(r.node) && r.bindings.length > 0 && !r.path.includes('[]'));
46
+ /**
47
+ * What the data gives a row, read the way a placed figure reads its data: when it is there, it is what the figure shows,
48
+ * and a value saved by hand for the row is not read (things-scene's FigureDataReader: live data first). Undefined when
49
+ * the data leaves the row out, or gives it null.
50
+ */
51
+ export function dataValueAt(data, path) {
52
+ const steps = parseFigureAccessor(path);
53
+ if (!steps)
54
+ return undefined;
55
+ let at = data;
56
+ for (const step of steps) {
57
+ if (at === null || typeof at !== 'object')
58
+ return undefined;
59
+ at = 'field' in step ? at[step.field] : at[step.index];
60
+ }
61
+ return at === null ? undefined : at;
62
+ }
63
+ /** A value typed or chosen for a row, as its kind reads it: a number (NaN when empty), true or false, or the text. */
64
+ export function typedValueOf(node, typed) {
65
+ if (node.kind === 'number')
66
+ return typed.trim() === '' ? Number.NaN : Number(typed);
67
+ if (node.kind === 'boolean')
68
+ return typed === 'true';
69
+ return typed;
70
+ }
71
+ /**
72
+ * Which fields of each motion group the data binds: its clip, its speed. A field bound wins over the group's own setting
73
+ * whenever the data, a saved value or the schema's default gives it a value, so the preview drives it through the data.
74
+ */
75
+ export function motionWrittenByData(asset) {
76
+ const out = {};
77
+ for (const b of asset.dataInterface?.bindings ?? []) {
78
+ if (b.rule === 'table') {
79
+ if (!b.targets.group)
80
+ continue;
81
+ const one = (out[b.targets.group] ??= { clip: false, speed: false });
82
+ const looks = Object.values(b.table);
83
+ if (looks.some(l => l.clip !== undefined))
84
+ one.clip = true;
85
+ if (looks.some(l => l.speed !== undefined))
86
+ one.speed = true;
87
+ continue;
88
+ }
89
+ if (b.behavior.kind !== 'motion-clip' && b.behavior.kind !== 'motion-speed')
90
+ continue;
91
+ const one = (out[b.behavior.group] ??= { clip: false, speed: false });
92
+ if (b.behavior.kind === 'motion-clip')
93
+ one.clip = true;
94
+ else
95
+ one.speed = true;
96
+ }
97
+ return out;
98
+ }
99
+ //# sourceMappingURL=data-values.js.map
@@ -1,49 +1,16 @@
1
- import { type FigureAsset, type FigureDataValue } from '@hatiolab/figure-model';
1
+ import type { FigureAsset } from '@hatiolab/figure-model';
2
2
  /** External values win over drivers; release only the controls owned by the chosen clip. */
3
3
  export declare function parametersForClip(asset: FigureAsset, values: Record<string, number>, clip: string): {
4
4
  [k: string]: number;
5
5
  };
6
- /** The clips that move an input. A clip can move many inputs, so it plays on its own row, never on an input's. */
7
- export declare function clipsDriving(asset: FigureAsset, id: string): string[];
8
6
  /**
9
- * How the detail view plays a clip (ADR-0051 §3.2, §8). A clip in no motion group plays at its own speed (the board's
10
- * `clips`). A clip of a group is the group's selection (the board's `motion`); and when the figure's data chooses that
11
- * group's clip, the data wins -- its default too -- so the clip is chosen through a data value the figure's own binding
12
- * turns into it, given as a saved value (`figureValues`), the way a board would: the value itself, or the code of a
13
- * table whose look names the clip (ADR-0166). A clip no data value turns into (an interval, a scale, or only another
14
- * value's fallback of an open field) cannot be chosen here.
7
+ * The controls a playing clip drives in the preview, each with that clip: a clip in no group played at a speed above 0,
8
+ * or the clip a motion group plays at a speed above 0 (its default until one is chosen).
15
9
  */
16
- export type ClipPlay = {
17
- kind: 'free';
18
- } | {
19
- kind: 'group';
20
- group: string;
21
- } | {
22
- kind: 'data';
23
- group: string;
24
- accessor: string;
25
- value: FigureDataValue;
26
- } | {
27
- kind: 'unreachable';
28
- group: string;
29
- };
30
- export declare function clipPlayOf(asset: FigureAsset, clip: string): ClipPlay;
31
- /**
32
- * What the board is told for the clip playing (none: ''): the free clips' speeds, the group's selection, and the saved
33
- * data value that chooses it. Every key is written whole, so the clip played before is let go.
34
- */
35
- export declare function playSettingsOf(asset: FigureAsset, playing: string): {
36
- clips: {
37
- [k: string]: number;
38
- };
39
- motion: {
40
- [x: string]: {
41
- clip: string;
42
- speed: number;
43
- paused: boolean;
44
- };
45
- };
46
- figureValues: {
47
- [x: string]: FigureDataValue;
48
- };
49
- };
10
+ export declare function playedControlsOf(asset: FigureAsset, driving: Record<string, number>, moving: Record<string, {
11
+ clip: string;
12
+ speed: number;
13
+ }>): Map<string, string>;
14
+ /** Whether the preview's joint rows are folded: as the person left them, else folded from ten joints on. */
15
+ export declare const JOINTS_FOLDED_FROM = 10;
16
+ export declare function jointsFoldedOf(chosen: boolean | undefined, joints: number): boolean;
@@ -1,47 +1,28 @@
1
- import { compileFigureDataInterface } from '@hatiolab/figure-model';
2
1
  /** External values win over drivers; release only the controls owned by the chosen clip. */
3
2
  export function parametersForClip(asset, values, clip) {
4
3
  const driven = new Set((asset.drivers ?? []).filter(d => d.clip === clip).map(d => d.state));
5
4
  return Object.fromEntries(Object.entries(values).filter(([id]) => !driven.has(id)));
6
5
  }
7
- /** The clips that move an input. A clip can move many inputs, so it plays on its own row, never on an input's. */
8
- export function clipsDriving(asset, id) {
9
- return [...new Set((asset.drivers ?? []).filter(d => d.state === id).map(d => d.clip))];
10
- }
11
- export function clipPlayOf(asset, clip) {
12
- const group = (asset.motionGroups ?? []).find(g => g.clips.includes(clip));
13
- if (!group)
14
- return { kind: 'free' };
15
- const plan = asset.dataInterface ? compileFigureDataInterface(asset) : null;
16
- const ready = plan?.bindings.find(({ binding: b }) => b.rule === 'table' ? b.targets.group === group.id && Object.values(b.table).some(look => look.clip !== undefined) : b.behavior.kind === 'motion-clip' && b.behavior.group === group.id);
17
- if (!ready)
18
- return { kind: 'group', group: group.id };
19
- const { binding, node } = ready;
20
- const reached = (value) => ({ kind: 'data', group: group.id, accessor: binding.accessor, value });
21
- const unreachable = { kind: 'unreachable', group: group.id };
22
- const closed = node.kind === 'boolean' ? ['false', 'true'] : node.kind === 'text' && node.values ? node.values : null;
23
- const typed = (key) => (node.kind === 'boolean' ? key === 'true' : node.kind === 'number' ? Number(key) : key);
24
- if (binding.rule === 'value')
25
- return node.kind === 'text' && (!closed || closed.includes(clip)) ? reached(clip) : unreachable;
26
- if (binding.rule !== 'table' || binding.lookup !== 'code')
27
- return unreachable;
28
- const table = binding.table;
29
- const key = Object.keys(table).find(k => k !== 'default' && table[k].clip === clip);
30
- if (key !== undefined)
31
- return reached(typed(key));
32
- /* Only the default turns into it: a value of a closed field the table does not name. */
33
- const spare = table.default?.clip === clip ? closed?.find(v => !Object.hasOwn(table, v)) : undefined;
34
- return spare !== undefined ? reached(typed(spare)) : unreachable;
35
- }
36
6
  /**
37
- * What the board is told for the clip playing (none: ''): the free clips' speeds, the group's selection, and the saved
38
- * data value that chooses it. Every key is written whole, so the clip played before is let go.
7
+ * The controls a playing clip drives in the preview, each with that clip: a clip in no group played at a speed above 0,
8
+ * or the clip a motion group plays at a speed above 0 (its default until one is chosen).
39
9
  */
40
- export function playSettingsOf(asset, playing) {
41
- const play = playing ? clipPlayOf(asset, playing) : null;
42
- const clips = Object.fromEntries([...new Set((asset.drivers ?? []).filter(d => !(asset.motionGroups ?? []).some(g => g.clips.includes(d.clip))).map(d => d.clip))].map(c => [c, c === playing ? 1 : 0]));
43
- const motion = play && play.kind !== 'free' && play.kind !== 'unreachable' ? { [play.group]: { clip: playing, speed: 1, paused: false } } : {};
44
- const figureValues = play?.kind === 'data' ? { [play.accessor]: play.value } : {};
45
- return { clips, motion, figureValues };
10
+ export function playedControlsOf(asset, driving, moving) {
11
+ const playing = new Set(Object.entries(driving).filter(([, speed]) => speed > 0).map(([clip]) => clip));
12
+ for (const group of asset.motionGroups ?? []) {
13
+ const m = moving[group.id];
14
+ if (m && m.speed > 0)
15
+ playing.add(m.clip || group.defaultClip);
16
+ }
17
+ const played = new Map();
18
+ for (const d of asset.drivers ?? [])
19
+ if (playing.has(d.clip) && !played.has(d.state))
20
+ played.set(d.state, d.clip);
21
+ return played;
22
+ }
23
+ /** Whether the preview's joint rows are folded: as the person left them, else folded from ten joints on. */
24
+ export const JOINTS_FOLDED_FROM = 10;
25
+ export function jointsFoldedOf(chosen, joints) {
26
+ return chosen ?? joints >= JOINTS_FOLDED_FROM;
46
27
  }
47
28
  //# sourceMappingURL=detail-motion.js.map
@@ -1,6 +1,7 @@
1
1
  import '@material/web/icon/icon.js';
2
2
  import { LitElement, type PropertyValues } from 'lit';
3
3
  import { type FigureAsset } from '@hatiolab/figure-model';
4
+ import './figure-motion-controls.js';
4
5
  /** What the view's tabs show under it: the figure's facts, its size, its motion, the data it takes. */
5
6
  export type FigureViewerTab = 'info' | 'size' | 'motion' | 'data';
6
7
  export declare const FIGURE_VIEWER_TABS: readonly FigureViewerTab[];
@@ -22,17 +23,17 @@ export declare class FigureAssetViewer extends FigureAssetViewer_base {
22
23
  /** The tab shown under the view. */
23
24
  tab: FigureViewerTab;
24
25
  private stage;
26
+ private motionControls?;
25
27
  private shot;
26
28
  private sizes;
27
- private values;
28
- private playing;
29
29
  private error;
30
30
  private copied;
31
31
  private scene?;
32
32
  private registered?;
33
33
  private observer?;
34
34
  private needsScene;
35
- private played;
35
+ /** Stops the floor following the figure's travel (travel-floor). */
36
+ private stopTravel?;
36
37
  /** The board component's properties, read from the instance standing here as the board's panel reads them. */
37
38
  private exposed;
38
39
  /** The board the instance stands on, set when the scene is built; its centre is the grid's origin. */
@@ -51,8 +52,6 @@ export declare class FigureAssetViewer extends FigureAssetViewer_base {
51
52
  private boardName;
52
53
  private renderDesign;
53
54
  private renderMotion;
54
- /** A clip on its own row, played by the mark at its end. */
55
- private clipRow;
56
55
  private renderData;
57
56
  private copyExample;
58
57
  /**
@@ -62,8 +61,6 @@ export declare class FigureAssetViewer extends FigureAssetViewer_base {
62
61
  private takeShot;
63
62
  /** The whole figure in view: the board's fit, then the 3D camera's own (as the modeller canvas fits). */
64
63
  fit(): void;
65
- /** Play or pause a clip, at the end of the line it moves. */
66
- private playButton;
67
64
  private tell;
68
65
  private resize;
69
66
  /**
@@ -71,8 +68,6 @@ export declare class FigureAssetViewer extends FigureAssetViewer_base {
71
68
  * which can be wider than the size asked, so the box is read back rather than computed here.
72
69
  */
73
70
  private centre;
74
- private pose;
75
- private play;
76
71
  private reset;
77
72
  private standUp;
78
73
  private teardown;
@@ -8,10 +8,10 @@ import { SurfaceStyles } from '@things-factory/styles';
8
8
  import { compileFigureAsset, figureDataExample } from '@hatiolab/figure-model';
9
9
  import { create, registerFigure, unregisterFigure } from '@hatiolab/things-scene';
10
10
  import { authoredSizeOf, bodyAtSize, previewOneInstance, sizeSpanOf, sizeWithinRange } from './preview-model.js';
11
- import { controlsOf } from './controls.js';
12
11
  import { DEFAULT_VIEW, previewBoardDepth, sceneLook } from './figure-view.js';
13
12
  import { SidePanelStyles } from './side-panel-styles.js';
14
- import { clipPlayOf, clipsDriving, parametersForClip, playSettingsOf } from './detail-motion.js';
13
+ import './figure-motion-controls.js';
14
+ import { followTravelFloor, PREVIEW_CLIP_TRAVEL } from './travel-floor.js';
15
15
  import { dataConnectionsOf, ITEM_FIELDS } from './data-connection.js';
16
16
  import { itemFieldWords, kindWords, methodWords, moveWords } from './data-words.js';
17
17
  export const FIGURE_VIEWER_TABS = ['info', 'size', 'motion', 'data'];
@@ -20,6 +20,7 @@ export const FIGURE_VIEWER_TABS = ['info', 'size', 'motion', 'data'];
20
20
  data's are the data tab's own, from the connections.
21
21
  */
22
22
  const DESIGN_KEYS = ['designInputs', 'slotLayout'];
23
+ const MOTION_KEYS = ['figureValues', 'motion', 'clips', 'parameters'];
23
24
  /**
24
25
  * A single board instance. Sizes and poses are transient, and never change the asset or call a mutation.
25
26
  *
@@ -36,12 +37,9 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
36
37
  this.tab = 'info';
37
38
  this.shot = '';
38
39
  this.sizes = { x: 1, y: 1, z: 1 };
39
- this.values = {};
40
- this.playing = '';
41
40
  this.error = '';
42
41
  this.copied = false;
43
42
  this.needsScene = false;
44
- this.played = new Set();
45
43
  /** The board component's properties, read from the instance standing here as the board's panel reads them. */
46
44
  this.exposed = [];
47
45
  /** The board the instance stands on, set when the scene is built; its centre is the grid's origin. */
@@ -89,7 +87,6 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
89
87
  */
90
88
  div[slide] { display: grid; grid-template-columns: 120px minmax(64px, 1fr) 52px 22px; align-items: center; gap: 8px; min-height: 22px; }
91
89
  div[slide] > span { color: var(--md-sys-color-on-surface-variant); overflow-wrap: anywhere; line-height: 1.3; }
92
- div[slide][clip] > span { grid-column: 1 / 4; }
93
90
  div[slide] input[type='number'] { min-height: 0; height: 20px; padding: 0 2px; border: none; border-bottom: 1px solid transparent; border-radius: 0;
94
91
  background: none; text-align: right; font-family: var(--ui-mono, ui-monospace, monospace); -moz-appearance: textfield; }
95
92
  div[slide] input[type='number']::-webkit-inner-spin-button, div[slide] input[type='number']::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
@@ -101,8 +98,12 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
101
98
  background: transparent; color: var(--md-sys-color-on-surface-variant); cursor: pointer; }
102
99
  button[icon]:hover { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }
103
100
  button[icon] md-icon { --md-icon-size: 16px; }
104
- button[icon][aria-pressed='true'] { color: var(--md-sys-color-primary); }
105
101
  p[hint] { margin: 0; }
102
+ section[hidden] { display: none; }
103
+ /* The board's keys for what moves the figure, on one line over its controls. */
104
+ div[keys] { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-bottom: 6px; font-weight: 600; }
105
+ /* The shared motion controls in the panel's colour, their slider as wide as the panel lets it. */
106
+ figure-motion-controls { --figure-motion-slider: minmax(64px, 1fr); color: var(--md-sys-color-on-surface); }
106
107
  /* A connection: its field, what it moves and how on one line; under it, where the data has it and of what kind. */
107
108
  div[connection] { display: grid; gap: 1px; padding: 3px 0; }
108
109
  div[connection] [method] { color: var(--md-sys-color-on-surface-variant); margin-left: 6px; }
@@ -136,8 +137,6 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
136
137
  }
137
138
  render() {
138
139
  const asset = this.asset;
139
- const clips = asset ? [...new Set((asset.drivers ?? []).map(d => d.clip))] : [];
140
- const controls = asset ? controlsOf(asset, this.values) : [];
141
140
  const shotLabel = this.shot === 'saved' ? i18next.t('figure.text.detail-thumbnail-saved') : i18next.t('figure.button.detail-save-thumbnail');
142
141
  const fitLabel = i18next.t('button.fit-view');
143
142
  return html `<div viewport><div stage></div>
@@ -157,8 +156,8 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
157
156
  <div tab-body role="tabpanel" aria-labelledby=${`tab-${this.tab}`}>
158
157
  ${this.tab === 'info' ? html `<slot name="facts"></slot>` : nothing}
159
158
  ${asset && this.tab === 'size' ? this.renderSize(asset) : nothing}
160
- ${asset && this.tab === 'motion' ? this.renderMotion(asset, controls, clips) : nothing}
161
159
  ${asset && this.tab === 'data' ? this.renderData(asset) : nothing}
160
+ ${asset ? this.renderMotion(asset) : nothing}
162
161
  </div>`;
163
162
  }
164
163
  /** The tab strip: the facts, the size, the motion, the data. Arrow keys move along it, as the suite's tabs do. */
@@ -226,43 +225,17 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
226
225
  </section>`;
227
226
  }
228
227
  /*
229
- The inputs, then the clips. A clip can move many inputs -- the robot dog's walk moves all eight leg joints -- so it
230
- plays on its own row (user 2026-10-15: a play mark on fl-thigh played the walk and every leg moved). An input the
231
- clip playing moves cannot be dragged; one a clip played and let go of stands where the clip left it, so its number
232
- is not shown until it is dragged.
228
+ How the figure moves, the same controls as the modeller's preview (figure-motion-controls): the data's states, then
229
+ the clips, then the joints (the user, 2026-11-21: 「상태, 애니메이션과 관절 순서를 모델러의 미리보기와 같이」). Over them,
230
+ the board's word and key for each that a board sets and binds (user 2026-11-05).
233
231
  */
234
- renderMotion(asset, controls, clips) {
235
- /* Each part under the board's word for it and the key a board sets and binds (user 2026-11-05). */
236
- const heading = (name) => {
237
- const p = this.exposed.find(x => x.name === name);
238
- return p ? html `<h3>${this.boardName(p)}</h3>` : nothing;
239
- };
240
- const groups = asset.motionGroups ?? [];
241
- const free = clips.filter(clip => !groups.some(g => g.clips.includes(clip)));
242
- return html `<section>
243
- ${controls.length ? heading('parameters') : nothing}
244
- ${controls.map(c => {
245
- const driving = clipsDriving(asset, c.id);
246
- const moving = driving.includes(this.playing);
247
- const held = moving || (driving.some(clip => this.played.has(clip)) && !(c.id in this.values));
248
- return html `<div slide><span title=${`${c.label} · ${c.unit}`}>${c.label} · ${c.unit}</span>
249
- <input type="range" aria-label=${c.label} min=${c.min} max=${c.max} step=${c.step || 'any'} .value=${String(c.value)} ?disabled=${moving}
250
- @input=${(e) => this.pose(c.id, e.target.valueAsNumber)}>
251
- <output>${held ? '' : Math.round(c.value * 100) / 100}</output><span></span></div>`;
252
- })}
253
- ${!controls.length && !clips.length ? html `<p hint>${i18next.t('figure.text.detail-no-motion')}</p>` : nothing}
254
- </section>
255
- ${free.length ? html `<section>${heading('clips')}${free.map(name => this.clipRow(name))}</section>` : nothing}
256
- ${groups.some(g => g.clips.some(c => clips.includes(c)))
257
- ? html `<section>
258
- ${heading('motion')}
259
- ${groups.map(g => html `<h4>${g.label}</h4>${g.clips.filter(c => clips.includes(c)).map(name => this.clipRow(name))}`)}
260
- </section>`
261
- : nothing}`;
262
- }
263
- /** A clip on its own row, played by the mark at its end. */
264
- clipRow(name) {
265
- return html `<div slide clip><span title=${name}>${name}</span>${this.playButton(name)}</div>`;
232
+ renderMotion(asset) {
233
+ const keys = MOTION_KEYS.flatMap(key => this.exposed.filter(p => p.name === key));
234
+ /* Kept standing on the other tabs, hidden: what plays goes on playing, and the controls still say what it is. */
235
+ return html `<section motion ?hidden=${this.tab !== 'motion'}>
236
+ ${keys.length ? html `<div keys>${keys.map(p => html `<span>${this.boardName(p)}</span>`)}</div>` : nothing}
237
+ <figure-motion-controls .asset=${asset} @motion-tell=${(e) => this.tell(e.detail.key, e.detail.values)}></figure-motion-controls>
238
+ </section>`;
266
239
  }
267
240
  /*
268
241
  The connections the author declared (the modeller's 「연결」): for each, the data field, what it moves and how, then
@@ -331,15 +304,6 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
331
304
  this.scene?.fit?.('ratio');
332
305
  this.scene?.root?.fitCameraToModel?.();
333
306
  }
334
- /** Play or pause a clip, at the end of the line it moves. */
335
- playButton(clip) {
336
- const on = this.playing === clip;
337
- /* A clip the figure's data never turns into cannot be chosen here; it says so instead of pressing to no effect. */
338
- const unreachable = !!this.asset && clipPlayOf(this.asset, clip).kind === 'unreachable';
339
- const title = unreachable ? i18next.t('figure.text.detail-clip-by-data', { clip }) : clip;
340
- return html `<button icon play aria-pressed=${String(on)} aria-label=${clip} title=${title} ?disabled=${unreachable} @click=${() => this.play(clip)}>
341
- <md-icon>${on ? 'pause' : 'play_arrow'}</md-icon></button>`;
342
- }
343
307
  tell(key, value) {
344
308
  this.scene?.root?.components?.[0]?.set(key, value);
345
309
  }
@@ -371,27 +335,6 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
371
335
  const { width = 0, height = 0 } = instance.model;
372
336
  instance.set({ left: this.board.x / 2 - width / 2, top: this.board.z / 2 - height / 2 });
373
337
  }
374
- pose(id, value) {
375
- if (!Number.isFinite(value))
376
- return;
377
- this.values = { ...this.values, [id]: value };
378
- this.tell('parameters', this.values);
379
- }
380
- play(name) {
381
- this.playing = this.playing === name ? '' : name;
382
- if (this.playing && this.asset) {
383
- this.played.add(name);
384
- this.values = parametersForClip(this.asset, this.values, name);
385
- this.tell('parameters', this.values);
386
- }
387
- if (!this.asset)
388
- return;
389
- /* A clip of a motion group is the group's to choose -- through the data when the data chooses it (detail-motion). */
390
- const { clips, motion, figureValues } = playSettingsOf(this.asset, this.playing);
391
- this.tell('clips', clips);
392
- this.tell('motion', motion);
393
- this.tell('figureValues', figureValues);
394
- }
395
338
  reset() {
396
339
  if (!this.asset)
397
340
  return;
@@ -404,11 +347,9 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
404
347
  const asset = this.asset;
405
348
  if (!asset)
406
349
  return;
407
- this.values = {};
350
+ this.motionControls?.reset();
408
351
  this.exposed = [];
409
- this.playing = '';
410
352
  this.shot = '';
411
- this.played.clear();
412
353
  try {
413
354
  compileFigureAsset(asset);
414
355
  if (!asset.appearance.length)
@@ -418,7 +359,9 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
418
359
  registerFigure(type, asset);
419
360
  this.registered = type;
420
361
  const size = bodyAtSize(asset, this.sizes) ?? this.sizes;
421
- const { board, components } = previewOneInstance(type, size);
362
+ const { board, components: placed } = previewOneInstance(type, size);
363
+ /* A run that travels stays in view, its floor flowing under it, as in the modeller's preview (travel-floor). */
364
+ const components = placed.map(c => ({ ...c, clipTravel: PREVIEW_CLIP_TRAVEL }));
422
365
  this.board = { x: board.width, z: board.height };
423
366
  this.scene = create({ target: this.stage, mode: 0, model: {
424
367
  type: 'model-layer', width: board.width, height: board.height,
@@ -432,6 +375,7 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
432
375
  this.scene.resize?.();
433
376
  this.fit();
434
377
  this.exposed = this.scene.root?.components?.[0]?.nature?.properties ?? [];
378
+ this.stopTravel = followTravelFloor(() => this.scene?.root);
435
379
  }
436
380
  catch (error) {
437
381
  this.error = error.message;
@@ -439,6 +383,8 @@ let FigureAssetViewer = class FigureAssetViewer extends localize(i18next)(LitEle
439
383
  }
440
384
  }
441
385
  teardown() {
386
+ this.stopTravel?.();
387
+ this.stopTravel = undefined;
442
388
  this.scene?.dispose?.();
443
389
  this.scene = undefined;
444
390
  if (this.registered)
@@ -462,6 +408,10 @@ __decorate([
462
408
  query('[stage]'),
463
409
  __metadata("design:type", HTMLElement)
464
410
  ], FigureAssetViewer.prototype, "stage", void 0);
411
+ __decorate([
412
+ query('figure-motion-controls'),
413
+ __metadata("design:type", Function)
414
+ ], FigureAssetViewer.prototype, "motionControls", void 0);
465
415
  __decorate([
466
416
  state(),
467
417
  __metadata("design:type", String)
@@ -470,14 +420,6 @@ __decorate([
470
420
  state(),
471
421
  __metadata("design:type", Object)
472
422
  ], FigureAssetViewer.prototype, "sizes", void 0);
473
- __decorate([
474
- state(),
475
- __metadata("design:type", Object)
476
- ], FigureAssetViewer.prototype, "values", void 0);
477
- __decorate([
478
- state(),
479
- __metadata("design:type", Object)
480
- ], FigureAssetViewer.prototype, "playing", void 0);
481
423
  __decorate([
482
424
  state(),
483
425
  __metadata("design:type", Object)
@@ -13,7 +13,7 @@ export declare class FigureDataList extends FigureDataList_base {
13
13
  static styles: import("lit").CSSResult[];
14
14
  report?: FigureDataReport;
15
15
  private copied;
16
- render(): import("lit-html").TemplateResult<1> | typeof nothing;
16
+ render(): typeof nothing | import("lit-html").TemplateResult<1>;
17
17
  private renderRow;
18
18
  private copy;
19
19
  }