@things-factory/figure-viewer 10.1.163 → 10.1.164

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/figure-viewer",
3
- "version": "10.1.163",
3
+ "version": "10.1.164",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -31,7 +31,8 @@
31
31
  "@hatiolab/things-scene": "^10.1.86",
32
32
  "@material/web": "^2.0.0",
33
33
  "@operato/i18n": "^10.0.0",
34
+ "@things-factory/styles": "^10.1.123",
34
35
  "lit": "^3.1.2"
35
36
  },
36
- "gitHead": "fe2a9c39294d64cd50e52b283105390bb0fa6cee"
37
+ "gitHead": "812391f1ef292805b9f1d3049bcb1bfc0b371d38"
37
38
  }
@@ -1,5 +1,7 @@
1
1
  import { test } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
+ import { readFileSync } from 'node:fs'
4
+ import { fileURLToPath } from 'node:url'
3
5
  import { addFigureBox, createFigureAsset, editFigurePart, serializeFigureAsset } from '@hatiolab/figure-model'
4
6
  import { moving } from './joints.ts'
5
7
  import { clipForControl, parametersForClip } from '../client/detail-motion.ts'
@@ -24,3 +26,65 @@ test('playing a clip releases manual values that would mask its drivers, retaini
24
26
  test('choosing a different clip cannot clear another clip’s manual control', () => {
25
27
  assert.deepEqual(parametersForClip(machine(), { shift: 75 }, 'other'), { shift: 75 })
26
28
  })
29
+
30
+ /*
31
+ * A clip of a motion group (ADR-0051 §3.2) is not played by its speed: the board plays a group's selected clip, and when
32
+ * the figure's data chooses that clip, the data -- its default too -- wins over the selection. The robot dog's walk and
33
+ * run, pressed in the dock, stood still on idle (2026-10-15). Read here by things-scene's own figure inputs.
34
+ */
35
+ import { applyFigureProposal, robotDogFigure } from '@hatiolab/figure-model'
36
+ import { FigureInputs } from '@hatiolab/things-scene'
37
+ import { clipPlayOf, playSettingsOf } from '../client/detail-motion.ts'
38
+
39
+ const DOG = robotDogFigure().asset
40
+ const played = (asset: typeof DOG, settings: { motion?: unknown; figureValues?: unknown }) => {
41
+ const inputs = new FigureInputs(asset)
42
+ const taken = inputs.setManual(settings)
43
+ assert.ok(taken.accepted, JSON.stringify(taken.issues))
44
+ return inputs.motion
45
+ }
46
+
47
+ test('a group clip the data chooses plays through the data value that turns into it', () => {
48
+ assert.deepEqual(clipPlayOf(DOG, 'run'), { kind: 'data', group: 'locomotion', accessor: 'mode', value: 'run' })
49
+ const settings = playSettingsOf(DOG, 'run')
50
+ assert.deepEqual(settings, { clips: {}, motion: { locomotion: { clip: 'run', speed: 1, paused: false } }, figureValues: { mode: 'run' } })
51
+ const motion = played(DOG, settings)
52
+ assert.deepEqual([motion.locomotion!.clip, motion.locomotion!.speed, motion.locomotion!.paused], ['run', 1, false])
53
+ /* The group's selection alone is not enough: the data's default, idle, wins -- what the dock did before. */
54
+ assert.equal(played(DOG, { motion: settings.motion }).locomotion!.clip, 'idle')
55
+ /* Nothing playing: every key let go, back to the default clip. */
56
+ assert.deepEqual(playSettingsOf(DOG, ''), { clips: {}, motion: {}, figureValues: {} })
57
+ assert.equal(played(DOG, playSettingsOf(DOG, '')).locomotion!.clip, 'idle')
58
+ })
59
+
60
+ test('a map chooses by the value that turns into the clip, a fallback by a closed value it does not name; else the clip cannot be chosen', () => {
61
+ /* A closed field of its own, then the clip bound to it by a map in place of mode's. */
62
+ const mapped = applyFigureProposal(DOG, [
63
+ { kind: 'set-data-schema', schema: [...DOG.dataInterface!.schema, { name: 'gait', kind: 'text', values: ['STOP', 'GO', 'HURRY'], default: 'STOP' }] },
64
+ { kind: 'remove-data-binding', id: 'mode-locomotion' },
65
+ { kind: 'set-data-binding', binding: { id: 'gait-locomotion', accessor: 'gait', behavior: { kind: 'motion-clip', group: 'locomotion' }, rule: 'map', param: { GO: 'walk', HURRY: 'walk', default: 'idle' } } }
66
+ ])
67
+ assert.deepEqual(clipPlayOf(mapped, 'walk'), { kind: 'data', group: 'locomotion', accessor: 'gait', value: 'GO' })
68
+ assert.deepEqual(clipPlayOf(mapped, 'idle'), { kind: 'data', group: 'locomotion', accessor: 'gait', value: 'STOP' })
69
+ assert.deepEqual(clipPlayOf(mapped, 'run'), { kind: 'unreachable', group: 'locomotion' })
70
+ assert.equal(played(mapped, playSettingsOf(mapped, 'walk')).locomotion!.clip, 'walk')
71
+ })
72
+
73
+ test('a group nothing in the data chooses plays by its selection; a clip in no group, by its speed', () => {
74
+ const { dataInterface: _data, ...free } = DOG
75
+ assert.deepEqual(clipPlayOf(free as typeof DOG, 'walk'), { kind: 'group', group: 'locomotion' })
76
+ assert.equal(played(free as typeof DOG, playSettingsOf(free as typeof DOG, 'walk')).locomotion!.clip, 'walk')
77
+ assert.deepEqual(clipPlayOf(machine(), 'cycle'), { kind: 'free' })
78
+ assert.deepEqual(playSettingsOf(machine(), 'cycle'), { clips: { cycle: 1 }, motion: {}, figureValues: {} })
79
+ })
80
+
81
+ test('the dock tells the board all three, and a clip it cannot choose is not pressed to no effect', () => {
82
+ const viewer = readFileSync(fileURLToPath(new URL('../client/figure-asset-viewer.ts', import.meta.url)), 'utf8')
83
+ assert.match(viewer, /const \{ clips, motion, figureValues \} = playSettingsOf\(this\.asset, this\.playing\)/)
84
+ for (const key of ['clips', 'motion', 'figureValues']) assert.match(viewer, new RegExp(`this\\.tell\\('${key}', ${key}\\)`))
85
+ assert.match(viewer, /\?disabled=\$\{unreachable\}/)
86
+ for (const lang of ['ko', 'en', 'ja', 'zh', 'ms', 'es']) {
87
+ const table = JSON.parse(readFileSync(fileURLToPath(new URL(`../translations/${lang}.json`, import.meta.url)), 'utf8'))
88
+ assert.ok(table['figure.text.detail-clip-by-data'], lang)
89
+ }
90
+ })
@@ -3,6 +3,9 @@
3
3
  "figure.button.detail-save-thumbnail": "use this view as the thumbnail",
4
4
  "figure.label.category": "category",
5
5
  "figure.label.detail-size": "Placement size",
6
+ "figure.label.detail-tab-info": "Info",
7
+ "figure.label.detail-tab-motion": "Motion",
8
+ "figure.label.detail-tab-size": "Size",
6
9
  "figure.label.extensions": "extensions",
7
10
  "figure.label.figure-placement": "placement",
8
11
  "figure.label.instance-range": "allowed size",
@@ -29,6 +32,7 @@
29
32
  "figure.text.detail-no-motion": "No motion is defined.",
30
33
  "figure.text.detail-paused": "Paused",
31
34
  "figure.text.detail-playing": "Playing",
35
+ "figure.text.detail-clip-by-data": "The figure's data chooses the clip {clip}, and no data value turns into it, so it cannot be played here.",
32
36
  "figure.text.detail-thumbnail-failed": "could not save the thumbnail. try again.",
33
37
  "figure.text.detail-thumbnail-saved": "saved as the thumbnail",
34
38
  "figure.text.detail-transient": "Try sizes and motion here. The saved model stays unchanged.",
@@ -3,6 +3,9 @@
3
3
  "figure.button.detail-save-thumbnail": "usar esta vista como miniatura",
4
4
  "figure.label.category": "categoría",
5
5
  "figure.label.detail-size": "Tamaño de colocación",
6
+ "figure.label.detail-tab-info": "Información",
7
+ "figure.label.detail-tab-motion": "Movimiento",
8
+ "figure.label.detail-tab-size": "Tamaño",
6
9
  "figure.label.extensions": "extensiones",
7
10
  "figure.label.figure-placement": "colocación",
8
11
  "figure.label.instance-range": "tamaño permitido",
@@ -29,6 +32,7 @@
29
32
  "figure.text.detail-no-motion": "No hay ningún movimiento definido.",
30
33
  "figure.text.detail-paused": "En pausa",
31
34
  "figure.text.detail-playing": "Reproduciendo",
35
+ "figure.text.detail-clip-by-data": "Los datos de la figura eligen el clip {clip} y ningún valor de datos lleva a él, así que no se puede reproducir aquí.",
32
36
  "figure.text.detail-thumbnail-failed": "no se pudo guardar la miniatura. inténtelo de nuevo.",
33
37
  "figure.text.detail-thumbnail-saved": "guardada como miniatura",
34
38
  "figure.text.detail-transient": "Pruebe aquí tamaños y movimientos. El modelo guardado no cambia.",
@@ -3,6 +3,9 @@
3
3
  "figure.button.detail-save-thumbnail": "この画面をサムネイルに",
4
4
  "figure.label.category": "分類",
5
5
  "figure.label.detail-size": "配置サイズ",
6
+ "figure.label.detail-tab-info": "情報",
7
+ "figure.label.detail-tab-motion": "動き",
8
+ "figure.label.detail-tab-size": "サイズ",
6
9
  "figure.label.extensions": "拡張属性",
7
10
  "figure.label.figure-placement": "配置基準",
8
11
  "figure.label.instance-range": "許容サイズ",
@@ -29,6 +32,7 @@
29
32
  "figure.text.detail-no-motion": "登録された動きがありません。",
30
33
  "figure.text.detail-paused": "一時停止",
31
34
  "figure.text.detail-playing": "再生中",
35
+ "figure.text.detail-clip-by-data": "{clip} クリップはこのFigureのデータが選びますが、そのクリップになるデータ値がないため、ここでは再生できません。",
32
36
  "figure.text.detail-thumbnail-failed": "サムネイルを保存できませんでした。もう一度お試しください。",
33
37
  "figure.text.detail-thumbnail-saved": "サムネイルに保存しました",
34
38
  "figure.text.detail-transient": "サイズと動きはここでのみ試します。保存されたモデルは変更されません。",
@@ -3,6 +3,9 @@
3
3
  "figure.button.detail-save-thumbnail": "이 화면을 썸네일로",
4
4
  "figure.label.category": "분류",
5
5
  "figure.label.detail-size": "배치 크기",
6
+ "figure.label.detail-tab-info": "정보",
7
+ "figure.label.detail-tab-motion": "움직임",
8
+ "figure.label.detail-tab-size": "크기",
6
9
  "figure.label.extensions": "확장 속성",
7
10
  "figure.label.figure-placement": "배치 기준",
8
11
  "figure.label.instance-range": "허용 크기",
@@ -29,6 +32,7 @@
29
32
  "figure.text.detail-no-motion": "등록된 움직임이 없습니다.",
30
33
  "figure.text.detail-paused": "일시정지",
31
34
  "figure.text.detail-playing": "재생 중",
35
+ "figure.text.detail-clip-by-data": "{clip} 클립은 이 Figure의 데이터가 고르는데, 그 클립이 되는 데이터 값이 없어 여기서 재생할 수 없습니다.",
32
36
  "figure.text.detail-thumbnail-failed": "썸네일을 저장하지 못했습니다. 다시 시도하세요.",
33
37
  "figure.text.detail-thumbnail-saved": "썸네일로 저장했습니다",
34
38
  "figure.text.detail-transient": "크기와 움직임은 여기서만 시험합니다. 저장된 모델은 바뀌지 않습니다.",
@@ -3,6 +3,9 @@
3
3
  "figure.button.detail-save-thumbnail": "guna paparan ini sebagai lakaran kecil",
4
4
  "figure.label.category": "kategori",
5
5
  "figure.label.detail-size": "Saiz penempatan",
6
+ "figure.label.detail-tab-info": "Maklumat",
7
+ "figure.label.detail-tab-motion": "Pergerakan",
8
+ "figure.label.detail-tab-size": "Saiz",
6
9
  "figure.label.extensions": "sambungan",
7
10
  "figure.label.figure-placement": "penempatan",
8
11
  "figure.label.instance-range": "saiz dibenarkan",
@@ -29,6 +32,7 @@
29
32
  "figure.text.detail-no-motion": "Tiada gerakan didaftarkan.",
30
33
  "figure.text.detail-paused": "Dijeda",
31
34
  "figure.text.detail-playing": "Sedang dimainkan",
35
+ "figure.text.detail-clip-by-data": "Data figure ini memilih klip {clip}, dan tiada nilai data menjadi klip itu, jadi ia tidak boleh dimainkan di sini.",
32
36
  "figure.text.detail-thumbnail-failed": "lakaran kecil tidak dapat disimpan. cuba lagi.",
33
37
  "figure.text.detail-thumbnail-saved": "disimpan sebagai lakaran kecil",
34
38
  "figure.text.detail-transient": "Saiz dan gerakan hanya diuji di sini. Model yang disimpan tidak berubah.",
@@ -3,6 +3,9 @@
3
3
  "figure.button.detail-save-thumbnail": "将此画面设为缩略图",
4
4
  "figure.label.category": "分类",
5
5
  "figure.label.detail-size": "放置尺寸",
6
+ "figure.label.detail-tab-info": "信息",
7
+ "figure.label.detail-tab-motion": "运动",
8
+ "figure.label.detail-tab-size": "尺寸",
6
9
  "figure.label.extensions": "扩展属性",
7
10
  "figure.label.figure-placement": "放置基准",
8
11
  "figure.label.instance-range": "允许尺寸",
@@ -29,6 +32,7 @@
29
32
  "figure.text.detail-no-motion": "没有已注册的动作。",
30
33
  "figure.text.detail-paused": "已暂停",
31
34
  "figure.text.detail-playing": "播放中",
35
+ "figure.text.detail-clip-by-data": "片段 {clip} 由此 Figure 的数据选择,但没有数据值对应它,因此无法在此播放。",
32
36
  "figure.text.detail-thumbnail-failed": "无法保存缩略图。请重试。",
33
37
  "figure.text.detail-thumbnail-saved": "已保存为缩略图",
34
38
  "figure.text.detail-transient": "尺寸和动作仅在此处试用,不会修改已保存的模型。",