@things-factory/figure-ui 10.1.16 โ 10.1.18
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/modeller/figure-animations.ts +331 -124
- package/client/modeller/figure-canvas.ts +32 -48
- package/client/modeller/figure-capabilities.ts +10 -10
- package/client/modeller/figure-inspector.ts +39 -28
- package/client/modeller/figure-parts.ts +1 -1
- package/client/modeller/figure-preview.ts +151 -41
- package/client/modeller/figure-report.ts +24 -6
- package/client/modeller/figure-settings.ts +45 -2
- package/client/modeller/figure-side.ts +6 -6
- package/client/modeller/figure-source.ts +62 -32
- package/client/modeller/figure-thumbnail.ts +5 -5
- package/client/modeller/figure-view.ts +53 -0
- package/client/modeller/part-edits.ts +36 -36
- package/client/modeller/proposal.ts +27 -4
- package/client/pages/figure-modeller-page.ts +65 -58
- package/dist-client/modeller/figure-animations.d.ts +37 -8
- package/dist-client/modeller/figure-animations.js +293 -122
- package/dist-client/modeller/figure-animations.js.map +1 -1
- package/dist-client/modeller/figure-canvas.d.ts +7 -7
- package/dist-client/modeller/figure-canvas.js +27 -40
- package/dist-client/modeller/figure-canvas.js.map +1 -1
- package/dist-client/modeller/figure-capabilities.d.ts +2 -2
- package/dist-client/modeller/figure-capabilities.js +9 -9
- package/dist-client/modeller/figure-capabilities.js.map +1 -1
- package/dist-client/modeller/figure-inspector.d.ts +16 -5
- package/dist-client/modeller/figure-inspector.js +38 -27
- package/dist-client/modeller/figure-inspector.js.map +1 -1
- package/dist-client/modeller/figure-parts.d.ts +1 -1
- package/dist-client/modeller/figure-parts.js +1 -1
- package/dist-client/modeller/figure-parts.js.map +1 -1
- package/dist-client/modeller/figure-preview.d.ts +56 -6
- package/dist-client/modeller/figure-preview.js +132 -39
- package/dist-client/modeller/figure-preview.js.map +1 -1
- package/dist-client/modeller/figure-report.d.ts +9 -0
- package/dist-client/modeller/figure-report.js +23 -5
- package/dist-client/modeller/figure-report.js.map +1 -1
- package/dist-client/modeller/figure-settings.js +42 -2
- package/dist-client/modeller/figure-settings.js.map +1 -1
- package/dist-client/modeller/figure-side.d.ts +2 -2
- package/dist-client/modeller/figure-side.js +5 -5
- package/dist-client/modeller/figure-side.js.map +1 -1
- package/dist-client/modeller/figure-source.d.ts +25 -15
- package/dist-client/modeller/figure-source.js +42 -21
- package/dist-client/modeller/figure-source.js.map +1 -1
- package/dist-client/modeller/figure-thumbnail.d.ts +2 -2
- package/dist-client/modeller/figure-thumbnail.js +3 -3
- package/dist-client/modeller/figure-thumbnail.js.map +1 -1
- package/dist-client/modeller/figure-view.d.ts +45 -0
- package/dist-client/modeller/figure-view.js +27 -0
- package/dist-client/modeller/figure-view.js.map +1 -1
- package/dist-client/modeller/part-edits.d.ts +16 -16
- package/dist-client/modeller/part-edits.js +35 -35
- package/dist-client/modeller/part-edits.js.map +1 -1
- package/dist-client/modeller/proposal.d.ts +1 -1
- package/dist-client/modeller/proposal.js +16 -3
- package/dist-client/modeller/proposal.js.map +1 -1
- package/dist-client/pages/figure-modeller-page.d.ts +9 -10
- package/dist-client/pages/figure-modeller-page.js +61 -54
- package/dist-client/pages/figure-modeller-page.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/test/ai-proposal-contract.test.ts +433 -12
- package/test/expect.ts +55 -0
- package/test/figure-source.test.ts +572 -0
- package/test/i18n-prefix-guard.test.ts +9 -12
- package/{client/modeller โ test}/part-edits.test.ts +50 -45
- package/translations/en.json +46 -35
- package/translations/ja.json +16 -21
- package/translations/ko.json +56 -45
- package/translations/ms.json +16 -21
- package/translations/zh.json +16 -21
- package/client/modeller/figure-ask.ts +0 -265
- package/client/modeller/figure-source.test.ts +0 -352
- package/dist-client/modeller/figure-ask.d.ts +0 -40
- package/dist-client/modeller/figure-ask.js +0 -282
- package/dist-client/modeller/figure-ask.js.map +0 -1
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
import { describe, it, test } from 'node:test'
|
|
4
|
+
|
|
5
|
+
import { expect } from './expect.ts'
|
|
6
|
+
|
|
7
|
+
import { existsSync, readFileSync } from 'fs'
|
|
8
|
+
import { dirname, join } from 'path'
|
|
9
|
+
|
|
10
|
+
import { toFigureSource, fromFigureSource, partToFigure, partFromFigure } from '../client/modeller/figure-source.ts'
|
|
11
|
+
import type { FigureDraft, PartModel } from '../client/modeller/figure-source.ts'
|
|
12
|
+
import type { FigurePlacement, FigureSource } from '@hatiolab/figure-model'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* ์ฌ ๋ชจ๋ธ โ `FigureSource`.
|
|
16
|
+
*
|
|
17
|
+
* ์ ์ ์ค์ ์ ๋ณธ์ ์ฌ ๋ชจ๋ธ์ด๊ณ , ํ์์ ์ ์ฅํ๊ฑฐ๋ ํ์ ํ ๋ ์ ์ด์ ๋ง๋ ๋ค. ๋ ์ดํ๊ฐ
|
|
18
|
+
* ๋ค๋ฅด๋ฏ๋ก **์ฎ๊ธฐ๋ ์ผ์ด ํ ๊ณณ์๋ง** ์์ด์ผ ํ๊ณ , ๊ทธ ํ ๊ณณ์ด ๋ง๋์ง๋ฅผ ์ฌ๊ธฐ์ ๋ชป ๋ฐ๋๋ค.
|
|
19
|
+
*
|
|
20
|
+
* ๊ฐ์ฅ ์ค์ํ ๊ฒ์ ์๋ณต์ด๋ค. ์ ์๋ค ํด๋ฉด ๊ฐ์์ผ ํ๊ณ ํด์ ์ ์ด๋ ๊ฐ์์ผ ํ๋ค โ
|
|
21
|
+
* ์ด๋ ํ์ชฝ์์๋ง ๋ง์ผ๋ฉด AI ๊ฐ ์ ์ํด ์จ ์ ๋ณธ์ ํธ์งํ๋ ์๊ฐ ๊ฐ์ด ์๋ค.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** ํ 3000 x 2000 x 800 โ ์ธ ์ถ์ด ๋ค ๋ฌ๋ผ์ผ ์ถ์ ๋ฐ๊ฟ ์จ๋ ์ํ์ด ์ก๋๋ค. */
|
|
25
|
+
const DRAFT: FigureDraft = {
|
|
26
|
+
width: 3000,
|
|
27
|
+
height: 2000,
|
|
28
|
+
depth: 800,
|
|
29
|
+
figureType: 'AGV',
|
|
30
|
+
detailLevel: 'L'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const PART: PartModel = {
|
|
34
|
+
type: 'figure-part',
|
|
35
|
+
name: 'deck',
|
|
36
|
+
primitive: 'cube',
|
|
37
|
+
left: 1100,
|
|
38
|
+
top: 700,
|
|
39
|
+
width: 800,
|
|
40
|
+
height: 600,
|
|
41
|
+
zPos: 300,
|
|
42
|
+
depth: 200,
|
|
43
|
+
token: 'palette.primary'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('์ ๊ธฐ โ ์ฌ ๋ชจ๋ธ์ ํ์์ผ๋ก', () => {
|
|
47
|
+
it('ํ์ด ๊ธฐ์ค ์์๊ฐ ๋๋ค โ ๋์ด๋ ํ์ depth ๋ค', () => {
|
|
48
|
+
const { base } = toFigureSource(DRAFT, [])
|
|
49
|
+
expect(base).toEqual({ x: 3000, y: 800, z: 2000 })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('๋ถํ ์๋ฆฌ๊ฐ ํ ์ค์ฌ ๊ธฐ์ค์ด ๋๋ค', () => {
|
|
53
|
+
const [part] = toFigureSource(DRAFT, [PART]).parts
|
|
54
|
+
|
|
55
|
+
// ํ๋ฉด ์ค์ฌ (1100+400, 700+300) = (1500, 1000), ํ ์ค์ฌ (1500, 1000) โ ์์
|
|
56
|
+
expect(part.transform.position.x).toBe(0)
|
|
57
|
+
expect(part.transform.position.z).toBe(0)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('zPos ๋ ๋ฐ๋ฉด์ด๋ค โ ์ค์ฌ์ผ๋ก ์ฌ๋ ค ์ ๋๋ค', () => {
|
|
61
|
+
const [part] = toFigureSource(DRAFT, [PART]).parts
|
|
62
|
+
|
|
63
|
+
// ๋ฐ๋ฉด 300 + ๋๊ป 200/2 = ์ค์ฌ 400. ํ ๋์ด 800 ์ ์ ๋ฐ์ ๋นผ๋ฉด 0
|
|
64
|
+
expect(part.transform.position.y).toBe(0)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('๊ฐ์ด๋ฐ๋ฅผ ๋ฒ์ด๋ ๋ถํ์ด ๊ทธ๋งํผ ์ด๊ธ๋ ์ ํ๋ค', () => {
|
|
68
|
+
const moved = { ...PART, left: 1200, top: 900, zPos: 500 }
|
|
69
|
+
const [part] = toFigureSource(DRAFT, [moved]).parts
|
|
70
|
+
|
|
71
|
+
expect(part.transform.position).toEqual({ x: 100, y: 200, z: 200 })
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('ํฌ๊ธฐ๊ฐ ์ถ ์ด๋ฆ์ผ๋ก ๋ฐ๋๋ค โ ๋๊ป๊ฐ y ๋ค', () => {
|
|
75
|
+
const [part] = toFigureSource(DRAFT, [PART]).parts
|
|
76
|
+
expect(part.transform.size).toEqual({ x: 800, y: 200, z: 600 })
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
์ฌ์ ๋ผ๋์์ ์ฐ๊ณ ์ด๋ฆ์ด ๋ค์์ฌ ์๋ค โ rotationY ๊ฐ three ์ z ๋ก ๊ฐ๋ค.
|
|
81
|
+
ํ์์ ๋๋ฅผ ์ฐ๊ณ ์ถ ์ด๋ฆ์ด ๊ทธ๋๋ก๋ค.
|
|
82
|
+
*/
|
|
83
|
+
it('ํ์ ์ด ๋๋ก ๋ฐ๋๊ณ ์ถ์ด ์ ์๋ฆฌ๋ฅผ ์ฐพ๋๋ค', () => {
|
|
84
|
+
const turned = { ...PART, rotationX: Math.PI / 6, rotation: Math.PI / 2, rotationY: Math.PI }
|
|
85
|
+
const [part] = toFigureSource(DRAFT, [turned]).parts
|
|
86
|
+
|
|
87
|
+
expect(part.transform.rotation).toEqual({ x: 30, y: -90, z: 180 })
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('ํ์ ์ด ์์ผ๋ฉด ํ๋๋ฅผ ๋์ง ์๋๋ค', () => {
|
|
91
|
+
const [part] = toFigureSource(DRAFT, [PART]).parts
|
|
92
|
+
expect(part.transform.rotation).toBeUndefined()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('์ฌ์ง์ด ํ ๋ฉ์ด๋ฆฌ๋ก ๋ชจ์ธ๋ค', () => {
|
|
96
|
+
const [part] = toFigureSource(DRAFT, [{ ...PART, preset: 'metal', flatShading: false }]).parts
|
|
97
|
+
expect(part.material).toEqual({ token: 'palette.primary', preset: 'metal', flatShading: false })
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('๋จ๋ฉด ๊ฐ์ด shape ์ผ๋ก ๋ชจ์ธ๋ค', () => {
|
|
101
|
+
const [part] = toFigureSource(DRAFT, [{ ...PART, primitive: 'rect', round: 40 }]).parts
|
|
102
|
+
expect(part.shape).toEqual({ round: 40 })
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('๋จ๋ฉด ๊ฐ์ด ์์ผ๋ฉด shape ์ ๋์ง ์๋๋ค', () => {
|
|
106
|
+
expect(toFigureSource(DRAFT, [PART]).parts[0].shape).toBeUndefined()
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
describe('ํด๊ธฐ โ ํ์์ ์ฌ ๋ชจ๋ธ๋ก', () => {
|
|
111
|
+
const SOURCE: FigureSource = {
|
|
112
|
+
type: 'AGV',
|
|
113
|
+
base: { x: 3000, y: 800, z: 2000 },
|
|
114
|
+
detailLevel: 'L',
|
|
115
|
+
parts: [
|
|
116
|
+
{
|
|
117
|
+
name: 'deck',
|
|
118
|
+
primitive: 'cube',
|
|
119
|
+
transform: { position: { x: 100, y: 200, z: 200 }, size: { x: 800, y: 200, z: 600 } },
|
|
120
|
+
material: { token: 'palette.primary' }
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
it('๊ธฐ์ค ์์๊ฐ ํ์ด ๋๋ค', () => {
|
|
126
|
+
const { draft } = fromFigureSource(SOURCE)
|
|
127
|
+
expect(draft).toMatchObject({ width: 3000, height: 2000, depth: 800 })
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('์ค์ฌ ๊ธฐ์ค ์๋ฆฌ๊ฐ ์ฌ์ ๋ชจ์๋ฆฌยท๋ฐ๋ฉด์ผ๋ก ๋ฐ๋๋ค', () => {
|
|
131
|
+
const [part] = fromFigureSource(SOURCE).parts
|
|
132
|
+
expect(part).toMatchObject({ left: 1200, top: 900, zPos: 500 })
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('๋ถํ์ด ์ฌ ํ์
์ ๊ฐ๋๋ค โ ํ์ ๊ทธ๋๋ก ๋์ ์ ์์ด์ผ ํ๋ค', () => {
|
|
136
|
+
expect(fromFigureSource(SOURCE).parts[0].type).toBe('figure-part')
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
/*
|
|
141
|
+
์๋ณต.
|
|
142
|
+
|
|
143
|
+
์ด๊ฒ์ด ์ด ๋ชจ๋์ ์กด์ฌ ์ด์ ๋ค. ํ์ชฝ์์๋ง ๋ง์ผ๋ฉด AI ๊ฐ ์ ์ํด ์จ ์ ๋ณธ์ ํด์
|
|
144
|
+
ํธ์งํ๊ณ ๋ค์ ์ ๋ ์๊ฐ ๊ฐ์ด ์๋ค โ ๊ทธ๊ฒ๋ ์กฐ์ฉํ.
|
|
145
|
+
*/
|
|
146
|
+
/**
|
|
147
|
+
* ํ์์ด ๊ฐ์ง ๊ฒ์ ๋๋๋ก ๋ค ๋ด์ ์ ๋ณธ. ์ ์ฐ์ด๋ ํ๋๋ ๋ฃ๋๋ค.
|
|
148
|
+
*
|
|
149
|
+
* describe ๋ฐ์ ๋๋ค โ ์๋ ใํฝ์ค์ฒ๊ฐ ํ์์ ๋ค ๋ด๋๋คใ๊ฐ ์ด๊ฒ์ ํ์์ ํ๋ ๋ชฉ๋ก๊ณผ
|
|
150
|
+
* ๋ง๋์ด ๋ณธ๋ค.
|
|
151
|
+
*/
|
|
152
|
+
/** ํ์์ด ๊ฐ์ง ๊ฒ์ ๋๋๋ก ๋ค ๋ด์ ์ ๋ณธ. ์ ์ฐ์ด๋ ํ๋๋ ๋ฃ๋๋ค. */
|
|
153
|
+
const FULL: FigureSource = {
|
|
154
|
+
version: 1,
|
|
155
|
+
type: 'AGV',
|
|
156
|
+
base: { x: 3000, y: 800, z: 2000 },
|
|
157
|
+
placement: 'floor',
|
|
158
|
+
detailLevel: 'L',
|
|
159
|
+
styleKit: 'factory',
|
|
160
|
+
parts: [
|
|
161
|
+
{
|
|
162
|
+
name: 'deck',
|
|
163
|
+
primitive: 'cube',
|
|
164
|
+
transform: { position: { x: 100, y: 200, z: 200 }, size: { x: 800, y: 200, z: 600 } },
|
|
165
|
+
material: { token: 'palette.primary', preset: 'metal', flatShading: true }
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'wheel',
|
|
169
|
+
primitive: 'cylinder',
|
|
170
|
+
segments: 24,
|
|
171
|
+
transform: {
|
|
172
|
+
position: { x: -700, y: -260, z: 420 },
|
|
173
|
+
size: { x: 180, y: 70, z: 180 },
|
|
174
|
+
rotation: { z: 90 }
|
|
175
|
+
},
|
|
176
|
+
material: { token: 'palette.dark', preset: 'rubber' }
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'panel',
|
|
180
|
+
primitive: 'rect',
|
|
181
|
+
// ์์ ํ ๋จ๋ฉด. ํ ๊ฒน ์์ด๋ผ ์ฒ์ ํ ์ํ์ด ๋ชป ๋ดค๋ ์๋ฆฌ๋ค.
|
|
182
|
+
shape: { round: 40, hollow: { wall: 8, floor: 4 } },
|
|
183
|
+
transform: {
|
|
184
|
+
position: { x: 0, y: 260, z: -500 },
|
|
185
|
+
size: { x: 400, y: 30, z: 200 },
|
|
186
|
+
rotation: { x: 15, y: -30, z: 45 }
|
|
187
|
+
},
|
|
188
|
+
material: { token: 'palette.accent', transparent: true },
|
|
189
|
+
// ์์ง ์๋ฌด ์ผ๋ ์ ํ๋ ํ๋๋ค. ์์ด๋ฒ๋ฆฌ๋ฉด ์ ๋๋ค.
|
|
190
|
+
materialSlot: 'cap',
|
|
191
|
+
keepRound: false,
|
|
192
|
+
sizing: 'fixed',
|
|
193
|
+
anchor: { x: 'span', y: 'max', z: 'center' },
|
|
194
|
+
label: { name: 'rpm', source: 'speed', when: 'zoomed' }
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'foot',
|
|
198
|
+
primitive: 'polygon',
|
|
199
|
+
shape: {
|
|
200
|
+
path: [
|
|
201
|
+
{ x: -60, y: -40 },
|
|
202
|
+
{ x: 60, y: -40 },
|
|
203
|
+
{ x: 0, y: 40 }
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
transform: { position: { x: 900, y: -340, z: -600 }, size: { x: 120, y: 80, z: 80 } },
|
|
207
|
+
material: { token: 'palette.neutral' },
|
|
208
|
+
sizing: 'repeat',
|
|
209
|
+
repeat: { axis: 'x', pitch: 200 }
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
/*
|
|
213
|
+
๋ฌผ๊ฑด์ ๋๋ ์๋ฆฌ์ด๋ฉด์ ๋๋๋๋ ๋ฌธ์ด๋ค โ AGV ์ ์ํ์ด ๊ทธ๋ ๋ค. **๊ทธ๋ ค์ง์ง ์์ผ๋ฏ๋ก**
|
|
214
|
+
์ฌ์ง์ด ์๋ค.
|
|
215
|
+
|
|
216
|
+
๊ทธ๋ฆฌ์ง ์๋ ๊ฒ์ด๋ผ ํ๋ฉด์ผ๋ก๋ ์๋ณต์์ ๋๋ฝ๋๋์ง ์ ์ ์๋ค. ์๋ฆฌ๋ฅผ ์์ด๋ฒ๋ฆฐ ๋ํ์
|
|
217
|
+
๋ฉ์ฉกํด ๋ณด์ด๋ฉด์ ์๋ฌด๊ฒ๋ ๋ฐ์ง ๋ชปํ๋ค.
|
|
218
|
+
*/
|
|
219
|
+
name: 'seat',
|
|
220
|
+
primitive: 'cube',
|
|
221
|
+
transform: { position: { x: 0, y: 420, z: 0 }, size: { x: 700, y: 500, z: 500 } },
|
|
222
|
+
capability: { roles: ['slot', 'port-in', 'port-out'], accepts: ['PALLET'], capacity: 2 }
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
/* ์ด ๋ํ์ด ์ง๋ ๋ฅ๋ ฅ. ๋ถํ์ด ์๋๋ผ ๋ํ ์ ์ฒด์ ๊ฒ์ด๋ค. */
|
|
226
|
+
capabilities: ['FlowNode'],
|
|
227
|
+
/*
|
|
228
|
+
์์ง์. ํธ์ง๋ฉด์ด ์์ง ์ ๋ง์ง๋ ์๋ฆฌ์ด๋ฉฐ, **๋ฐ๋ก ๊ทธ๋์ ์ฌ๊ธฐ ์๋ค.**
|
|
229
|
+
|
|
230
|
+
์ด ํฝ์ค์ฒ๊ฐ ใํ์์ด ๊ฐ์ง ๊ฒ์ ๋๋๋ก ๋ค ๋ด์ ์ ๋ณธใ์ธ๋ฐ clip ์ด ๋น ์ ธ ์์๊ณ , ๊ทธ
|
|
231
|
+
์ฌ์ด `toFigureSource` ๊ฐ clip ์ ์ ์ค์๋ค. ์ํ์ ์ด๋ก์ด์๋ค โ ํฝ์ค์ฒ์ ์๋ ๊ฒ์
|
|
232
|
+
์ํ์ด ๋ชป ๋ณธ๋ค. ํ๋ณธ ๋กค๋ฌ์ clip ์ ์ ๊ณ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์์ ์๋ฌด๊ฒ๋ ์ ๋๊ณ ๋์์ผ ์์๋ค.
|
|
233
|
+
*/
|
|
234
|
+
animations: [
|
|
235
|
+
{
|
|
236
|
+
name: 'spin',
|
|
237
|
+
channels: [
|
|
238
|
+
{
|
|
239
|
+
target: 'wheel',
|
|
240
|
+
path: 'rotation',
|
|
241
|
+
pivot: { x: 0, y: 0, z: 0 },
|
|
242
|
+
keys: [
|
|
243
|
+
{ at: 0, value: { x: 0, y: 0, z: 0 } },
|
|
244
|
+
{ at: 1, value: { x: 0, y: 360, z: 0 } }
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
/*
|
|
251
|
+
๊ฐ์ด ๋ง๋๋ ์์ธ. ์ ๋๋ฉ์ด์
๊ณผ **๋ค๋ฅธ ์นธ์ด๋ผ** ๋ฐ๋ก ๋ด๋๋ค โ ๊ฐ์ ์ด์ ๋ก ์ฌ๊ธฐ ์๋ค.
|
|
252
|
+
ํ ์นธ์ด ์๋ฉด ์ด์๋ค ์ ์ฅํ๋ ๊ฒ๋ง์ผ๋ก ์กฐ์ฉํ ์ง์์ง๋ค.
|
|
253
|
+
*/
|
|
254
|
+
parameters: [
|
|
255
|
+
{
|
|
256
|
+
name: 'lift',
|
|
257
|
+
label: 'ํฌํฌ ๋์ด',
|
|
258
|
+
range: { unit: 'mm', min: 0, max: 1800 },
|
|
259
|
+
default: 0,
|
|
260
|
+
clip: {
|
|
261
|
+
channels: [
|
|
262
|
+
{
|
|
263
|
+
target: 'wheel',
|
|
264
|
+
path: 'translation',
|
|
265
|
+
keys: [
|
|
266
|
+
{ at: 0, value: { x: 0, y: 0, z: 0 } },
|
|
267
|
+
{ at: 2.5, value: { x: 0, y: 1800, z: 0 } }
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
describe('์๋ณตํด๋ ๊ฐ๋ค', () => {
|
|
277
|
+
|
|
278
|
+
it('ํด์ ์ ์ผ๋ฉด ๊ทธ๋๋ก๋ค', () => {
|
|
279
|
+
const { draft, parts } = fromFigureSource(FULL)
|
|
280
|
+
expect(toFigureSource(draft, parts)).toEqual(FULL)
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
it('์ ์ด์ ํด๋ฉด ๊ทธ๋๋ก๋ค', () => {
|
|
284
|
+
const { draft, parts } = fromFigureSource(FULL)
|
|
285
|
+
const again = fromFigureSource(toFigureSource(draft, parts))
|
|
286
|
+
|
|
287
|
+
expect(again.draft).toEqual(draft)
|
|
288
|
+
expect(again.parts).toEqual(parts)
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('๋ ๋ฒ ์๋ณตํด๋ ๊ฐ์ด ๋ฐ๋ฆฌ์ง ์๋๋ค โ ๋ผ๋์ยท๋๋ฅผ ์ค๊ฐ๋', () => {
|
|
292
|
+
let source = FULL
|
|
293
|
+
for (let i = 0; i < 5; i++) {
|
|
294
|
+
const { draft, parts } = fromFigureSource(source)
|
|
295
|
+
source = toFigureSource(draft, parts)
|
|
296
|
+
}
|
|
297
|
+
expect(source).toEqual(FULL)
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
it('์์ง์๋ ์ด์๋จ๋๋ค โ ์ด์๋ค ์ ์ฅํ๋ ๊ฒ๋ง์ผ๋ก ์ง์์ง๋ ์๋ฆฌ๋ค', () => {
|
|
301
|
+
const { draft, parts } = fromFigureSource(FULL)
|
|
302
|
+
|
|
303
|
+
expect(toFigureSource(draft, parts).animations).toEqual(FULL.animations)
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
it('๊ฐ์ด ๋ง๋๋ ์์ธ๋ ์ด์๋จ๋๋ค โ ์ ๋๋ฉ์ด์
๊ณผ ๋ค๋ฅธ ์นธ์ด๋ผ ๋ฐ๋ก ์ ์ ์๋ค', () => {
|
|
307
|
+
const { draft, parts } = fromFigureSource(FULL)
|
|
308
|
+
|
|
309
|
+
expect(toFigureSource(draft, parts).parameters).toEqual(FULL.parameters)
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
it('์ ์ฐ์ด๋ ํ๋๋ ์ด์๋จ๋๋ค โ ์กฐ์ฉํ ์ฌ๋ผ์ง๋ฉด ์ ์์๊ฐ ์ ๊ธธ์ด ์๋ค', () => {
|
|
313
|
+
const { draft, parts } = fromFigureSource(FULL)
|
|
314
|
+
const panel = toFigureSource(draft, parts).parts.find(part => part.name === 'panel')!
|
|
315
|
+
|
|
316
|
+
expect(panel.materialSlot).toBe('cap')
|
|
317
|
+
expect(panel.sizing).toBe('fixed')
|
|
318
|
+
expect(panel.label).toEqual({ name: 'rpm', source: 'speed', when: 'zoomed' })
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
/*
|
|
323
|
+
ํฝ์ค์ฒ๊ฐ ํ์์ ๋ฐ๋ผ๊ฐ๋์ง.
|
|
324
|
+
|
|
325
|
+
**์ด ํ์ผ์์ ํ๋๊ฐ ๋ค ๋ฒ ์๋ค** โ `ports` ยท `animations` ยท `anchor` ยท `shape.hollow`.
|
|
326
|
+
๋ค ๋ฒ ๋ค ์๋ณต ์ํ์ ์ด๋ก์ด์๋ค. ์์ `FULL` ์ด ใํ์์ด ๊ฐ์ง ๊ฒ์ ๋๋๋ก ๋ค ๋ด์
|
|
327
|
+
์ ๋ณธใ์ด๋ผ๊ณ ์ ํ ์์์ง๋ง ์ค์ ๋ก๋ ๊ทธ๋๊ทธ๋ ์์ผ๋ก ์ฑ์ด ๊ฒ์ด๋ผ, ํ์์ ํ๋๊ฐ ๋๋ฉด
|
|
328
|
+
ํฝ์ค์ฒ๋ ๊ทธ๋๋ก ์๊ณ ์ํ์ ๋์ด๋ ์๋ฆฌ๋ฅผ ๋ณด์ง ๋ชปํ๋ค.
|
|
329
|
+
|
|
330
|
+
๋ค ๋ฒ์งธ ๊ฒ์ **ํ ๊ฒน ์**์ด๋ผ ์ต์์๋ง ์ธ๋ ์ฒซ ํ์ด ๋์ณค๋ค. ๊ทธ๋์ ํฝ์ค์ฒ์ ํค๋ฅผ
|
|
331
|
+
๊น์ด ์๊ด์์ด ๋ค ๋ชจ์ ๋๊ณ ๋ง๋๋ค.
|
|
332
|
+
|
|
333
|
+
๊ทธ๋์ ํฝ์ค์ฒ๋ฅผ ๋ฏฟ์ง ์๊ณ **ํ์์ด ์ค์ค๋ก ๋ฐํ ํ๋ ๋ชฉ๋ก**์ ์ฝ๋๋ค. ํ์์ด ๋ถ์
|
|
334
|
+
ํ์
์ ์ธ(`dist/types.d.ts`)์ด ์ ๋ณธ์ด๊ณ , ๊ฑฐ๊ธฐ ์ ํ ์ด๋ฆ์ด ํฝ์ค์ฒ์ ์์ผ๋ฉด ์ฌ๊ธฐ์
|
|
335
|
+
๊นจ์ง๋ค. ๋ค์ ๋ฒ ํ๋๋ ํ๋ฉด์ด ์๋๋ผ ์ด ์ํ์ด ๋จผ์ ์ก๋๋ค.
|
|
336
|
+
*/
|
|
337
|
+
describe('ํฝ์ค์ฒ๊ฐ ํ์์ ๋ค ๋ด๋๋ค', () => {
|
|
338
|
+
/**
|
|
339
|
+
* ํ์์ด ๋ถ์ฌ ๋ณด๋ธ ํ์
์ ์ธ ํ์ผ.
|
|
340
|
+
*
|
|
341
|
+
* `require.resolve` ๋ก๋ ๋ชป ์ก๋๋ค โ jest ์ resolver ๊ฐ `.d.ts` ๋ฅผ ๋ชจ๋๋ก ๋ณด์ง
|
|
342
|
+
* ์๋๋ค. ์ฌ๋ผ๊ฐ๋ฉด์ ์ฐพ๊ณ , ๋ชป ์ฐพ์ผ๋ฉด ์กฐ์ฉํ ๊ฑด๋๋ฐ์ง ์๊ณ ์ฌ๊ธฐ์ ๊นจ์ง๋ค.
|
|
343
|
+
*/
|
|
344
|
+
function declarationPath(): string {
|
|
345
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
346
|
+
for (let at = here; at !== dirname(at); at = dirname(at)) {
|
|
347
|
+
const candidate = join(at, 'node_modules/@hatiolab/figure-model/dist/types.d.ts')
|
|
348
|
+
if (existsSync(candidate)) return candidate
|
|
349
|
+
}
|
|
350
|
+
throw new Error('figure-model ์ ํ์
์ ์ธ์ ๋ชป ์ฐพ์๋ค โ ์ด ์ํ์ ๊ทธ๊ฒ์ด ์ ๋ณธ์ด๋ค')
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** ๋ถ์ ํ์
์ ์ธ์์ ํ ์ธํฐํ์ด์ค์ ํ๋ ์ด๋ฆ์ ๋ฝ๋๋ค. */
|
|
354
|
+
function fieldsOf(name: string): string[] {
|
|
355
|
+
const declared = readFileSync(declarationPath(), 'utf-8')
|
|
356
|
+
const start = declared.indexOf(`export interface ${name} {`)
|
|
357
|
+
expect(start).toBeGreaterThan(-1)
|
|
358
|
+
|
|
359
|
+
// ์ค์ฒฉ์ด ์๋ ํํํ ์ธํฐํ์ด์ค๋ค. ๋ค์ ๋ซ๋ ์ค๊ดํธ๊ฐ ๋์ด๋ค.
|
|
360
|
+
const body = declared.slice(start, declared.indexOf('\n}', start))
|
|
361
|
+
return [...body.matchAll(/^\s{4}(\w+)\??:/gm)].map(m => m[1])
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** ํฝ์ค์ฒ๊ฐ ์ด ํค๋ฅผ ๊น์ด ์๊ด์์ด ๋ชจ์๋ค โ ํ๋ฆฐ ํ๋๊ฐ ํ ๊ฒน ์์ ์์๋ค. */
|
|
365
|
+
function keysDeep(value: unknown, into = new Set<string>()): Set<string> {
|
|
366
|
+
if (Array.isArray(value)) value.forEach(one => keysDeep(one, into))
|
|
367
|
+
else if (value && typeof value === 'object') {
|
|
368
|
+
for (const [key, one] of Object.entries(value)) {
|
|
369
|
+
into.add(key)
|
|
370
|
+
keysDeep(one, into)
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return into
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const WRITTEN = keysDeep(FULL)
|
|
377
|
+
|
|
378
|
+
/*
|
|
379
|
+
`fold` ๊ฐ ์ค์ ๋ก ๋ฑ๊ฐ๋ก ํธ๋ ๊ฒ๋ค์ด๋ค. ํต์งธ๋ก ๋๋ฅด๋ ๊ตฌ์กฐ(`transform` ์ฒ๋ผ)๋ ํ๋๊ฐ
|
|
380
|
+
๋์ด๋ ์ ์๋ฏ๋ก ์ฌ๊ธฐ ์๋ค.
|
|
381
|
+
*/
|
|
382
|
+
for (const name of ['FigureSource', 'FigurePart', 'PartShape', 'HollowSpec']) {
|
|
383
|
+
it(`${name} ๊ฐ ๊ฐ์ง ๋ชจ๋ ํ๋๊ฐ ์๋ณต ํฝ์ค์ฒ์ ์๋ค`, () => {
|
|
384
|
+
expect(fieldsOf(name).filter(field => !WRITTEN.has(field))).toEqual([])
|
|
385
|
+
})
|
|
386
|
+
}
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
/*
|
|
390
|
+
* โโ The placement is a height, not a flip โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
391
|
+
*
|
|
392
|
+
* `placement` says which reference surface a figure of this kind attaches to. It is a fact about
|
|
393
|
+
* the figure *type*, and what acts on it is the scene placing an instance: a floor figure stands on
|
|
394
|
+
* the ground, a ceiling one hangs at ceiling height less its own. `operato-scene`'s archetype says
|
|
395
|
+
* the same โ *ceiling: zPos derived from ceiling minus depth* (`archetypes.ts`).
|
|
396
|
+
*
|
|
397
|
+
* **Nothing about the authored shape depends on it.** The format measures every part from the box
|
|
398
|
+
* centre, so two figures with identical parts and different placements have identical `parts`.
|
|
399
|
+
*
|
|
400
|
+
* It was wired the other way for a while: the editing canvas fed the figure's placement to the
|
|
401
|
+
* model layer's `state.placement`, a scene-wide coordinate mode that flips what `zPos` names for
|
|
402
|
+
* everything in that layer. It stood in for the archetype because the modeller holds one figure โ
|
|
403
|
+
* and every number the author had typed then meant a different face depending on a dropdown, while
|
|
404
|
+
* what got saved never changed. These four tests hold that line.
|
|
405
|
+
*/
|
|
406
|
+
test('๋ฐฐ์น๋ฅผ ๋ฐ๊ฟ๋ ๋ถํ์ ์๋ฆฌ๋ ํ ๊ธ์๋ ์ ๋ฐ๋๋ค', () => {
|
|
407
|
+
const source: FigureSource = {
|
|
408
|
+
type: 'OHT_TEST',
|
|
409
|
+
base: { x: 2, y: 3, z: 2 },
|
|
410
|
+
parts: [
|
|
411
|
+
/* ๋๊ป๊ฐ ์๋ก ๋ฌ๋ผ์ผ ํ๋ค โ ๋๊ป์ ๋น๋กํ๋ ์ด๊ธ๋จ์ ํต์งธ๋ก ์ฎ๊ธฐ๋ ๊ฒ๊ณผ ๋ฌ๋ฆฌ ํ์์ ๋ฒ๋ฆฐ๋ค. */
|
|
412
|
+
{ name: 'rail', primitive: 'cube', transform: { position: { x: 0, y: 1.425, z: 0 }, size: { x: 2, y: 0.15, z: 0.4 } }, material: { token: 'palette.primary' } },
|
|
413
|
+
{ name: 'belt', primitive: 'cube', transform: { position: { x: 0, y: 0, z: 0 }, size: { x: 0.1, y: 1, z: 0.1 } }, material: { token: 'palette.neutral' } }
|
|
414
|
+
]
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const authored = JSON.stringify(source.parts)
|
|
418
|
+
|
|
419
|
+
for (const placement of ['floor', 'ceiling', 'center'] as const) {
|
|
420
|
+
const { draft, parts } = fromFigureSource({ ...source, placement })
|
|
421
|
+
assert.equal(
|
|
422
|
+
JSON.stringify(toFigureSource(draft, parts).parts),
|
|
423
|
+
authored,
|
|
424
|
+
`${placement}: ๋ฐฐ์น๊ฐ ์ ์ํ ์๋ฆฌ๋ฅผ ๋ฐ๊ฟจ๋ค`
|
|
425
|
+
)
|
|
426
|
+
}
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
test('ํธ์ง ์บ๋ฒ์ค์ zPos ๋ ๋ฐฐ์น์ ๋ฌด๊ดํ๊ฒ ๋ฐ๋ฉด์ด๋ค', () => {
|
|
430
|
+
/*
|
|
431
|
+
์ ์์๊ฐ ์ธ์คํํฐ์ ์ ๋ ์๋ค. ๊ทธ ๋ป์ด ๋๋กญ๋ค์ด์ ๋ฐ๋ผ ๋ฐ๋ฉดโ์๋ฉด์ผ๋ก ๋ฐ๋๋ฉด, ์๋ฌด๊ฒ๋
|
|
432
|
+
์ ๊ณ ์ณค๋๋ฐ ๋ชจ๋ ๋ถํ์ ๋์ด๊ฐ ๋ฌ๋ผ์ง ๊ฒ์ผ๋ก ๋ณด์ธ๋ค. OHT ์์ ์ค์ ๋ก ๊ทธ๋ฌ๋ค โ
|
|
433
|
+
overhead-rail ์ด 1.35 ์์ -1.5 ๊ฐ ๋์๋ค.
|
|
434
|
+
*/
|
|
435
|
+
const part: PartModel = { type: 'figure-part', name: 'rail', primitive: 'cube', left: 0, top: 0, width: 2, height: 0.4, zPos: 1.35, depth: 0.15 }
|
|
436
|
+
const draft: FigureDraft = { width: 2, height: 2, depth: 3 }
|
|
437
|
+
|
|
438
|
+
for (const placement of [undefined, 'floor', 'ceiling', 'center'] as const) {
|
|
439
|
+
const written = partToFigure(part, { ...draft, placement })
|
|
440
|
+
/* ๋ฐ๋ฉด 1.35 + ๋๊ป 0.15/2 = ์ค์ฌ 1.425. ์์ ๋์ด 3 ์ ์ ๋ฐ์ ๋นผ๋ฉด -0.075. */
|
|
441
|
+
assert.equal(written.transform.position.y, -0.075, `${placement}: ์ ๋ ์ชฝ์ด ๋ฐฐ์น๋ฅผ ๋ดค๋ค`)
|
|
442
|
+
assert.equal(partFromFigure(written, { ...draft, placement }).zPos, 1.35, `${placement}: ํด๋ ์ชฝ์ด ๋ฐฐ์น๋ฅผ ๋ดค๋ค`)
|
|
443
|
+
}
|
|
444
|
+
})
|
|
445
|
+
|
|
446
|
+
describe('๋ฐฐ์น๋ ์ฌ์ ์ขํ ๋ชจ๋๊ฐ ์๋๋ค', () => {
|
|
447
|
+
const read = (rel: string) => readFileSync(join(dirname(fileURLToPath(import.meta.url)), rel), 'utf8')
|
|
448
|
+
|
|
449
|
+
/*
|
|
450
|
+
์์ค๋ฅผ ์ฝ๋ ๊ฒ์ฌ๋ค. Lit ์ปดํฌ๋ํธ๊ฐ document ์์ด ์ ๋จ๋ ์๋ฆฌ๋ผ ๊ทธ๋ ๊ณ , ๋ฌด์๋ณด๋ค
|
|
451
|
+
**์์ด์ผ ํ๋ ๊ฒ์ด ์๋์ง**๋ฅผ ๋ฌป๋ ๊ฒ์ฌ๋ ํธ์ถ๋ก๋ ๋ฌผ์ ์๊ฐ ์๋ค.
|
|
452
|
+
*/
|
|
453
|
+
it('๋ณํ์ด ์ขํ ๋ชจ๋๋ฅผ ์์ ๋ชจ๋ฅธ๋ค', () => {
|
|
454
|
+
const source = read('../client/modeller/figure-source.ts')
|
|
455
|
+
|
|
456
|
+
assert.doesNotMatch(source, /zPosOffset|toScenePlacement/, '๋ณํ์ ์ขํ ๋ชจ๋๊ฐ ๋ค์ ๋ค์ด์๋ค')
|
|
457
|
+
assert.doesNotMatch(
|
|
458
|
+
source,
|
|
459
|
+
/placement.*=>.*'inverted'|'inverted'.*:/,
|
|
460
|
+
'์ฌ์ ์ขํ ๋ฑ๋ง์ด ๋ณํ์ ๋ค์ด์๋ค'
|
|
461
|
+
)
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
it('ํธ์ง ์บ๋ฒ์ค๊ฐ ์ฌ์ ๋ฐฐ์น๋ฅผ ์ ์ฃ๋๋ค', () => {
|
|
465
|
+
const source = read('../client/modeller/figure-canvas.ts')
|
|
466
|
+
|
|
467
|
+
assert.doesNotMatch(
|
|
468
|
+
source,
|
|
469
|
+
/placement:/,
|
|
470
|
+
'ํธ์ง ์บ๋ฒ์ค๊ฐ ๋ฐฐ์น๋ฅผ ์ฌ์ ์ค์ผ๋ฉด ์ ์์๊ฐ ์ ์ ๋์ด์ ๋ป์ด ๋๋กญ๋ค์ด๋ง๋ค ๋ฐ๋๋ค'
|
|
471
|
+
)
|
|
472
|
+
})
|
|
473
|
+
|
|
474
|
+
it('setPlacement ๊ฐ ๋ถํ์ ์ ๊ฑด๋๋ฆฐ๋ค', () => {
|
|
475
|
+
const source = read('../client/modeller/figure-inspector.ts')
|
|
476
|
+
const body = source.slice(source.indexOf('private setPlacement'), source.indexOf('private setPlacement') + 500)
|
|
477
|
+
|
|
478
|
+
assert.match(body, /detail: \{ draft \}/, '๋ฐฐ์น๋ ํ๋ ํ๋๋ง ์ด๋ค')
|
|
479
|
+
assert.doesNotMatch(body, /zPos/, '๋ฐฐ์น๋ฅผ ๋ฐ๊พธ๋ฉด์ ๋ถํ ๋์ด๋ฅผ ๋ค์ ๊ณ์ฐํ๋ฉด ์ ๋๋ค')
|
|
480
|
+
})
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
describe('๋ฏธ๋ฆฌ๋ณด๊ธฐ๊ฐ ๋์ด๋ฅผ ์ฌ์๊ฒ ๋งก๊ธด๋ค', () => {
|
|
484
|
+
const read = (rel: string) => readFileSync(join(dirname(fileURLToPath(import.meta.url)), rel), 'utf8')
|
|
485
|
+
const preview = read('../client/modeller/figure-preview.ts')
|
|
486
|
+
|
|
487
|
+
/*
|
|
488
|
+
๋ฐฐ์น ๊ธฐ์ค์ ๋์ด๋ก ์ฎ๊ธฐ๋ ๊ท์น์ ์ฌ์ด ๊ฐ๋๋ค โ `FigureRealObject.effectiveZPos` ๊ฐ ์ฒญ์ฌ์ง์
|
|
489
|
+
`placement` ์ ๋ ์ด์ด์ `heights` ๋ก ์ ํ๋ค(ADR-0045). ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ ใ๋ณด๋์ ๋์์ ๋ใ๋ฅผ
|
|
490
|
+
๋งํ๋ ์๋ฆฌ์ด๋ฏ๋ก ๋ณด๋์ ๊ฐ์ ๊ธธ๋ก ์ธ์์ผ ํ๋ค.
|
|
491
|
+
|
|
492
|
+
์ด ํ๋ฉด์ด ๊ท์น์ ํ ๋ฒ ๋ ๋ค๊ณ ์์๋ค. ๊ทธ๋ฌ๋ฉด ์ฌ์ ๊ท์น์ด ๋ฐ๋์ด๋ ์ด ํ๋ฉด๋ง ์ ๋ต์ ๋ด๊ณ ,
|
|
493
|
+
์ ์์๋ ๋ณด๋์ ๋๊ณ ๋์์ผ ๋ค๋ฅด๋ค๋ ๊ฒ์ ์๋ค.
|
|
494
|
+
*/
|
|
495
|
+
it('์ธ์คํด์ค์ zPos ๋ฅผ ์ ์ง ์๋๋ค โ ์ ์ผ๋ฉด ์ ์ ๊ฐ์ด ์ด๊ธด๋ค', () => {
|
|
496
|
+
const at = preview.indexOf('const components = PREVIEW_WAYS.map')
|
|
497
|
+
const built = preview.slice(at, preview.indexOf('const draft = {', at))
|
|
498
|
+
|
|
499
|
+
assert.doesNotMatch(built, /zPos/, '์ฌ๊ธฐ์ ๋์ด๋ฅผ ์ ํ๋ฉด ์ฌ์ด ๋ฌด์์ ํ ์ง๊ฐ ์ด ํ๋ฉด์์๋ง ์ ๋ณด์ธ๋ค')
|
|
500
|
+
})
|
|
501
|
+
|
|
502
|
+
it('๋ฐฐ์น๋ฅผ ๋์ด๋ก ์ฎ๊ธฐ๋ ๊ณ์ฐ์ ๋ค๊ณ ์์ง ์๋ค', () => {
|
|
503
|
+
assert.doesNotMatch(preview, /bottomOf|zPosOf/, '๊ท์น์ด ๋ ๋ฒ์ด๋ฉด ๊ฐ๋ฆฐ๋ค')
|
|
504
|
+
})
|
|
505
|
+
|
|
506
|
+
it('์ฒ์ฅ ๋์ด๋ฅผ ์ฌ์ ์ค์ด ์ค๋ค โ ๊ฐ์ด ์ฌ๋ ์๋ฆฌ๊ฐ ๊ฑฐ๊ธฐ๋ค', () => {
|
|
507
|
+
assert.match(preview, /heights: \{ floor: 0, ceiling: view\.ceilingHeight \}/)
|
|
508
|
+
})
|
|
509
|
+
|
|
510
|
+
it('๋ฏธ๋ฆฌ๋ณด๊ธฐ๊ฐ ์ขํ ๋ชจ๋๋ฅผ ๋ณด๊ธฐ ์ค์ ์์ ๋ฐ๋๋ค โ ๋ํ์์๊ฐ ์๋๋ผ', () => {
|
|
511
|
+
assert.match(preview, /placement: view\.placement/, '๋ณด๊ธฐ ์ค์ ์ ์ขํ ๋ชจ๋๋ฅผ ์ฌ์ ์ค์ด์ผ ํ๋ค')
|
|
512
|
+
assert.doesNotMatch(preview, /placement: (source|toScenePlacement)/, '๋ํ์ ๋ฐฐ์น๋ฅผ ์ฌ ๋ชจ๋๋ก ์ฐ๋ฉด ์ ๋๋ค')
|
|
513
|
+
})
|
|
514
|
+
|
|
515
|
+
it('๋ฏธ๋ฆฌ๋ณด๊ธฐ๊ฐ ๋ณด๊ธฐ ์ค์ ์ ์กฐ๋ช
ยทํ๊ฒฝ์ ๋ฐ๋ฅธ๋ค', () => {
|
|
516
|
+
assert.match(preview, /\.\.\.sceneLook\(view\)/, 'ํ๋์ฝ๋ฉํ๋ฉด ํธ์ง ์บ๋ฒ์ค์ ๋ ํ๋ฉด์ด ๊ฐ๋ฆฐ๋ค')
|
|
517
|
+
assert.doesNotMatch(preview, /environment: 'studio'/, 'ํ๊ฒฝ์ด ํ๋์ฝ๋ฉ์ผ๋ก ๋จ์ ์๋ค')
|
|
518
|
+
})
|
|
519
|
+
})
|
|
520
|
+
|
|
521
|
+
describe('๋ณด๊ธฐ ์ค์ ์ด ํธ์ง ์บ๋ฒ์ค๋ก ์์ง ์๋๋ค', () => {
|
|
522
|
+
const read = (rel: string) => readFileSync(join(dirname(fileURLToPath(import.meta.url)), rel), 'utf8')
|
|
523
|
+
|
|
524
|
+
it('sceneLook ์ด ์ขํ ๋ชจ๋์ ์ฒ์ฅ ๋์ด๋ฅผ ๋บ๋ค', () => {
|
|
525
|
+
const view = read('../client/modeller/figure-view.ts')
|
|
526
|
+
assert.match(view, /const \{ placement, ceilingHeight, \.\.\.look \} = view/)
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
it('ํธ์ง ์บ๋ฒ์ค๊ฐ rest spread ๋ก ๋ณด๊ธฐ ์ค์ ์ ๋๊ธฐ์ง ์๋๋ค', () => {
|
|
530
|
+
/*
|
|
531
|
+
ํ๋์ `const { grid, ..., ...light } = view` ์๋ค. ๊ทธ๋ฌ๋ฉด ์ค์ ์ ํ๋ ๋ํ ๋๋ง๋ค
|
|
532
|
+
๊ทธ๊ฒ์ด ๋ ํ๋ฉด์ **๋ง์์ด** ์ค๋ฆฐ๋ค โ ์ขํ ๋ชจ๋๊ฐ ๋ฐ๋ก ๊ทธ ๊ธธ๋ก ๋ค์ด๊ฐ ๋ปํ๋ค.
|
|
533
|
+
*/
|
|
534
|
+
const canvas = read('../client/modeller/figure-canvas.ts')
|
|
535
|
+
const fn = canvas.slice(canvas.indexOf('private sceneView'), canvas.indexOf('private sceneView') + 200)
|
|
536
|
+
|
|
537
|
+
assert.match(fn, /sceneLook\(/)
|
|
538
|
+
assert.doesNotMatch(fn, /\.\.\.light/, '๋๋จธ์ง๋ฅผ ํต์งธ๋ก ๋๊ธฐ๋ฉด ์ ์ค์ ์ด ์กฐ์ฉํ ์ค๋ฆฐ๋ค')
|
|
539
|
+
})
|
|
540
|
+
})
|
|
541
|
+
|
|
542
|
+
/*
|
|
543
|
+
* โโ ๋ง๋ ๊ฒ๊ณผ ์๋ฆฌ๋ ๊ฒ์ ํ๋ฉด์ด ๊ฐ๋ผ์ผ ํ๋ค โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
544
|
+
*
|
|
545
|
+
* ํ์ ํจ๋์ ์๋ฐ์ ์ ๋ถ ๊ฐ์ `info` ๋ก ๊ทธ๋ ธ๋ค. ๊ธฐ์ค ์์ ์๋ฐ ๋์ด ๋ฐํ์ ๋ง๊ฒ ๋ ๋ค์๋
|
|
546
|
+
* ๊ทธ๋๋ก๋ผ, ์ ์์๋ ๋ค์ฏ ์ค์ ์๋ฆผ์ ๋ณด๊ณ **๋ฐํ์ ๋๋ฌ ๋ณด๊ณ ๋์์ผ** ๋งํ ๊ฒ์ ์๋ค.
|
|
547
|
+
*
|
|
548
|
+
* ๋ฑ๊ธ์ ํ์์ด ์๋ค(`blocksRelease`). ํ๋ฉด์ด ์ ๋ชฉ๋ก์ ๋ค๋ฉด ์ฝ๋๊ฐ ํ๋ ๋ ๋ ์กฐ์ฉํ
|
|
549
|
+
* ใ์๋ฆผใ ์ชฝ์ผ๋ก ๋จ์ด์ง๋ค โ ์์ ํ์ง ์์ ์ชฝ์ผ๋ก ๊ธฐ์ฐ๋ ๊ธฐ๋ณธ๊ฐ์ด๋ค.
|
|
550
|
+
*/
|
|
551
|
+
describe('ํ์ ํจ๋์ด ๋ฐํ์ ๋ง๋ ๊ฒ์ ๊ฐ๋ผ ๋ณด์ธ๋ค', () => {
|
|
552
|
+
const read = (rel: string) => readFileSync(join(dirname(fileURLToPath(import.meta.url)), rel), 'utf8')
|
|
553
|
+
const report = read('../client/modeller/figure-report.ts')
|
|
554
|
+
|
|
555
|
+
it('๋ฑ๊ธ์ ํ์์์ ๋ฐ๋๋ค โ ์ ๋ชฉ๋ก์ ๋ค์ง ์๋๋ค', () => {
|
|
556
|
+
assert.match(report, /blocksRelease/, 'ํ์์ด ์ด๋ ์๋ฐ์ด ๋ง๋์ง ์๋ค')
|
|
557
|
+
assert.doesNotMatch(
|
|
558
|
+
report,
|
|
559
|
+
/'part-outside-base'|'parts-off-placement-face'/,
|
|
560
|
+
'ํ๋ฉด์ด ์ฝ๋ ์ด๋ฆ์ ์ ์ผ๋ฉด ํ์๊ณผ ๋ ๋ฒ์ด ๋๋ค'
|
|
561
|
+
)
|
|
562
|
+
})
|
|
563
|
+
|
|
564
|
+
it('๋ง๋ ๊ฒ์ ๋ค๋ฅธ ์์ด์ฝ์ผ๋ก ๊ทธ๋ฆฐ๋ค', () => {
|
|
565
|
+
assert.match(report, /v\.blocking \? 'block' : 'info'/, '๊ฐ์ ์์ด์ฝ์ด๋ฉด ๊ฐ๋ฆฐ ๋ป์ด ํ๋ฉด์ ์ ๋์จ๋ค')
|
|
566
|
+
})
|
|
567
|
+
|
|
568
|
+
it('์ผ๋ง๋ ๋์ณค๋์ง ๋ณด์ฌ ์ค๋ค', () => {
|
|
569
|
+
/* ใ์์๋ฅผ ๋ฒ์ด๋๋คใ๋ง์ผ๋ก๋ 2mm ์ธ์ง 250mm ์ธ์ง ๋ชจ๋ฅด๊ณ , ๊ทธ ๋์ ๊ณ ์น๋ ํ์ด ๋ค๋ฅด๋ค. */
|
|
570
|
+
assert.match(report, /v\.actual/, '๋์น ์์ ๋ฒ๋ฆฌ๋ฉด ์ ์์๊ฐ ๋ฌด์๋ถํฐ ๊ณ ์น ์ง ๋ชป ๊ณ ๋ฅธ๋ค')
|
|
571
|
+
})
|
|
572
|
+
})
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* ์ฌ๋ฟ์ด๋ฉด ๋ง์ง๋ง์ด ์ด๊ธฐ๊ณ ์๋ฌด ๊ฒฝ๊ณ ๋ ์๋ค. ๊ทธ๋์ ๋ด ํ์ผ์ ์ฝ์ด๋ ํ๋ฉด์ ๋จ๋ ๊ฐ์ ์ ์
|
|
7
7
|
* ์๋ค โ ๋ด๊ฐ ์ ์ ๊ฐ์ด ์๋๋ผ ์ด๊ธด ๊ฐ์ด ๋ฌ๋ค.
|
|
8
8
|
*
|
|
9
|
-
* ์ค์ ๋ก ๊ทธ๋ฌ๋ค. figure ์ฑ์ ๋ฐํ ๋จ์ถ๊ฐ ใ๋ฐฐํฌใ๋ก ๋ด๋ค(
|
|
9
|
+
* ์ค์ ๋ก ๊ทธ๋ฌ๋ค. figure ์ฑ์ ๋ฐํ ๋จ์ถ๊ฐ ใ๋ฐฐํฌใ๋ก ๋ด๋ค(draft-ui ์ `button.release` ๊ฐ ์ด๊ฒผ๋ค).
|
|
10
10
|
* ๊ทธ๋ figure ์ 266๊ฐ ํค ์ค ์ํ์ด **๋ค๋ฅธ ๋ป์ผ๋ก** ๊ฒน์ณ ์์๋ค โ ๋ชจ๋ธ๋ฌ๊ฐ ์๊ธฐ ๋ถํ์ board ์
|
|
11
11
|
* ๋ฑ๋ง์ธ ใํ๋ชฉใ์ด๋ผ ๋ถ๋ฅด๊ณ ์์๊ณ ์๋ฌด๊ฒ๋ ๊ทธ๊ฒ์ ๋งํด ์ฃผ์ง ์์๋ค.
|
|
12
12
|
*
|
|
@@ -28,7 +28,7 @@ import { readFileSync, readdirSync } from 'node:fs'
|
|
|
28
28
|
import { fileURLToPath } from 'node:url'
|
|
29
29
|
import { join } from 'node:path'
|
|
30
30
|
|
|
31
|
-
import { CHANNEL_PATHS,
|
|
31
|
+
import { CHANNEL_PATHS, INTERPOLATIONS } from '@hatiolab/figure-model'
|
|
32
32
|
|
|
33
33
|
const HERE = fileURLToPath(new URL('.', import.meta.url))
|
|
34
34
|
const TRANSLATIONS = join(HERE, '../translations')
|
|
@@ -125,23 +125,22 @@ test('โ
ํต์ด ๊ฐ๋ฆฐ ์ง โ ์ฌ๋ค๋ฆฌ ์ด๋ฆ๊ณผ ์ค๋ช
', () => {
|
|
|
125
125
|
/*
|
|
126
126
|
์ ๋๋ฉ์ด์
ํญ๋ ์ด๊ฑฐ ๊ฐ์ ํค์ ์ด์ด ๋ถ์ธ๋ค. ์ฌ๋ค๋ฆฌ์ **๊ฐ์ ๋ชจ์์ ํจ์ **์ด๋ผ ๊ฐ์ ๋ชป์ ๋ฐ๋๋ค.
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
๊ฒฝ๋ก๋ ์ด๋ฆ(`label`)๊ณผ ๋จ์ ์ค๋ช
(`text.โฆ-unit`)์ผ๋ก ๊ฐ๋ฆฐ๋ค. ํ์ชฝ๋ง ๋ฃ์ผ๋ฉด ํ๋ฉด์ ํค๊ฐ
|
|
129
|
+
๊ทธ๋๋ก ๋จ๊ณ , ๋์ ์๋จธ๋ฆฌ๊ฐ ์์ ๋ฏธ์ฌ์ฉ ๊ฒ์ฌ๋ฅผ ๋ฎ์ด ํต๊ณผ์ํจ๋ค.
|
|
130
|
+
|
|
131
|
+
`CLIP_DRIVES` ๋ ์ฌ๊ธฐ ์๋ค. ๊ตฌ๋ ๊ฐ๋๋ ํ๋ฉด์์ ๊ณ ๋ฅด๋ ๊ฒ์ด ์๋๋ผ **์ด๋ ๋ชฉ๋ก์
|
|
132
|
+
์ ์๋๊ฐ**๊ฐ ๋์๋ค โ ์ ๋๋ฉ์ด์
์ด๋ฉด ์๊ฐ์ด ํ๋ฅด๊ณ ํ๋ผ๋ฏธํฐ๋ฉด ๊ฐ์ด ์์ธ๋ฅผ ๋ง๋ ๋ค
|
|
133
|
+
(ADR-0051 โ ).
|
|
131
134
|
|
|
132
135
|
์ด๊ฑฐ ๊ฐ์ ์ฌ๊ธฐ ๋ค์ ์ ์ง ์๊ณ ํ์์์ ์ฝ๋๋ค. ์ ์ด ๋๋ฉด ํ์์ ๊ฐ์ ํ๋ ๋ํ ๋
|
|
133
136
|
๊ฒ์ฌ๊ฐ ์กฐ์ฉํ ํต๊ณผํ๋ค.
|
|
134
137
|
*/
|
|
135
|
-
test('โ
์ด๊ฑฐ ๊ฐ๋ง๋ค ์ง์ด ๋ค ์๋ค โ
|
|
138
|
+
test('โ
์ด๊ฑฐ ๊ฐ๋ง๋ค ์ง์ด ๋ค ์๋ค โ ๊ฒฝ๋ก ยท ๋ณด๊ฐ', () => {
|
|
136
139
|
const missing: string[] = []
|
|
137
140
|
const want = (key: string) => {
|
|
138
141
|
if (!(key in KO)) missing.push(key)
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
for (const drive of CLIP_DRIVES) {
|
|
142
|
-
want(`figure.label.drive-${drive}`)
|
|
143
|
-
want(`figure.text.drive-${drive}-note`)
|
|
144
|
-
}
|
|
145
144
|
for (const path of CHANNEL_PATHS) {
|
|
146
145
|
want(`figure.label.path-${path}`)
|
|
147
146
|
want(`figure.text.path-${path}-unit`)
|
|
@@ -156,8 +155,6 @@ test('โ
์ด๊ฑฐ ๊ฐ๋ง๋ค ์ง์ด ๋ค ์๋ค โ ๊ตฌ๋ ยท ๊ฒฝ๋ก ยท ๋ณด๊ฐ', ()
|
|
|
156
155
|
test('โ
์ ๋๋ฉ์ด์
ํญ์ด ๊ทธ ํต์์ ์ฐพ๋๋ค โ ์ด๋ฆ์ label, ์ค๋ช
์ text', () => {
|
|
157
156
|
const source = readFileSync(join(CLIENT, 'modeller/figure-animations.ts'), 'utf-8')
|
|
158
157
|
|
|
159
|
-
assert.ok(source.includes("'figure.label.drive-' + drive"), '๊ตฌ๋ ์ด๋ฆ์ label ํต์์ ์ฐพ์ง ์๋๋ค')
|
|
160
|
-
assert.ok(source.includes("'figure.text.drive-'"), '๊ตฌ๋ ์ค๋ช
์ text ํต์์ ์ฐพ์ง ์๋๋ค')
|
|
161
158
|
assert.ok(source.includes("'figure.label.path-' + path"), '๊ฒฝ๋ก ์ด๋ฆ์ label ํต์์ ์ฐพ์ง ์๋๋ค')
|
|
162
159
|
assert.ok(source.includes("'figure.text.path-' + channel.path + '-unit'"), '๋จ์ ์ค๋ช
์ text ํต์์ ์ฐพ์ง ์๋๋ค')
|
|
163
160
|
})
|