@things-factory/figure-viewer 10.1.291 → 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.
- package/dist-client/angle-dial.d.ts +32 -0
- package/dist-client/angle-dial.js +41 -0
- package/dist-client/controls.d.ts +16 -2
- package/dist-client/controls.js +18 -5
- package/dist-client/data-values.d.ts +43 -0
- package/dist-client/data-values.js +99 -0
- package/dist-client/detail-motion.d.ts +10 -43
- package/dist-client/detail-motion.js +19 -38
- package/dist-client/figure-asset-viewer.d.ts +4 -9
- package/dist-client/figure-asset-viewer.js +30 -88
- package/dist-client/figure-motion-controls.d.ts +80 -0
- package/dist-client/figure-motion-controls.js +534 -0
- package/dist-client/index.d.ts +5 -0
- package/dist-client/index.js +5 -0
- package/dist-client/scrub.d.ts +22 -0
- package/dist-client/scrub.js +51 -0
- package/dist-client/travel-floor.d.ts +9 -0
- package/dist-client/travel-floor.js +32 -0
- package/package.json +2 -2
- package/translations/en.json +11 -2
- package/translations/es.json +11 -2
- package/translations/ja.json +11 -2
- package/translations/ko.json +12 -3
- package/translations/ms.json +11 -2
- package/translations/zh.json +11 -2
|
@@ -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
|
|
@@ -15,11 +15,25 @@ export interface Control {
|
|
|
15
15
|
sweep: number;
|
|
16
16
|
/** A slider step: one degree for an angle, else a hundredth of the range. */
|
|
17
17
|
step: number;
|
|
18
|
+
/**
|
|
19
|
+
* The hold whose starting pose solves this control (ADR-0217), when one does: its start is worked out from the others,
|
|
20
|
+
* never written by hand, so keeping a pose leaves it out and the hold solves it again for the pose kept.
|
|
21
|
+
*/
|
|
22
|
+
heldBy?: string;
|
|
18
23
|
}
|
|
24
|
+
/** The controls a starting-pose hold solves, each with the hold that solves it. */
|
|
25
|
+
export declare function heldAtStartOf(asset: FigureAsset): Map<string, string>;
|
|
19
26
|
export declare function controlsOf(asset: FigureAsset, values?: Record<string, number>): Control[];
|
|
20
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Whether the pose being looked at differs from the default pose -- only then is there a pose to keep. A control a hold
|
|
29
|
+
* solves is not the person's to keep.
|
|
30
|
+
*/
|
|
21
31
|
export declare const poseDiffers: (controls: readonly Control[]) => boolean;
|
|
22
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The current pose as the defaults: one `set-state-defaults` edit. The controls a starting-pose hold solves are left
|
|
34
|
+
* out: the kernel refuses them (HOLD_OWNED), and solves them again for the pose kept (2026-11-21: on a figure with such
|
|
35
|
+
* a hold no pose could be kept).
|
|
36
|
+
*/
|
|
23
37
|
export declare const poseAsDefault: (controls: readonly Control[]) => {
|
|
24
38
|
kind: "set-state-defaults";
|
|
25
39
|
values: {
|
package/dist-client/controls.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
/** The controls a starting-pose hold solves, each with the hold that solves it. */
|
|
2
|
+
export function heldAtStartOf(asset) {
|
|
3
|
+
return new Map((asset.holds ?? []).filter(h => h.clip === undefined).flatMap(h => h.by.map(state => [state, h.id])));
|
|
4
|
+
}
|
|
1
5
|
export function controlsOf(asset, values = {}) {
|
|
6
|
+
const held = heldAtStartOf(asset);
|
|
2
7
|
return asset.document.model.inputs
|
|
3
8
|
.filter(input => input.role === 'state')
|
|
4
9
|
.map(input => {
|
|
@@ -14,15 +19,23 @@ export function controlsOf(asset, values = {}) {
|
|
|
14
19
|
value: values[input.id] ?? start,
|
|
15
20
|
start,
|
|
16
21
|
sweep: policy?.sweep ?? 0,
|
|
17
|
-
step: input.unit === 'deg' ? 1 : (input.max - input.min) / 100
|
|
22
|
+
step: input.unit === 'deg' ? 1 : (input.max - input.min) / 100,
|
|
23
|
+
...(held.has(input.id) ? { heldBy: held.get(input.id) } : {})
|
|
18
24
|
};
|
|
19
25
|
});
|
|
20
26
|
}
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Whether the pose being looked at differs from the default pose -- only then is there a pose to keep. A control a hold
|
|
29
|
+
* solves is not the person's to keep.
|
|
30
|
+
*/
|
|
31
|
+
export const poseDiffers = (controls) => controls.some(c => !c.heldBy && c.value !== c.start);
|
|
32
|
+
/**
|
|
33
|
+
* The current pose as the defaults: one `set-state-defaults` edit. The controls a starting-pose hold solves are left
|
|
34
|
+
* out: the kernel refuses them (HOLD_OWNED), and solves them again for the pose kept (2026-11-21: on a figure with such
|
|
35
|
+
* a hold no pose could be kept).
|
|
36
|
+
*/
|
|
24
37
|
export const poseAsDefault = (controls) => ({
|
|
25
38
|
kind: 'set-state-defaults',
|
|
26
|
-
values: Object.fromEntries(controls.map(c => [c.id, c.value]))
|
|
39
|
+
values: Object.fromEntries(controls.filter(c => !c.heldBy).map(c => [c.id, c.value]))
|
|
27
40
|
});
|
|
28
41
|
//# sourceMappingURL=controls.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 {
|
|
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
|
-
*
|
|
10
|
-
*
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
*
|
|
38
|
-
*
|
|
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
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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;
|