@things-factory/figure-ui 10.1.5 → 10.1.7
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/client/graphql/index.ts +36 -3
- package/client/modeller/figure-animations.ts +712 -0
- package/client/modeller/figure-ask.ts +5 -5
- package/client/modeller/figure-canvas.ts +1 -1
- package/client/modeller/figure-capabilities.ts +372 -0
- package/client/modeller/figure-history-panel.ts +171 -18
- package/client/modeller/figure-inspector.ts +439 -76
- package/client/modeller/figure-parts.ts +15 -15
- package/client/modeller/figure-preview.ts +2 -2
- package/client/modeller/figure-report.ts +102 -37
- package/client/modeller/figure-settings.ts +20 -20
- package/client/modeller/figure-side.ts +91 -15
- package/client/modeller/figure-source.test.ts +15 -1
- package/client/modeller/figure-source.ts +31 -15
- package/client/modeller/figure-thumbnail.ts +49 -4
- package/client/modeller/maturity.ts +10 -10
- package/client/pages/figure-list-page.ts +204 -66
- package/client/pages/figure-modeller-page.ts +158 -42
- package/client/types.ts +31 -0
- package/client/viewparts/figure-thumb.ts +250 -0
- package/dist-client/graphql/index.d.ts +8 -1
- package/dist-client/graphql/index.js +33 -3
- package/dist-client/graphql/index.js.map +1 -1
- package/dist-client/modeller/figure-animations.d.ts +93 -0
- package/dist-client/modeller/figure-animations.js +655 -0
- package/dist-client/modeller/figure-animations.js.map +1 -0
- package/dist-client/modeller/figure-ask.js +5 -5
- package/dist-client/modeller/figure-ask.js.map +1 -1
- package/dist-client/modeller/figure-canvas.js +1 -1
- package/dist-client/modeller/figure-canvas.js.map +1 -1
- package/dist-client/modeller/figure-capabilities.d.ts +42 -0
- package/dist-client/modeller/figure-capabilities.js +344 -0
- package/dist-client/modeller/figure-capabilities.js.map +1 -0
- package/dist-client/modeller/figure-history-panel.d.ts +15 -1
- package/dist-client/modeller/figure-history-panel.js +165 -18
- package/dist-client/modeller/figure-history-panel.js.map +1 -1
- package/dist-client/modeller/figure-inspector.d.ts +98 -0
- package/dist-client/modeller/figure-inspector.js +425 -75
- package/dist-client/modeller/figure-inspector.js.map +1 -1
- package/dist-client/modeller/figure-parts.js +15 -15
- package/dist-client/modeller/figure-parts.js.map +1 -1
- package/dist-client/modeller/figure-preview.js +2 -2
- package/dist-client/modeller/figure-preview.js.map +1 -1
- package/dist-client/modeller/figure-report.d.ts +18 -1
- package/dist-client/modeller/figure-report.js +105 -37
- package/dist-client/modeller/figure-report.js.map +1 -1
- package/dist-client/modeller/figure-settings.js +19 -19
- package/dist-client/modeller/figure-settings.js.map +1 -1
- package/dist-client/modeller/figure-side.d.ts +24 -0
- package/dist-client/modeller/figure-side.js +94 -14
- package/dist-client/modeller/figure-side.js.map +1 -1
- package/dist-client/modeller/figure-source.d.ts +15 -8
- package/dist-client/modeller/figure-source.js +16 -7
- package/dist-client/modeller/figure-source.js.map +1 -1
- package/dist-client/modeller/figure-thumbnail.js +40 -4
- package/dist-client/modeller/figure-thumbnail.js.map +1 -1
- package/dist-client/modeller/maturity.js +10 -10
- package/dist-client/modeller/maturity.js.map +1 -1
- package/dist-client/pages/figure-list-page.d.ts +11 -4
- package/dist-client/pages/figure-list-page.js +201 -63
- package/dist-client/pages/figure-list-page.js.map +1 -1
- package/dist-client/pages/figure-modeller-page.d.ts +33 -0
- package/dist-client/pages/figure-modeller-page.js +156 -42
- package/dist-client/pages/figure-modeller-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/types.d.ts +29 -0
- package/dist-client/types.js.map +1 -1
- package/dist-client/viewparts/figure-thumb.d.ts +29 -0
- package/dist-client/viewparts/figure-thumb.js +242 -0
- package/dist-client/viewparts/figure-thumb.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/test/i18n-prefix-guard.test.ts +171 -0
- package/test/korean-register-guard.test.ts +83 -0
- package/translations/en.json +351 -264
- package/translations/ja.json +276 -264
- package/translations/ko.json +351 -264
- package/translations/ms.json +276 -264
- package/translations/zh.json +276 -264
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
import { css, html, LitElement, nothing, type TemplateResult } from 'lit'
|
|
2
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
|
+
import { live } from 'lit/directives/live.js'
|
|
4
|
+
|
|
5
|
+
import { i18next, localize } from '@operato/i18n'
|
|
6
|
+
import { ScrollbarStyles } from '@operato/styles'
|
|
7
|
+
|
|
8
|
+
import { AXES, CHANNEL_PATHS, CLIP_DRIVES, INTERPOLATIONS, LIMITS } from '@hatiolab/figure-model'
|
|
9
|
+
import type { ChannelPath, Vec3 } from '@hatiolab/figure-model'
|
|
10
|
+
|
|
11
|
+
import type { BoardModel, PartModel } from './figure-source.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 이 도형이 **어떻게 움직이는가.**
|
|
15
|
+
*
|
|
16
|
+
* ## 왜 탭 하나가 필요한가
|
|
17
|
+
*
|
|
18
|
+
* 움직임은 형식에 있고 런타임까지 서 있었다 — 검증이 촘촘히 보고, 청사진이 움직이는 부품을
|
|
19
|
+
* 단독 묶음으로 빼고(합치면 따로 못 움직인다), 씬이 frameClock 을 구독해 실제로 돌린다.
|
|
20
|
+
* 미리보기에도 clip 마다 슬라이더가 있었다.
|
|
21
|
+
*
|
|
22
|
+
* **만들 자리만 없었다.** 그래서 움직이는 도형을 얻는 길이 「AI 가 후보로 내놓는 것」 하나였고,
|
|
23
|
+
* 채널 하나를 고치려면 손댈 화면이 없었다.
|
|
24
|
+
*
|
|
25
|
+
* ## 부품이 아니라 도형의 것이다
|
|
26
|
+
*
|
|
27
|
+
* clip 하나가 부품 여럿을 함께 움직인다 — 문 열림은 왼짝과 오른짝이 반대로 미끄러지는 것
|
|
28
|
+
* 하나다. 그래서 부품을 고르고 「이 부품의 움직임」을 적는 형태가 될 수 없고, 속성 탭이 아니라
|
|
29
|
+
* 자기 탭에 산다.
|
|
30
|
+
*
|
|
31
|
+
* ## 트윈은 타임라인을 재생하지 않는다
|
|
32
|
+
*
|
|
33
|
+
* 「문 열기 clip 을 재생하라」가 아니라 **「지금 40% 열려 있다」**다. 그래서 clip 마다 그 값을
|
|
34
|
+
* 어떻게 받을지(`drive`)를 저작 시점에 정한다 — 도는 롤러는 배속을 받고, 열린 문은 0~1 위치를
|
|
35
|
+
* 받는다. 이 선택이 화면에서 가장 설명이 필요한 자리다.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
type Clip = NonNullable<BoardModel['animations']>[number]
|
|
39
|
+
type Channel = Clip['channels'][number]
|
|
40
|
+
type Keyframe = Channel['keys'][number]
|
|
41
|
+
|
|
42
|
+
/** 새 clip 의 키 둘. **하나로 만들지 않는다** — 키 하나는 움직임이 아니라 자세다. */
|
|
43
|
+
const NEW_KEYS: Keyframe[] = [
|
|
44
|
+
{ at: 0, value: { x: 0, y: 0, z: 0 } },
|
|
45
|
+
{ at: 1, value: { x: 0, y: 0, z: 0 } }
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
/** `scale` 만 1 에서 시작한다 — 0 은 부품을 지운다. */
|
|
49
|
+
function startValue(path: ChannelPath): Vec3 {
|
|
50
|
+
return path === 'scale' ? { x: 1, y: 1, z: 1 } : { x: 0, y: 0, z: 0 }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function keysFor(path: ChannelPath): Keyframe[] {
|
|
54
|
+
return NEW_KEYS.map(key => ({ at: key.at, value: startValue(path) }))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 이미 쓴 이름을 비켜 간다. `type` 처럼 저장되는 식별자는 아니지만 인스턴스가 이 이름으로 구동한다. */
|
|
58
|
+
function freeName(taken: readonly Clip[]): string {
|
|
59
|
+
const used = new Set(taken.map(clip => clip.name))
|
|
60
|
+
for (let n = 1; ; n++) {
|
|
61
|
+
const name = `clip-${n}`
|
|
62
|
+
if (!used.has(name)) return name
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@customElement('figure-animations')
|
|
67
|
+
export class FigureAnimations extends localize(i18next)(LitElement) {
|
|
68
|
+
static styles = [
|
|
69
|
+
ScrollbarStyles,
|
|
70
|
+
css`
|
|
71
|
+
:host {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
min-height: 0;
|
|
75
|
+
overflow-y: auto;
|
|
76
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
77
|
+
color: var(--md-sys-color-on-surface);
|
|
78
|
+
font: var(--label-font, inherit);
|
|
79
|
+
font-size: 0.76rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
section {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
gap: var(--spacing-medium, 8px);
|
|
86
|
+
padding: var(--spacing-large, 12px);
|
|
87
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* 다른 탭들과 같은 눈금이다 */
|
|
91
|
+
h3 {
|
|
92
|
+
margin: 0 0 2px 0;
|
|
93
|
+
font-size: var(--ui-t-micro, 11px);
|
|
94
|
+
font-weight: 700;
|
|
95
|
+
letter-spacing: 0.04em;
|
|
96
|
+
text-transform: uppercase;
|
|
97
|
+
color: var(--md-sys-color-on-surface-variant, var(--md-sys-color-on-surface));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
p[quiet] {
|
|
101
|
+
margin: 0;
|
|
102
|
+
font-size: 0.72rem;
|
|
103
|
+
line-height: 1.5;
|
|
104
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* ── clip ─────────────────────────────────────────────────────── */
|
|
108
|
+
|
|
109
|
+
div[clip] {
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
gap: var(--spacing-medium, 8px);
|
|
113
|
+
padding: 8px;
|
|
114
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
115
|
+
border-radius: 4px;
|
|
116
|
+
}
|
|
117
|
+
div[clip][on] {
|
|
118
|
+
border-color: var(--md-sys-color-primary);
|
|
119
|
+
background-color: var(--md-sys-color-surface-container-low);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
div[head] {
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
gap: 6px;
|
|
126
|
+
}
|
|
127
|
+
div[head] input[name] {
|
|
128
|
+
flex: 1;
|
|
129
|
+
min-width: 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* ── channel ──────────────────────────────────────────────────── */
|
|
133
|
+
|
|
134
|
+
div[channel] {
|
|
135
|
+
display: flex;
|
|
136
|
+
flex-direction: column;
|
|
137
|
+
gap: 6px;
|
|
138
|
+
padding: 6px 8px;
|
|
139
|
+
border-left: 2px solid var(--md-sys-color-outline-variant);
|
|
140
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
141
|
+
}
|
|
142
|
+
div[channel][orphan] {
|
|
143
|
+
border-left-color: var(--md-sys-color-error);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
div[row] {
|
|
147
|
+
display: flex;
|
|
148
|
+
align-items: center;
|
|
149
|
+
gap: 6px;
|
|
150
|
+
}
|
|
151
|
+
div[row] > label {
|
|
152
|
+
flex: none;
|
|
153
|
+
min-width: 3.2em;
|
|
154
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* ── keyframe ─────────────────────────────────────────────────── */
|
|
158
|
+
|
|
159
|
+
table[keys] {
|
|
160
|
+
width: 100%;
|
|
161
|
+
border-collapse: collapse;
|
|
162
|
+
}
|
|
163
|
+
table[keys] th {
|
|
164
|
+
padding: 0 2px 2px;
|
|
165
|
+
font-size: 0.68rem;
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
text-align: left;
|
|
168
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
169
|
+
}
|
|
170
|
+
table[keys] td {
|
|
171
|
+
padding: 1px 2px;
|
|
172
|
+
}
|
|
173
|
+
table[keys] input {
|
|
174
|
+
width: 100%;
|
|
175
|
+
min-width: 0;
|
|
176
|
+
}
|
|
177
|
+
table[keys] td[drop] {
|
|
178
|
+
width: 1.6em;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
input,
|
|
182
|
+
select {
|
|
183
|
+
box-sizing: border-box;
|
|
184
|
+
padding: 3px 5px;
|
|
185
|
+
font: inherit;
|
|
186
|
+
font-size: 0.74rem;
|
|
187
|
+
color: var(--md-sys-color-on-surface);
|
|
188
|
+
background-color: var(--md-sys-color-surface-container-lowest);
|
|
189
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
190
|
+
border-radius: 3px;
|
|
191
|
+
}
|
|
192
|
+
input:focus,
|
|
193
|
+
select:focus {
|
|
194
|
+
outline: none;
|
|
195
|
+
border-color: var(--md-sys-color-primary);
|
|
196
|
+
}
|
|
197
|
+
input[bad] {
|
|
198
|
+
border-color: var(--md-sys-color-error);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
button {
|
|
202
|
+
display: inline-flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
gap: 3px;
|
|
205
|
+
padding: 3px 8px;
|
|
206
|
+
font: inherit;
|
|
207
|
+
font-size: 0.72rem;
|
|
208
|
+
color: var(--md-sys-color-on-surface);
|
|
209
|
+
background-color: var(--md-sys-color-surface-container);
|
|
210
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
211
|
+
border-radius: 3px;
|
|
212
|
+
cursor: pointer;
|
|
213
|
+
}
|
|
214
|
+
button:hover:not(:disabled) {
|
|
215
|
+
background-color: var(--md-sys-color-surface-container-high);
|
|
216
|
+
}
|
|
217
|
+
button:disabled {
|
|
218
|
+
opacity: 0.4;
|
|
219
|
+
cursor: default;
|
|
220
|
+
}
|
|
221
|
+
button[plain] {
|
|
222
|
+
padding: 1px 4px;
|
|
223
|
+
background: none;
|
|
224
|
+
border: none;
|
|
225
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
226
|
+
}
|
|
227
|
+
button[plain]:hover:not(:disabled) {
|
|
228
|
+
color: var(--md-sys-color-error);
|
|
229
|
+
background: none;
|
|
230
|
+
}
|
|
231
|
+
button md-icon {
|
|
232
|
+
font-size: 14px;
|
|
233
|
+
width: 14px;
|
|
234
|
+
height: 14px;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* ── 예산 ─────────────────────────────────────────────────────── */
|
|
238
|
+
|
|
239
|
+
div[budget] {
|
|
240
|
+
display: flex;
|
|
241
|
+
align-items: baseline;
|
|
242
|
+
gap: 6px;
|
|
243
|
+
}
|
|
244
|
+
div[budget] strong {
|
|
245
|
+
font-size: 0.86rem;
|
|
246
|
+
font-weight: 700;
|
|
247
|
+
}
|
|
248
|
+
div[budget][over] strong {
|
|
249
|
+
color: var(--md-sys-color-error);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
p[warn] {
|
|
253
|
+
margin: 0;
|
|
254
|
+
font-size: 0.7rem;
|
|
255
|
+
line-height: 1.5;
|
|
256
|
+
color: var(--md-sys-color-error);
|
|
257
|
+
}
|
|
258
|
+
`
|
|
259
|
+
]
|
|
260
|
+
|
|
261
|
+
@property({ type: Object }) board?: BoardModel
|
|
262
|
+
@property({ type: Array }) parts: PartModel[] = []
|
|
263
|
+
|
|
264
|
+
/** 펼쳐 둔 clip. 이름이 아니라 자리로 잡는다 — 이름은 편집 중에 바뀐다. */
|
|
265
|
+
@state() private open = 0
|
|
266
|
+
|
|
267
|
+
private get clips(): Clip[] {
|
|
268
|
+
return this.board?.animations ?? []
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** 부품 이름 — 채널이 이것을 가리킨다. */
|
|
272
|
+
private get partNames(): string[] {
|
|
273
|
+
return this.parts.map(part => part.name).filter(name => !!name)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* 몇 부품이 움직이나 — 채널이 가리키는 **서로 다른 부품**의 수.
|
|
278
|
+
*
|
|
279
|
+
* clip 수가 아니다. 한 부품을 세 clip 이 움직여도 그 부품 하나가 단독 묶음이 될 뿐이다.
|
|
280
|
+
* 청사진이 묶음을 가르는 기준과 같은 셈이어야 화면의 수와 판정의 수가 맞는다.
|
|
281
|
+
*/
|
|
282
|
+
private get movingParts(): number {
|
|
283
|
+
const moving = new Set<string>()
|
|
284
|
+
for (const clip of this.clips) for (const channel of clip.channels) moving.add(channel.target)
|
|
285
|
+
return moving.size
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
render(): TemplateResult {
|
|
289
|
+
if (!this.board) return html``
|
|
290
|
+
|
|
291
|
+
return html`
|
|
292
|
+
<section>
|
|
293
|
+
<h3>${i18next.t('figure.label.animation')}</h3>
|
|
294
|
+
<p quiet>${i18next.t('figure.text.animation-is-driven-by-a-fact')}</p>
|
|
295
|
+
</section>
|
|
296
|
+
|
|
297
|
+
${this.clips.length === 0 ? this.renderEmpty() : this.renderClips()}
|
|
298
|
+
|
|
299
|
+
<section>
|
|
300
|
+
<button @click=${() => this.addClip()} ?disabled=${this.partNames.length === 0}>
|
|
301
|
+
<md-icon>add</md-icon>${i18next.t('figure.button.add-clip')}
|
|
302
|
+
</button>
|
|
303
|
+
${this.partNames.length === 0
|
|
304
|
+
? html`<p quiet>${i18next.t('figure.text.animation-needs-a-named-part')}</p>`
|
|
305
|
+
: nothing}
|
|
306
|
+
</section>
|
|
307
|
+
|
|
308
|
+
${this.clips.length === 0 ? nothing : this.renderBudget()}
|
|
309
|
+
`
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* 빈 화면 — **이 탭이 무엇인지 가르치는 자리다.**
|
|
314
|
+
*
|
|
315
|
+
* 「clip 을 추가하세요」라고만 쓰면 처음 여는 사람은 clip 이 무엇인지 모른 채 단추를 누른다.
|
|
316
|
+
* 그래서 무엇을 만들 수 있는지 예를 들고, 그것이 어떻게 움직이는지(사실이 들어온다)를 적는다.
|
|
317
|
+
*/
|
|
318
|
+
private renderEmpty(): TemplateResult {
|
|
319
|
+
return html`
|
|
320
|
+
<section>
|
|
321
|
+
<p quiet>${i18next.t('figure.text.animation-empty-what-it-is')}</p>
|
|
322
|
+
<p quiet>${i18next.t('figure.text.animation-empty-examples')}</p>
|
|
323
|
+
</section>
|
|
324
|
+
`
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private renderClips(): TemplateResult {
|
|
328
|
+
return html`
|
|
329
|
+
<section>
|
|
330
|
+
${this.clips.map((clip, at) => this.renderClip(clip, at))}
|
|
331
|
+
</section>
|
|
332
|
+
`
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
private renderClip(clip: Clip, at: number): TemplateResult {
|
|
336
|
+
const on = this.open === at
|
|
337
|
+
const duplicate = this.clips.some((other, i) => i !== at && other.name === clip.name)
|
|
338
|
+
const nameless = !clip.name?.trim()
|
|
339
|
+
|
|
340
|
+
return html`
|
|
341
|
+
<div clip ?on=${on}>
|
|
342
|
+
<div head>
|
|
343
|
+
<button plain @click=${() => (this.open = on ? -1 : at)} title=${i18next.t('figure.label.channels')}>
|
|
344
|
+
<md-icon>${on ? 'expand_more' : 'chevron_right'}</md-icon>
|
|
345
|
+
</button>
|
|
346
|
+
<input
|
|
347
|
+
name
|
|
348
|
+
.value=${live(clip.name ?? '')}
|
|
349
|
+
?bad=${duplicate || nameless}
|
|
350
|
+
placeholder=${i18next.t('figure.label.clip-name')}
|
|
351
|
+
title=${duplicate ? i18next.t('figure.text.clip-name-taken') : i18next.t('figure.text.clip-name-is-how-it-is-driven')}
|
|
352
|
+
@change=${(e: Event) => this.renameClip(at, (e.target as HTMLInputElement).value)}
|
|
353
|
+
/>
|
|
354
|
+
<select
|
|
355
|
+
.value=${live(clip.drive ?? 'loop')}
|
|
356
|
+
title=${i18next.t('figure.text.drive-explained')}
|
|
357
|
+
@change=${(e: Event) => this.setDrive(at, (e.target as HTMLSelectElement).value as Clip['drive'])}
|
|
358
|
+
>
|
|
359
|
+
${CLIP_DRIVES.map(
|
|
360
|
+
drive => html`<option value=${drive}>${i18next.t('figure.label.drive-' + drive)}</option>`
|
|
361
|
+
)}
|
|
362
|
+
</select>
|
|
363
|
+
<button plain @click=${() => this.removeClip(at)} title=${i18next.t('figure.button.remove')}>
|
|
364
|
+
<md-icon>close</md-icon>
|
|
365
|
+
</button>
|
|
366
|
+
</div>
|
|
367
|
+
|
|
368
|
+
${duplicate ? html`<p warn>${i18next.t('figure.text.clip-name-taken')}</p>` : nothing}
|
|
369
|
+
${nameless ? html`<p warn>${i18next.t('figure.text.clip-needs-a-name')}</p>` : nothing}
|
|
370
|
+
${on ? this.renderChannels(clip, at) : nothing}
|
|
371
|
+
</div>
|
|
372
|
+
`
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private renderChannels(clip: Clip, at: number): TemplateResult {
|
|
376
|
+
return html`
|
|
377
|
+
<p quiet>${i18next.t('figure.text.drive-' + (clip.drive ?? 'loop') + '-note')}</p>
|
|
378
|
+
|
|
379
|
+
${clip.channels.length === 0 ? html`<p warn>${i18next.t('figure.text.clip-needs-a-channel')}</p>` : nothing}
|
|
380
|
+
${clip.channels.map((channel, j) => this.renderChannel(channel, at, j))}
|
|
381
|
+
|
|
382
|
+
<button @click=${() => this.addChannel(at)}>
|
|
383
|
+
<md-icon>add</md-icon>${i18next.t('figure.button.add-channel')}
|
|
384
|
+
</button>
|
|
385
|
+
`
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* 채널 하나 — 어느 부품의 어느 속성을 움직이나.
|
|
390
|
+
*
|
|
391
|
+
* 없는 부품을 가리키는 채널은 붉게 낸다. 부품 이름을 바꾸면 그 순간 이렇게 되는데,
|
|
392
|
+
* 검증은 저장할 때 말하고 여기서는 **그 자리에서** 보여 준다.
|
|
393
|
+
*/
|
|
394
|
+
private renderChannel(channel: Channel, at: number, j: number): TemplateResult {
|
|
395
|
+
const orphan = !this.partNames.includes(channel.target)
|
|
396
|
+
const turning = channel.path === 'rotation'
|
|
397
|
+
|
|
398
|
+
return html`
|
|
399
|
+
<div channel ?orphan=${orphan}>
|
|
400
|
+
<div row>
|
|
401
|
+
<label>${i18next.t('figure.label.channel-target')}</label>
|
|
402
|
+
<select
|
|
403
|
+
.value=${live(channel.target ?? '')}
|
|
404
|
+
@change=${(e: Event) => this.setChannel(at, j, { target: (e.target as HTMLSelectElement).value })}
|
|
405
|
+
>
|
|
406
|
+
${orphan ? html`<option value=${channel.target}>${channel.target}</option>` : nothing}
|
|
407
|
+
${this.partNames.map(name => html`<option value=${name}>${name}</option>`)}
|
|
408
|
+
</select>
|
|
409
|
+
<button plain @click=${() => this.removeChannel(at, j)} title=${i18next.t('figure.button.remove')}>
|
|
410
|
+
<md-icon>close</md-icon>
|
|
411
|
+
</button>
|
|
412
|
+
</div>
|
|
413
|
+
|
|
414
|
+
${orphan ? html`<p warn>${i18next.t('figure.text.channel-target-is-gone')}</p>` : nothing}
|
|
415
|
+
|
|
416
|
+
<div row>
|
|
417
|
+
<label>${i18next.t('figure.label.channel-path')}</label>
|
|
418
|
+
<select
|
|
419
|
+
.value=${live(channel.path)}
|
|
420
|
+
@change=${(e: Event) => this.setPath(at, j, (e.target as HTMLSelectElement).value as ChannelPath)}
|
|
421
|
+
>
|
|
422
|
+
${CHANNEL_PATHS.map(path => html`<option value=${path}>${i18next.t('figure.label.path-' + path)}</option>`)}
|
|
423
|
+
</select>
|
|
424
|
+
<select
|
|
425
|
+
.value=${live(channel.interpolation ?? 'linear')}
|
|
426
|
+
title=${i18next.t('figure.text.interpolation-explained')}
|
|
427
|
+
@change=${(e: Event) =>
|
|
428
|
+
this.setChannel(at, j, { interpolation: (e.target as HTMLSelectElement).value as Channel['interpolation'] })}
|
|
429
|
+
>
|
|
430
|
+
${INTERPOLATIONS.map(
|
|
431
|
+
one => html`<option value=${one}>${i18next.t('figure.label.interpolation-' + one)}</option>`
|
|
432
|
+
)}
|
|
433
|
+
</select>
|
|
434
|
+
</div>
|
|
435
|
+
|
|
436
|
+
<p quiet>${i18next.t('figure.text.path-' + channel.path + '-unit')}</p>
|
|
437
|
+
|
|
438
|
+
${turning ? this.renderPivot(channel, at, j) : nothing}
|
|
439
|
+
${this.renderKeys(channel, at, j)}
|
|
440
|
+
</div>
|
|
441
|
+
`
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* 회전 중심 — **`rotation` 에서만 뜻이 있다.**
|
|
446
|
+
*
|
|
447
|
+
* 그래서 경로가 rotation 일 때만 낸다. 언제나 내면 저작자가 옮김·배율에도 적고, 검증이
|
|
448
|
+
* 저장할 때 「쓰이지 않는다」고 알린다. 안 보이면 적을 일이 없다.
|
|
449
|
+
*/
|
|
450
|
+
private renderPivot(channel: Channel, at: number, j: number): TemplateResult {
|
|
451
|
+
const pivot = channel.pivot
|
|
452
|
+
const on = pivot !== undefined
|
|
453
|
+
|
|
454
|
+
return html`
|
|
455
|
+
<div row>
|
|
456
|
+
<label>${i18next.t('figure.label.channel-pivot')}</label>
|
|
457
|
+
<button
|
|
458
|
+
@click=${() => this.setChannel(at, j, { pivot: on ? undefined : { x: 0, y: 0, z: 0 } })}
|
|
459
|
+
title=${i18next.t('figure.text.pivot-defaults-to-the-part-centre')}
|
|
460
|
+
>
|
|
461
|
+
${i18next.t(on ? 'figure.button.pivot-clear' : 'figure.button.pivot-set')}
|
|
462
|
+
</button>
|
|
463
|
+
${on
|
|
464
|
+
? AXES.map(
|
|
465
|
+
axis => html`
|
|
466
|
+
<input
|
|
467
|
+
type="number"
|
|
468
|
+
step="1"
|
|
469
|
+
.value=${live(String(pivot![axis]))}
|
|
470
|
+
aria-label=${axis}
|
|
471
|
+
@change=${(e: Event) =>
|
|
472
|
+
this.setChannel(at, j, {
|
|
473
|
+
pivot: { ...pivot!, [axis]: Number((e.target as HTMLInputElement).value) || 0 }
|
|
474
|
+
})}
|
|
475
|
+
/>
|
|
476
|
+
`
|
|
477
|
+
)
|
|
478
|
+
: nothing}
|
|
479
|
+
</div>
|
|
480
|
+
`
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* 키프레임 표.
|
|
485
|
+
*
|
|
486
|
+
* **둘 미만으로 못 내려간다.** 하나뿐이면 움직이는 것이 아니라 자세 하나이고, 형식이
|
|
487
|
+
* 오류로 막는다. 저장하고 나서 알려 주는 것보다 지우는 단추를 죽이는 것이 낫다.
|
|
488
|
+
*
|
|
489
|
+
* 시각이 오름차순이어야 하는 것도 형식의 규칙이다. 여기서는 어긋난 줄을 붉게 내고 값을
|
|
490
|
+
* 고치지는 않는다 — 저작자가 3 을 1 로 고치던 중일 수 있다.
|
|
491
|
+
*/
|
|
492
|
+
private renderKeys(channel: Channel, at: number, j: number): TemplateResult {
|
|
493
|
+
const keys = channel.keys ?? []
|
|
494
|
+
|
|
495
|
+
return html`
|
|
496
|
+
<table keys>
|
|
497
|
+
<tr>
|
|
498
|
+
<th>${i18next.t('figure.label.key-at')}</th>
|
|
499
|
+
${AXES.map(axis => html`<th>${axis}</th>`)}
|
|
500
|
+
<th></th>
|
|
501
|
+
</tr>
|
|
502
|
+
${keys.map((key, k) => {
|
|
503
|
+
const backwards = k > 0 && key.at <= (keys[k - 1]!.at ?? 0)
|
|
504
|
+
return html`
|
|
505
|
+
<tr>
|
|
506
|
+
<td>
|
|
507
|
+
<input
|
|
508
|
+
type="number"
|
|
509
|
+
step="0.1"
|
|
510
|
+
min="0"
|
|
511
|
+
?bad=${backwards || key.at < 0}
|
|
512
|
+
.value=${live(String(key.at))}
|
|
513
|
+
title=${backwards ? i18next.t('figure.text.keys-must-rise') : ''}
|
|
514
|
+
@change=${(e: Event) =>
|
|
515
|
+
this.setKey(at, j, k, { at: Math.max(0, Number((e.target as HTMLInputElement).value) || 0) })}
|
|
516
|
+
/>
|
|
517
|
+
</td>
|
|
518
|
+
${AXES.map(
|
|
519
|
+
axis => html`
|
|
520
|
+
<td>
|
|
521
|
+
<input
|
|
522
|
+
type="number"
|
|
523
|
+
step=${channel.path === 'scale' ? '0.1' : '1'}
|
|
524
|
+
.value=${live(String(key.value[axis]))}
|
|
525
|
+
aria-label=${axis}
|
|
526
|
+
@change=${(e: Event) =>
|
|
527
|
+
this.setKey(at, j, k, {
|
|
528
|
+
value: { ...key.value, [axis]: Number((e.target as HTMLInputElement).value) || 0 }
|
|
529
|
+
})}
|
|
530
|
+
/>
|
|
531
|
+
</td>
|
|
532
|
+
`
|
|
533
|
+
)}
|
|
534
|
+
<td drop>
|
|
535
|
+
<button
|
|
536
|
+
plain
|
|
537
|
+
?disabled=${keys.length <= 2}
|
|
538
|
+
title=${keys.length <= 2 ? i18next.t('figure.text.two-keys-at-least') : i18next.t('figure.button.remove')}
|
|
539
|
+
@click=${() => this.removeKey(at, j, k)}
|
|
540
|
+
>
|
|
541
|
+
<md-icon>close</md-icon>
|
|
542
|
+
</button>
|
|
543
|
+
</td>
|
|
544
|
+
</tr>
|
|
545
|
+
`
|
|
546
|
+
})}
|
|
547
|
+
</table>
|
|
548
|
+
|
|
549
|
+
${keys.some((key, k) => k > 0 && key.at <= (keys[k - 1]!.at ?? 0))
|
|
550
|
+
? html`<p warn>${i18next.t('figure.text.keys-must-rise')}</p>`
|
|
551
|
+
: nothing}
|
|
552
|
+
|
|
553
|
+
<button @click=${() => this.addKey(at, j)}>
|
|
554
|
+
<md-icon>add</md-icon>${i18next.t('figure.button.add-key')}
|
|
555
|
+
</button>
|
|
556
|
+
`
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* 움직이는 부품 예산.
|
|
561
|
+
*
|
|
562
|
+
* **넘어도 막지 않는다.** 움직이는 부품은 저마다 단독 묶음이라 draw call 이 늘고 프레임마다
|
|
563
|
+
* 갱신이 는다 — 그 대가가 수로 보이면 저작자가 아낀다. 랜드마크 설비 하나는 정교해도 되고,
|
|
564
|
+
* 그 값이 도면 예산에 드러나면 된다.
|
|
565
|
+
*/
|
|
566
|
+
private renderBudget(): TemplateResult {
|
|
567
|
+
const used = this.movingParts
|
|
568
|
+
const over = used > LIMITS.animatedParts
|
|
569
|
+
|
|
570
|
+
return html`
|
|
571
|
+
<section>
|
|
572
|
+
<h3>${i18next.t('figure.label.budget-animations')}</h3>
|
|
573
|
+
<div budget ?over=${over}>
|
|
574
|
+
<strong>${used}</strong>
|
|
575
|
+
<span quiet>/ ${LIMITS.animatedParts}</span>
|
|
576
|
+
</div>
|
|
577
|
+
<p quiet>${i18next.t('figure.text.animated-parts-cost')}</p>
|
|
578
|
+
${over ? html`<p warn>${i18next.t('figure.text.animated-parts-over')}</p>` : nothing}
|
|
579
|
+
</section>
|
|
580
|
+
`
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// ─── 고치기 ───────────────────────────────────────────────────────────────
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* 보드에 실어 올려보낸다.
|
|
587
|
+
*
|
|
588
|
+
* `animations` 는 도형 전체의 것이므로 부품 편집(`update-part`)이 아니라 `update-board` 로
|
|
589
|
+
* 간다. 빈 배열은 칸을 지운다 — clip 을 다 지운 도형은 `animations: []` 가 아니라 없는 것이다.
|
|
590
|
+
*/
|
|
591
|
+
private tell(animations: Clip[]): void {
|
|
592
|
+
if (!this.board) return
|
|
593
|
+
|
|
594
|
+
const board: BoardModel = { ...this.board }
|
|
595
|
+
if (animations.length === 0) delete board.animations
|
|
596
|
+
else board.animations = animations
|
|
597
|
+
|
|
598
|
+
this.dispatchEvent(new CustomEvent('update-board', { detail: { board }, bubbles: true, composed: true }))
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
private patchClip(at: number, patch: Partial<Clip>): void {
|
|
602
|
+
this.tell(this.clips.map((clip, i) => (i === at ? { ...clip, ...patch } : clip)))
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
private patchChannel(at: number, j: number, next: Channel): void {
|
|
606
|
+
const clip = this.clips[at]
|
|
607
|
+
if (!clip) return
|
|
608
|
+
this.patchClip(at, { channels: clip.channels.map((channel, i) => (i === j ? next : channel)) })
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
private addClip(): void {
|
|
612
|
+
const target = this.partNames[0]
|
|
613
|
+
if (!target) return
|
|
614
|
+
|
|
615
|
+
const clip: Clip = {
|
|
616
|
+
name: freeName(this.clips),
|
|
617
|
+
drive: 'loop',
|
|
618
|
+
channels: [{ target, path: 'translation', keys: keysFor('translation') }]
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
this.open = this.clips.length
|
|
622
|
+
this.tell([...this.clips, clip])
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
private renameClip(at: number, name: string): void {
|
|
626
|
+
this.patchClip(at, { name: name.trim() })
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
private setDrive(at: number, drive: Clip['drive']): void {
|
|
630
|
+
this.patchClip(at, { drive })
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
private removeClip(at: number): void {
|
|
634
|
+
if (this.open >= at) this.open = Math.max(0, this.open - 1)
|
|
635
|
+
this.tell(this.clips.filter((_, i) => i !== at))
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
private addChannel(at: number): void {
|
|
639
|
+
const clip = this.clips[at]
|
|
640
|
+
const target = this.partNames[0]
|
|
641
|
+
if (!clip || !target) return
|
|
642
|
+
|
|
643
|
+
this.patchClip(at, {
|
|
644
|
+
channels: [...clip.channels, { target, path: 'translation', keys: keysFor('translation') }]
|
|
645
|
+
})
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
private setChannel(at: number, j: number, patch: Partial<Channel>): void {
|
|
649
|
+
const channel = this.clips[at]?.channels[j]
|
|
650
|
+
if (!channel) return
|
|
651
|
+
|
|
652
|
+
const next: Channel = { ...channel, ...patch }
|
|
653
|
+
/* `undefined` 를 얹는 것은 지우는 뜻이다. 남겨 두면 저장 형식에 빈 칸이 실린다. */
|
|
654
|
+
if ('pivot' in patch && patch.pivot === undefined) delete next.pivot
|
|
655
|
+
this.patchChannel(at, j, next)
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* 경로를 바꾼다 — **값까지 함께 옮긴다.**
|
|
660
|
+
*
|
|
661
|
+
* 옮김·회전의 0 은 「제자리」인데 배율의 0 은 **부품을 지운다.** 경로만 바꾸고 값을 그대로
|
|
662
|
+
* 두면 저작자는 부품이 사라진 것을 보고 도구가 고장 난 줄 안다. 그래서 옮김·회전 ↔ 배율을
|
|
663
|
+
* 건널 때 시작값을 그 경로의 제자리로 되돌린다. 시각은 지킨다 — 저작자가 짠 박자다.
|
|
664
|
+
*/
|
|
665
|
+
private setPath(at: number, j: number, path: ChannelPath): void {
|
|
666
|
+
const channel = this.clips[at]?.channels[j]
|
|
667
|
+
if (!channel) return
|
|
668
|
+
|
|
669
|
+
const crossing = (channel.path === 'scale') !== (path === 'scale')
|
|
670
|
+
const next: Channel = {
|
|
671
|
+
...channel,
|
|
672
|
+
path,
|
|
673
|
+
keys: crossing ? channel.keys.map(key => ({ at: key.at, value: startValue(path) })) : channel.keys
|
|
674
|
+
}
|
|
675
|
+
/* 회전이 아니면 회전 중심은 쓰이지 않는다. 남겨 두면 검증이 「쓰이지 않는다」고 알린다. */
|
|
676
|
+
if (path !== 'rotation') delete next.pivot
|
|
677
|
+
|
|
678
|
+
this.patchChannel(at, j, next)
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
private removeChannel(at: number, j: number): void {
|
|
682
|
+
const clip = this.clips[at]
|
|
683
|
+
if (!clip) return
|
|
684
|
+
this.patchClip(at, { channels: clip.channels.filter((_, i) => i !== j) })
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/** 마지막 키에서 1 초 뒤. 값은 그 키를 그대로 받는다 — 붙여 놓고 고치는 것이 짜기 쉽다. */
|
|
688
|
+
private addKey(at: number, j: number): void {
|
|
689
|
+
const channel = this.clips[at]?.channels[j]
|
|
690
|
+
if (!channel) return
|
|
691
|
+
|
|
692
|
+
const last = channel.keys[channel.keys.length - 1]
|
|
693
|
+
const key: Keyframe = { at: (last?.at ?? 0) + 1, value: { ...(last?.value ?? startValue(channel.path)) } }
|
|
694
|
+
this.patchChannel(at, j, { ...channel, keys: [...channel.keys, key] })
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
private setKey(at: number, j: number, k: number, patch: Partial<Keyframe>): void {
|
|
698
|
+
const channel = this.clips[at]?.channels[j]
|
|
699
|
+
if (!channel) return
|
|
700
|
+
this.patchChannel(at, j, {
|
|
701
|
+
...channel,
|
|
702
|
+
keys: channel.keys.map((key, i) => (i === k ? { ...key, ...patch } : key))
|
|
703
|
+
})
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/** 둘 미만으로 내려가지 않는다 — 단추가 이미 죽어 있지만 밖에서 불릴 수 있다. */
|
|
707
|
+
private removeKey(at: number, j: number, k: number): void {
|
|
708
|
+
const channel = this.clips[at]?.channels[j]
|
|
709
|
+
if (!channel || channel.keys.length <= 2) return
|
|
710
|
+
this.patchChannel(at, j, { ...channel, keys: channel.keys.filter((_, i) => i !== k) })
|
|
711
|
+
}
|
|
712
|
+
}
|