@things-factory/figure-service 10.1.278 → 10.1.279

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.
Files changed (149) hide show
  1. package/package.json +23 -8
  2. package/coverage/clover.xml +0 -6
  3. package/coverage/coverage-final.json +0 -1
  4. package/coverage/lcov-report/base.css +0 -224
  5. package/coverage/lcov-report/block-navigation.js +0 -87
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +0 -101
  8. package/coverage/lcov-report/prettify.css +0 -1
  9. package/coverage/lcov-report/prettify.js +0 -2
  10. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  11. package/coverage/lcov-report/sorter.js +0 -210
  12. package/coverage/lcov.info +0 -0
  13. package/dist-server/index.js.map +0 -1
  14. package/dist-server/migrations/index.js.map +0 -1
  15. package/dist-server/routers/figure-mesh-router.js.map +0 -1
  16. package/dist-server/routers/figure-package-router.js.map +0 -1
  17. package/dist-server/routers/figure-thumbnail-router.js.map +0 -1
  18. package/dist-server/routes.js.map +0 -1
  19. package/dist-server/service/figure/event-subscriber.js.map +0 -1
  20. package/dist-server/service/figure/figure-ai-scenarios-run.js.map +0 -1
  21. package/dist-server/service/figure/figure-ai-scenarios.js.map +0 -1
  22. package/dist-server/service/figure/figure-categories.js.map +0 -1
  23. package/dist-server/service/figure/figure-context.js.map +0 -1
  24. package/dist-server/service/figure/figure-format.js.map +0 -1
  25. package/dist-server/service/figure/figure-glb.js.map +0 -1
  26. package/dist-server/service/figure/figure-history.js.map +0 -1
  27. package/dist-server/service/figure/figure-llm-provider.js.map +0 -1
  28. package/dist-server/service/figure/figure-mesh-store.js.map +0 -1
  29. package/dist-server/service/figure/figure-mutation.js.map +0 -1
  30. package/dist-server/service/figure/figure-namespace-entity.js.map +0 -1
  31. package/dist-server/service/figure/figure-namespace-resolver.js.map +0 -1
  32. package/dist-server/service/figure/figure-namespace.js.map +0 -1
  33. package/dist-server/service/figure/figure-package-export.js.map +0 -1
  34. package/dist-server/service/figure/figure-proposal-record.js.map +0 -1
  35. package/dist-server/service/figure/figure-proposal.js.map +0 -1
  36. package/dist-server/service/figure/figure-propose-steps.js.map +0 -1
  37. package/dist-server/service/figure/figure-propose-type.js.map +0 -1
  38. package/dist-server/service/figure/figure-public.js.map +0 -1
  39. package/dist-server/service/figure/figure-query.js.map +0 -1
  40. package/dist-server/service/figure/figure-rename.js.map +0 -1
  41. package/dist-server/service/figure/figure-replaced-draft.js.map +0 -1
  42. package/dist-server/service/figure/figure-revert.js.map +0 -1
  43. package/dist-server/service/figure/figure-subject.js.map +0 -1
  44. package/dist-server/service/figure/figure-thumbnail-reader.js.map +0 -1
  45. package/dist-server/service/figure/figure-thumbnail-store.js.map +0 -1
  46. package/dist-server/service/figure/figure-thumbnail-upgrade.js.map +0 -1
  47. package/dist-server/service/figure/figure-tools.js.map +0 -1
  48. package/dist-server/service/figure/figure-type.js.map +0 -1
  49. package/dist-server/service/figure/figure-write.js.map +0 -1
  50. package/dist-server/service/figure/figure.js.map +0 -1
  51. package/dist-server/service/figure/index.js.map +0 -1
  52. package/dist-server/service/figure-recipe/figure-recipe-resolver.js.map +0 -1
  53. package/dist-server/service/figure-recipe/figure-recipe-templates.js.map +0 -1
  54. package/dist-server/service/figure-recipe/figure-recipe-type.js.map +0 -1
  55. package/dist-server/service/figure-recipe/index.js.map +0 -1
  56. package/dist-server/service/index.js.map +0 -1
  57. package/dist-server/tsconfig.tsbuildinfo +0 -1
  58. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -15
  59. package/logs/application-2026-09-14-23.log +0 -0
  60. package/logs/figure-ai-scenarios/2026-11-03T09-31-35-151Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -1167
  61. package/logs/figure-ai-scenarios/2026-11-03T09-39-05-265Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -904
  62. package/logs/figure-ai-scenarios/2026-11-03T09-41-49-107Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -1629
  63. package/logs/figure-ai-scenarios/2026-11-03T09-58-26-681Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -4412
  64. package/logs/figure-ai-scenarios/2026-11-03T10-16-46-212Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -4513
  65. package/logs/figure-ai-scenarios/2026-11-03T10-21-07-872Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -4202
  66. package/logs/figure-ai-scenarios/2026-11-03T10-25-21-721Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -1665
  67. package/logs/figure-ai-scenarios/2026-11-09T01-28-51-664Z-agent_hatiolab_ChatGPT-openai-gpt-5.4-mini.json +0 -4484
  68. package/scripts/build-templates.mts +0 -64
  69. package/scripts/figure-ai-scenarios-agent.cjs +0 -98
  70. package/scripts/rename-figures-to-full-names.mjs +0 -211
  71. package/scripts/templates.test.mts +0 -112
  72. package/server/index.ts +0 -46
  73. package/server/migrations/index.ts +0 -9
  74. package/server/routers/figure-mesh-router.ts +0 -63
  75. package/server/routers/figure-package-router.ts +0 -53
  76. package/server/routers/figure-thumbnail-router.ts +0 -159
  77. package/server/routes.ts +0 -30
  78. package/server/service/figure/catalog-db.test.ts +0 -162
  79. package/server/service/figure/event-subscriber.ts +0 -66
  80. package/server/service/figure/figure-ai-scenarios-run.ts +0 -127
  81. package/server/service/figure/figure-ai-scenarios.live.test.ts +0 -59
  82. package/server/service/figure/figure-ai-scenarios.test.ts +0 -109
  83. package/server/service/figure/figure-ai-scenarios.ts +0 -798
  84. package/server/service/figure/figure-blueprint-query.test.ts +0 -536
  85. package/server/service/figure/figure-catalog-seen-db.test.ts +0 -153
  86. package/server/service/figure/figure-categories.ts +0 -50
  87. package/server/service/figure/figure-category-db.test.ts +0 -127
  88. package/server/service/figure/figure-context.test.ts +0 -402
  89. package/server/service/figure/figure-context.ts +0 -510
  90. package/server/service/figure/figure-deprecation-db.test.ts +0 -218
  91. package/server/service/figure/figure-format.test.ts +0 -423
  92. package/server/service/figure/figure-format.ts +0 -783
  93. package/server/service/figure/figure-glb.test.ts +0 -112
  94. package/server/service/figure/figure-glb.ts +0 -251
  95. package/server/service/figure/figure-history.ts +0 -192
  96. package/server/service/figure/figure-inspect-db.test.ts +0 -131
  97. package/server/service/figure/figure-llm-provider.ts +0 -20
  98. package/server/service/figure/figure-llm-smoke.test.ts +0 -95
  99. package/server/service/figure/figure-mesh-db.test.ts +0 -246
  100. package/server/service/figure/figure-mesh-store.ts +0 -91
  101. package/server/service/figure/figure-mutation.ts +0 -656
  102. package/server/service/figure/figure-namespace-db.test.ts +0 -315
  103. package/server/service/figure/figure-namespace-entity.ts +0 -67
  104. package/server/service/figure/figure-namespace-resolver.ts +0 -54
  105. package/server/service/figure/figure-namespace.ts +0 -156
  106. package/server/service/figure/figure-package-export.ts +0 -136
  107. package/server/service/figure/figure-proposal-db.test.ts +0 -117
  108. package/server/service/figure/figure-proposal-record.ts +0 -38
  109. package/server/service/figure/figure-proposal.ts +0 -41
  110. package/server/service/figure/figure-propose-clips.test.ts +0 -69
  111. package/server/service/figure/figure-propose-steps.test.ts +0 -324
  112. package/server/service/figure/figure-propose-steps.ts +0 -354
  113. package/server/service/figure/figure-propose-type.ts +0 -46
  114. package/server/service/figure/figure-public-db.test.ts +0 -288
  115. package/server/service/figure/figure-public.ts +0 -60
  116. package/server/service/figure/figure-query.ts +0 -511
  117. package/server/service/figure/figure-release-check.test.ts +0 -63
  118. package/server/service/figure/figure-release-record-db.test.ts +0 -153
  119. package/server/service/figure/figure-release-size-db.test.ts +0 -156
  120. package/server/service/figure/figure-rename-db.test.ts +0 -237
  121. package/server/service/figure/figure-rename.test.ts +0 -117
  122. package/server/service/figure/figure-rename.ts +0 -143
  123. package/server/service/figure/figure-replaced-draft.ts +0 -99
  124. package/server/service/figure/figure-revert-db.test.ts +0 -163
  125. package/server/service/figure/figure-revert-race.pg.test.ts +0 -168
  126. package/server/service/figure/figure-revert.ts +0 -186
  127. package/server/service/figure/figure-subject.test.ts +0 -41
  128. package/server/service/figure/figure-subject.ts +0 -21
  129. package/server/service/figure/figure-thumbnail-db.test.ts +0 -279
  130. package/server/service/figure/figure-thumbnail-reader.ts +0 -20
  131. package/server/service/figure/figure-thumbnail-store.ts +0 -111
  132. package/server/service/figure/figure-thumbnail-upgrade.pg.test.ts +0 -93
  133. package/server/service/figure/figure-thumbnail-upgrade.ts +0 -70
  134. package/server/service/figure/figure-tool-doors.test.ts +0 -127
  135. package/server/service/figure/figure-tools-door-db.test.ts +0 -227
  136. package/server/service/figure/figure-tools.test.ts +0 -817
  137. package/server/service/figure/figure-tools.ts +0 -611
  138. package/server/service/figure/figure-type.ts +0 -241
  139. package/server/service/figure/figure-write.test.ts +0 -15
  140. package/server/service/figure/figure-write.ts +0 -131
  141. package/server/service/figure/figure.ts +0 -241
  142. package/server/service/figure/index.ts +0 -13
  143. package/server/service/figure-recipe/figure-recipe-resolver.ts +0 -38
  144. package/server/service/figure-recipe/figure-recipe-templates.test.ts +0 -47
  145. package/server/service/figure-recipe/figure-recipe-templates.ts +0 -70
  146. package/server/service/figure-recipe/figure-recipe-type.ts +0 -31
  147. package/server/service/figure-recipe/index.ts +0 -3
  148. package/server/service/index.ts +0 -34
  149. package/tsconfig.json +0 -14
@@ -1,798 +0,0 @@
1
- /**
2
- * AI 모델링 시나리오 — what a person asks the figure AI for, and what the figure must then be (2026-11-03, 사용자 「여러가지
3
- * 모델링 시나리오를 구성해서 AI를 통한 모델링이 잘 구현되는지 지속적으로 점검할 수 있도록 하라」).
4
- *
5
- * Each scenario is a request in a person's words, the draft it is asked on (none for a new figure), and a check that
6
- * says what the figure that came back misses -- read from the figure by the kernel (its parts' shapes, fastenings,
7
- * motion, clips, data), never from the steps the model wrote, so any way of making it that the kernel takes passes.
8
- * Each also holds a reference answer the check must pass and a wrong one it must fail: the checks are themselves held to
9
- * known verdicts without a provider (figure-ai-scenarios.test.ts). The live run (figure-ai-scenarios.live.test.ts) asks a
10
- * real model for each and writes a report to compare runs by.
11
- *
12
- * The scenarios are spread over what the kernel can say (ADR-0100 shapes and §16's taper and pipe, ADR-0093 fastenings,
13
- * ADR-0159 joints, repeats, clips, the figure's size, data bindings, mirrored chains), new figures and revisions both.
14
- */
15
- import {
16
- applyFigureProposal,
17
- compileFigureAsset,
18
- createFigureAsset,
19
- figureOccupiedBoxesOf,
20
- figureShapeBoundsOf,
21
- figureShapeDescriptionOf,
22
- figureSweepSectionAt,
23
- figureWritersOf,
24
- type FigureAsset
25
- } from '@hatiolab/figure-model'
26
-
27
- type Dynamic = any
28
- type Axis = 'x' | 'y' | 'z'
29
-
30
- export interface FigureAIScenario {
31
- id: string
32
- /** What it checks, in a few words. */
33
- title: string
34
- /** The parts of the kernel it reaches: what a failure points at. */
35
- covers: string[]
36
- /** The request, as a person types it. */
37
- prompt: string
38
- /** The draft it is asked on; absent, a new figure named `name`. */
39
- base?: () => FigureAsset
40
- name?: string
41
- /** What the figure that came back misses; empty when it is what was asked. `before` is the draft, for a revision. */
42
- check: (after: FigureAsset, before?: FigureAsset) => string[]
43
- /** An answer the check must pass, and one the kernel takes that the check must fail. */
44
- reference: unknown[]
45
- wrong: unknown[]
46
- }
47
-
48
- /* ── What a figure is, read by the kernel ─────────────────────────────────────────────── */
49
-
50
- export interface ScenarioPart {
51
- id: string
52
- /** The shape's kind, as figure-model describes it: rectangle, ellipse, taper, tapered, sweep … */
53
- kind: string
54
- /** Where it stands in the figure, at its default size and pose: its box's centre and extent. */
55
- centre: Record<Axis, number>
56
- extent: Record<Axis, number>
57
- colour: string
58
- /** What it is fastened to: a part, the plane, or nothing. */
59
- on?: string
60
- /** Its joint's axes' types, in order; none for a fastening. */
61
- motion: string[]
62
- /** Its joint's controls, by axis. */
63
- controls: string[]
64
- limits: Array<{ lower?: number; upper?: number }>
65
- /** How many copies its row makes; 1 for a part not in a row. */
66
- copies: number
67
- shape: Dynamic
68
- node: Dynamic
69
- }
70
-
71
- /** Every part of a figure, as the kernel evaluates it. */
72
- export function scenarioPartsOf(asset: FigureAsset): ScenarioPart[] {
73
- const geometry = compileFigureAsset(asset).evaluate().geometry as Dynamic[]
74
- const boxes = figureOccupiedBoxesOf(geometry as never, figureWritersOf(asset))
75
- const nodes = (asset.document.model as Dynamic).nodes as Dynamic[]
76
- const joints = ((asset as Dynamic).joints ?? []) as Dynamic[]
77
- return asset.appearance.map((look: Dynamic) => {
78
- const id = look.target as string
79
- const node = nodes.find(n => n.id === `${id}.shape`)
80
- const joint = joints.find(j => j.body1?.part === id)
81
- const box = boxes.find(b => b.part === id)
82
- const body = geometry.find(g => g.id === id)
83
- const motion = (joint?.motion ?? []) as Dynamic[]
84
- return {
85
- id,
86
- kind: figureShapeDescriptionOf(node, asset.document.model as never)?.kind ?? String(node?.op ?? ''),
87
- centre: { x: box?.centre.x ?? 0, y: box?.centre.y ?? 0, z: box?.centre.z ?? 0 },
88
- extent: { x: box?.extent.x ?? 0, y: box?.extent.y ?? 0, z: box?.extent.z ?? 0 },
89
- colour: String((asset.palette as Dynamic)?.[look.material?.token] ?? look.material?.token ?? '').toLowerCase(),
90
- ...(joint ? { on: joint.body0?.part ?? 'mounting-plane' } : {}),
91
- motion: motion.map(m => m.type),
92
- controls: motion.map((m, i) => m.state?.id ?? m.id ?? (i ? `${joint.id}.${i}` : joint.id)),
93
- limits: motion.map(m => ({ lower: m.lowerLimit, upper: m.upperLimit })),
94
- /* The kernel's own reading of which part a body was placed by: a row's copies are named `["<part>.repeat", i, …]`. */
95
- copies: boxes.filter(b => b.part === id).length || 1,
96
- shape: body?.shape,
97
- node
98
- }
99
- })
100
- }
101
-
102
- const near = (a: number, b: number, tol = 0.5) => Math.abs(a - b) <= tol
103
- const bottom = (p: ScenarioPart) => p.centre.y - p.extent.y / 2
104
- const top = (p: ScenarioPart) => p.centre.y + p.extent.y / 2
105
-
106
- /** Every part fastened to something: the plane, or another part (each part fastened once, as the grammar teaches). */
107
- function loose(parts: ScenarioPart[]): string[] {
108
- return parts.filter(p => !p.on).map(p => `${p.id} is fastened to nothing`)
109
- }
110
-
111
- /** A clip that plays one of `controls`. */
112
- const clipsPlaying = (asset: FigureAsset, controls: string[]) => ((asset as Dynamic).drivers ?? []).filter((d: Dynamic) => controls.includes(d.state))
113
-
114
- const steps = (list: unknown[]) => list
115
-
116
- /* ── The drafts revisions are asked on ────────────────────────────────────────────────── */
117
-
118
- /** A mixer: a body standing on the floor, a port fastened to its front. */
119
- export function mixerDraft(): FigureAsset {
120
- return applyFigureProposal(createFigureAsset('Mixer'), [
121
- { kind: 'add-part', part: { id: 'body', kind: 'cylinder', dimensions: { radius: 140, length: 320 } } },
122
- { kind: 'add-part', part: { id: 'port', kind: 'box', dimensions: { width: 80, height: 60, depth: 30 } } },
123
- { kind: 'attach', part: 'body', to: { plane: 'mounting-plane' } },
124
- /* The body's front is its curved side: a point on it, by the outward normal there (ADR-0140 3.9; push Y, +Z is 270°). */
125
- { kind: 'attach', part: 'port', to: { part: 'body', surface: { around: 270, along: 'centre' } } },
126
- { kind: 'set-placement', placement: 'floor' }
127
- ] as never)
128
- }
129
-
130
- /**
131
- * What "make the port twice as wide and give it an accent colour" asks of the mixer, said as what is missing: the port
132
- * twice as wide (X), its height and depth kept, a colour it did not have, and the body left as it was.
133
- */
134
- export function portRevisionMisses(before: FigureAsset, after: FigureAsset): string[] {
135
- const was = Object.fromEntries(scenarioPartsOf(before).map(p => [p.id, p]))
136
- const now = Object.fromEntries(scenarioPartsOf(after).map(p => [p.id, p]))
137
- const misses: string[] = []
138
- if (!now.port) return ['the port is gone']
139
- const size = (p: ScenarioPart) => figureShapeBoundsOf(p.shape)
140
- const extentOf = (p: ScenarioPart, axis: Axis) => size(p)[axis].max - size(p)[axis].min
141
- if (!near(extentOf(now.port, 'x'), extentOf(was.port!, 'x') * 2)) misses.push(`port width ${extentOf(now.port, 'x')}, asked ${extentOf(was.port!, 'x') * 2}`)
142
- for (const axis of ['y', 'z'] as const) if (!near(extentOf(now.port, axis), extentOf(was.port!, axis))) misses.push(`port ${axis} changed to ${extentOf(now.port, axis)}`)
143
- if (now.port.colour === was.port!.colour) misses.push(`port colour still ${was.port!.colour}`)
144
- if (!now.body) misses.push('the body is gone')
145
- else for (const axis of ['x', 'y', 'z'] as const) if (!near(extentOf(now.body, axis), extentOf(was.body!, axis))) misses.push(`body ${axis} changed to ${extentOf(now.body, axis)}`)
146
- if (now.body && now.body.colour !== was.body!.colour) misses.push(`body colour changed to ${now.body.colour}`)
147
- return misses
148
- }
149
-
150
- /** An elbow: up from the floor, a quarter bend toward +X, along. */
151
- function elbowDraft(): FigureAsset {
152
- return applyFigureProposal(createFigureAsset('Elbow'), [
153
- { kind: 'add-part', part: { id: 'pipe', kind: 'pipe', dimensions: { radius: 40, wall: 4 }, path: [{ line: 500 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 400 }] } },
154
- { kind: 'attach', part: 'pipe', to: { plane: 'mounting-plane' } }
155
- ] as never)
156
- }
157
-
158
- /** A plain box standing on the floor. */
159
- function boxDraft(): FigureAsset {
160
- return applyFigureProposal(createFigureAsset('Bin'), [
161
- { kind: 'add-part', part: { id: 'bin', kind: 'box', dimensions: { width: 600, height: 300, depth: 400 } } },
162
- { kind: 'attach', part: 'bin', to: { plane: 'mounting-plane' } }
163
- ] as never)
164
- }
165
-
166
- /** A table: a top on four legs. */
167
- function tableDraft(): FigureAsset {
168
- return applyFigureProposal(createFigureAsset('Table'), [
169
- { kind: 'add-part', part: { id: 'top', kind: 'box', dimensions: { width: 1200, height: 40, depth: 700 } } },
170
- { kind: 'add-part', part: { id: 'leg', kind: 'box', dimensions: { width: 50, height: 700, depth: 50 } } },
171
- { kind: 'attach', part: 'leg', to: { plane: 'mounting-plane' } },
172
- { kind: 'attach', part: 'top', to: { part: 'leg', face: 'top' } }
173
- ] as never)
174
- }
175
-
176
- /** A cabinet with a lamp on its top. */
177
- function lampDraft(): FigureAsset {
178
- return applyFigureProposal(createFigureAsset('Cabinet'), [
179
- { kind: 'add-part', part: { id: 'cabinet', kind: 'box', dimensions: { width: 600, height: 1200, depth: 500 } } },
180
- { kind: 'add-part', part: { id: 'lamp', kind: 'cylinder', dimensions: { radius: 40, length: 80 } } },
181
- { kind: 'attach', part: 'cabinet', to: { plane: 'mounting-plane' } },
182
- { kind: 'attach', part: 'lamp', to: { part: 'cabinet', face: 'top' } }
183
- ] as never)
184
- }
185
-
186
- /* ── The scenarios ────────────────────────────────────────────────────────────────────── */
187
-
188
- const accent = (target: string, colour: string, token = 'palette.accent') => ({ kind: 'set-material', target, material: { token }, palette: { [token]: colour } })
189
-
190
- export const FIGURE_AI_SCENARIOS: FigureAIScenario[] = [
191
- {
192
- id: 'roll-press',
193
- title: '새 피규어: 프레임 안 두 롤러, 서로 다른 색',
194
- covers: ['add-part cylinder', 'attach', 'set-material'],
195
- prompt: 'two cylindrical rollers inside a simple rectangular press frame; make the rollers visually distinct',
196
- name: 'Roll press',
197
- /*
198
- Two rollers -- two parts, or one repeated in a row -- that stand out: a colour the frame does not have. Read so after
199
- a model's row of two was failed for being one part (2026-11-03, the first runs).
200
- */
201
- check: after => {
202
- const parts = scenarioPartsOf(after)
203
- const rollers = parts.filter(p => p.kind === 'ellipse')
204
- const frame = parts.filter(p => p.kind !== 'ellipse')
205
- const misses = [...loose(parts)]
206
- const drawn = rollers.reduce((sum, r) => sum + r.copies, 0)
207
- if (drawn < 2) misses.push(`${drawn} round bodies drawn, two rollers asked`)
208
- if (!frame.length) misses.push('no frame')
209
- else if (rollers.length && rollers.every(r => frame.some(f => f.colour === r.colour))) misses.push(`the rollers are the frame's colour, ${rollers[0]!.colour}`)
210
- return misses
211
- },
212
- reference: steps([
213
- { kind: 'add-part', part: { id: 'base', kind: 'box', dimensions: { width: 1000, height: 80, depth: 500 } } },
214
- { kind: 'add-part', part: { id: 'roller-a', kind: 'cylinder', dimensions: { radius: 80, length: 400 } } },
215
- { kind: 'add-part', part: { id: 'roller-b', kind: 'cylinder', dimensions: { radius: 80, length: 400 } } },
216
- { kind: 'attach', part: 'base', to: { plane: 'mounting-plane' } },
217
- { kind: 'attach', part: 'roller-a', to: { part: 'base', face: 'top' }, align: { x: { mm: -200 } } },
218
- { kind: 'attach', part: 'roller-b', to: { part: 'base', face: 'top' }, align: { x: { mm: 200 } } },
219
- accent('roller-b', '#d08a2c')
220
- ]),
221
- wrong: steps([
222
- { kind: 'add-part', part: { id: 'base', kind: 'box', dimensions: { width: 1000, height: 80, depth: 500 } } },
223
- { kind: 'add-part', part: { id: 'roller-a', kind: 'cylinder', dimensions: { radius: 80, length: 400 } } },
224
- { kind: 'add-part', part: { id: 'roller-b', kind: 'cylinder', dimensions: { radius: 80, length: 400 } } },
225
- { kind: 'attach', part: 'base', to: { plane: 'mounting-plane' } },
226
- { kind: 'attach', part: 'roller-a', to: { part: 'base', face: 'top' }, align: { x: { mm: -200 } } },
227
- { kind: 'attach', part: 'roller-b', to: { part: 'base', face: 'top' }, align: { x: { mm: 200 } } },
228
- /* Rollers drawn in the frame's own colour: nothing stands out. */
229
- accent('roller-a', '#477b9e', 'palette.primary'),
230
- accent('roller-b', '#477b9e', 'palette.primary'),
231
- accent('base', '#477b9e', 'palette.primary')
232
- ])
233
- },
234
- {
235
- id: 'lift-table',
236
- title: '새 피규어: 받침 · 기둥 · 상판을 쌓기',
237
- covers: ['attach part face', 'stacking'],
238
- prompt: '리프트 테이블: 바닥에 넓은 받침, 그 위에 원기둥 기둥, 기둥 위에 받침만 한 상판',
239
- name: 'Lift table',
240
- check: after => {
241
- const parts = scenarioPartsOf(after)
242
- const misses = [...loose(parts)]
243
- if (parts.length < 3) return [...misses, `${parts.length} parts, three asked`]
244
- const sorted = [...parts].sort((a, b) => top(b) - top(a))
245
- const [highest] = sorted
246
- const column = parts.find(p => p.kind === 'ellipse')
247
- if (!column) misses.push('no round column')
248
- else {
249
- if (!(highest!.extent.x * highest!.extent.z > column.extent.x * column.extent.z)) misses.push('the top is not wider than the column')
250
- if (!parts.some(p => p !== column && near(bottom(column), top(p), 1))) misses.push('the column does not stand on another part')
251
- if (!near(bottom(highest!), top(column), 1)) misses.push('the top does not sit on the column')
252
- }
253
- if (!parts.some(p => near(bottom(p), 0, 1))) misses.push('nothing stands on the floor')
254
- return misses
255
- },
256
- reference: steps([
257
- { kind: 'add-part', part: { id: 'base', kind: 'box', dimensions: { width: 1200, height: 80, depth: 800 } } },
258
- { kind: 'add-part', part: { id: 'column', kind: 'cylinder', dimensions: { radius: 90, length: 600 } } },
259
- { kind: 'add-part', part: { id: 'top', kind: 'box', dimensions: { width: 1200, height: 60, depth: 800 } } },
260
- { kind: 'attach', part: 'base', to: { plane: 'mounting-plane' } },
261
- { kind: 'attach', part: 'column', to: { part: 'base', face: 'top' } },
262
- { kind: 'attach', part: 'top', to: { part: 'column', face: 'top' } }
263
- ]),
264
- wrong: steps([
265
- { kind: 'add-part', part: { id: 'base', kind: 'box', dimensions: { width: 1200, height: 80, depth: 800 } } },
266
- { kind: 'add-part', part: { id: 'column', kind: 'cylinder', dimensions: { radius: 90, length: 600 } } },
267
- { kind: 'add-part', part: { id: 'top', kind: 'box', dimensions: { width: 1200, height: 60, depth: 800 } } },
268
- { kind: 'attach', part: 'base', to: { plane: 'mounting-plane' } },
269
- { kind: 'attach', part: 'column', to: { part: 'base', face: 'top' } },
270
- { kind: 'attach', part: 'top', to: { part: 'base', face: 'top' } }
271
- ])
272
- },
273
- {
274
- id: 'elbow-flange',
275
- title: '새 피규어: 엘보 배관과 끝의 플랜지 (ADR-0100 §16.2)',
276
- covers: ['add-part pipe', 'bend', 'attach to a pipe end'],
277
- prompt: '바닥에서 위로 올라가다 90도 꺾여 옆으로 가는 지름 80 배관, 배관 끝에 원판 플랜지',
278
- name: 'Elbow',
279
- check: after => {
280
- const parts = scenarioPartsOf(after)
281
- const misses = [...loose(parts)]
282
- const pipe = parts.find(p => p.kind === 'sweep')
283
- if (!pipe) return [...misses, 'no part along a path (a pipe)']
284
- if (!pipe.shape?.sweep?.path?.some((s: Dynamic) => s.kind === 'bend')) misses.push('the pipe has no bend')
285
- if (!parts.some(p => p.on === pipe.id)) misses.push('nothing is fastened to the pipe')
286
- return misses
287
- },
288
- reference: steps([
289
- { kind: 'add-part', part: { id: 'pipe', kind: 'pipe', dimensions: { radius: 40, wall: 4 }, path: [{ line: 500 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 400 }] } },
290
- { kind: 'attach', part: 'pipe', to: { plane: 'mounting-plane' } },
291
- { kind: 'add-part', part: { id: 'flange', kind: 'cylinder', dimensions: { radius: 70, length: 20 } } },
292
- { kind: 'attach', part: 'flange', to: { part: 'pipe', face: 'right' } }
293
- ]),
294
- wrong: steps([
295
- { kind: 'add-part', part: { id: 'pipe', kind: 'pipe', dimensions: { radius: 40, wall: 4 }, path: [{ line: 500 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 400 }] } },
296
- { kind: 'attach', part: 'pipe', to: { plane: 'mounting-plane' } },
297
- { kind: 'add-part', part: { id: 'flange', kind: 'cylinder', dimensions: { radius: 70, length: 20 } } },
298
- { kind: 'attach', part: 'flange', to: { plane: 'mounting-plane' } }
299
- ])
300
- },
301
- {
302
- id: 'conveyor',
303
- title: '새 피규어: 프레임 위 롤러를 반복으로',
304
- covers: ['make-repeat'],
305
- prompt: 'a roller conveyor: a 2 m long frame with rollers repeated along its length every 150 mm',
306
- name: 'Conveyor',
307
- check: after => {
308
- const parts = scenarioPartsOf(after)
309
- const misses = [...loose(parts)]
310
- const rows = ((after as Dynamic).joints ?? []).filter((j: Dynamic) => j.repeat)
311
- if (!rows.length) misses.push('no part repeated in a row')
312
- const geometry = compileFigureAsset(after).evaluate().geometry as Dynamic[]
313
- if (geometry.length < 8) misses.push(`${geometry.length} bodies drawn, a row of rollers asked`)
314
- const longest = Math.max(...parts.map(p => Math.max(p.extent.x, p.extent.z)))
315
- if (longest < 1500) misses.push(`the longest part is ${Math.round(longest)} mm, a 2 m frame asked`)
316
- return misses
317
- },
318
- reference: steps([
319
- { kind: 'add-part', part: { id: 'frame', kind: 'box', dimensions: { width: 2000, height: 100, depth: 500 } } },
320
- { kind: 'add-part', part: { id: 'roller', kind: 'cylinder', dimensions: { radius: 30, length: 480 } } },
321
- { kind: 'attach', part: 'frame', to: { plane: 'mounting-plane' } },
322
- { kind: 'attach', part: 'roller', to: { part: 'frame', face: 'top' } },
323
- { kind: 'make-repeat', part: 'roller', axis: 'x', pitch: 150 }
324
- ]),
325
- wrong: steps([
326
- { kind: 'add-part', part: { id: 'frame', kind: 'box', dimensions: { width: 2000, height: 100, depth: 500 } } },
327
- { kind: 'add-part', part: { id: 'roller', kind: 'cylinder', dimensions: { radius: 30, length: 480 } } },
328
- { kind: 'attach', part: 'frame', to: { plane: 'mounting-plane' } },
329
- { kind: 'attach', part: 'roller', to: { part: 'frame', face: 'top' } }
330
- ])
331
- },
332
- {
333
- id: 'two-joint-arm',
334
- title: '새 피규어: 두 관절로 도는 팔',
335
- covers: ['set-joint revolute', 'a joint on a moving part'],
336
- prompt: '바닥 받침 위에 아래팔과 위팔이 있고, 받침-아래팔, 아래팔-위팔이 각각 회전 관절인 로봇 팔',
337
- name: 'Arm',
338
- check: after => {
339
- const parts = scenarioPartsOf(after)
340
- const misses = [...loose(parts)]
341
- const turning = parts.filter(p => p.motion.includes('revolute'))
342
- if (turning.length < 2) misses.push(`${turning.length} turning joints, two asked`)
343
- else if (!turning.some(p => turning.some(q => q.id === p.on))) misses.push('no turning part hangs from another turning part')
344
- return misses
345
- },
346
- reference: steps([
347
- { kind: 'add-part', part: { id: 'base', kind: 'cylinder', dimensions: { radius: 150, length: 100 } } },
348
- { kind: 'add-part', part: { id: 'lower-arm', kind: 'box', dimensions: { width: 80, height: 500, depth: 80 } } },
349
- { kind: 'add-part', part: { id: 'upper-arm', kind: 'box', dimensions: { width: 60, height: 400, depth: 60 } } },
350
- { kind: 'attach', part: 'base', to: { plane: 'mounting-plane' } },
351
- { kind: 'set-joint', joint: { id: 'shoulder', body0: { part: 'base', face: 'top' }, body1: { part: 'lower-arm' }, motion: [{ type: 'revolute', axis: 'Z', lowerLimit: -90, upperLimit: 90 }] } },
352
- { kind: 'set-joint', joint: { id: 'elbow', body0: { part: 'lower-arm', face: 'top' }, body1: { part: 'upper-arm' }, motion: [{ type: 'revolute', axis: 'Z', lowerLimit: -120, upperLimit: 120 }] } }
353
- ]),
354
- wrong: steps([
355
- { kind: 'add-part', part: { id: 'base', kind: 'cylinder', dimensions: { radius: 150, length: 100 } } },
356
- { kind: 'add-part', part: { id: 'lower-arm', kind: 'box', dimensions: { width: 80, height: 500, depth: 80 } } },
357
- { kind: 'add-part', part: { id: 'upper-arm', kind: 'box', dimensions: { width: 60, height: 400, depth: 60 } } },
358
- { kind: 'attach', part: 'base', to: { plane: 'mounting-plane' } },
359
- { kind: 'set-joint', joint: { id: 'shoulder', body0: { part: 'base', face: 'top' }, body1: { part: 'lower-arm' }, motion: [{ type: 'revolute', axis: 'Z', lowerLimit: -90, upperLimit: 90 }] } },
360
- { kind: 'attach', part: 'upper-arm', to: { part: 'lower-arm', face: 'top' } }
361
- ])
362
- },
363
- {
364
- id: 'cabinet-door',
365
- title: '새 피규어: 경첩 문 0~90°와 여는 클립',
366
- covers: ['set-joint limits', 'set-driver clip'],
367
- prompt: 'a cabinet with one door on a hinge that opens from 0 to 90 degrees, and a clip that opens it in 2 seconds',
368
- name: 'Cabinet',
369
- check: after => {
370
- const parts = scenarioPartsOf(after)
371
- const misses = [...loose(parts)]
372
- const door = parts.find(p => p.motion.includes('revolute'))
373
- if (!door) return [...misses, 'no hinged part']
374
- const span = door.limits.map(l => (l.upper ?? Infinity) - (l.lower ?? -Infinity))[0]!
375
- if (!(span >= 80 && span <= 100)) misses.push(`the hinge turns ${span}°, 0 to 90 asked`)
376
- if (!clipsPlaying(after, door.controls).length) misses.push("no clip plays the door's hinge")
377
- return misses
378
- },
379
- reference: steps([
380
- { kind: 'add-part', part: { id: 'cabinet', kind: 'box', dimensions: { width: 600, height: 1200, depth: 500 } } },
381
- { kind: 'add-part', part: { id: 'door', kind: 'box', dimensions: { width: 600, height: 1200, depth: 20 } } },
382
- { kind: 'attach', part: 'cabinet', to: { plane: 'mounting-plane' } },
383
- { kind: 'set-joint', joint: { id: 'hinge', body0: { part: 'cabinet', face: 'front' }, body1: { part: 'door' }, origin: { align: { x: 'min' } }, motion: [{ type: 'revolute', axis: 'Y', lowerLimit: 0, upperLimit: 90, state: { id: 'door-open' } }] } },
384
- { kind: 'set-driver', state: 'door-open', clip: 'open', duration: 2, keys: [{ seconds: 0, value: 0 }, { seconds: 2, value: 90 }], loop: 'hold' }
385
- ]),
386
- wrong: steps([
387
- { kind: 'add-part', part: { id: 'cabinet', kind: 'box', dimensions: { width: 600, height: 1200, depth: 500 } } },
388
- { kind: 'add-part', part: { id: 'door', kind: 'box', dimensions: { width: 600, height: 1200, depth: 20 } } },
389
- { kind: 'attach', part: 'cabinet', to: { plane: 'mounting-plane' } },
390
- { kind: 'set-joint', joint: { id: 'hinge', body0: { part: 'cabinet', face: 'front' }, body1: { part: 'door' }, origin: { align: { x: 'min' } }, motion: [{ type: 'revolute', axis: 'Y', lowerLimit: 0, upperLimit: 90, state: { id: 'door-open' } }] } }
391
- ])
392
- },
393
- {
394
- id: 'hopper',
395
- title: '새 피규어: 윗면이 넓은 사각 호퍼 (ADR-0100 §16.1)',
396
- covers: ['add-part tapered-box'],
397
- prompt: '아래가 좁고 위가 넓은 사각 호퍼: 아랫면 300×300, 윗면 800×800, 높이 600, 모서리는 둥글게',
398
- name: 'Hopper',
399
- check: after => {
400
- const parts = scenarioPartsOf(after)
401
- const misses = [...loose(parts)]
402
- const hopper = parts.find(p => p.kind === 'tapered')
403
- if (!hopper) return [...misses, 'no part whose top is another size than its bottom']
404
- const l = hopper.shape.loft
405
- const [from, to] = [l.section.size, l.to.size]
406
- if (!(to.x > from.x && to.z > from.z)) misses.push(`its top ${to.x}×${to.z} is not wider than its bottom ${from.x}×${from.z}`)
407
- return misses
408
- },
409
- reference: steps([
410
- { kind: 'add-part', part: { id: 'hopper', kind: 'tapered-box', dimensions: { width: 300, depth: 300, height: 600, topWidth: 800, topDepth: 800, round: 30, topRound: 60 } } },
411
- { kind: 'attach', part: 'hopper', to: { plane: 'mounting-plane' } }
412
- ]),
413
- wrong: steps([
414
- { kind: 'add-part', part: { id: 'hopper', kind: 'tapered-box', dimensions: { width: 800, depth: 800, height: 600, topWidth: 300, topDepth: 300, round: 60, topRound: 30 } } },
415
- { kind: 'attach', part: 'hopper', to: { plane: 'mounting-plane' } }
416
- ])
417
- },
418
- {
419
- id: 'quadruped-legs',
420
- title: '새 피규어: 몸통과 좌우 대칭인 다리 넷, 다리마다 무릎',
421
- covers: ['mirror-part chain', 'joints'],
422
- prompt: 'a four-legged robot body: a box body and four legs, each leg a thigh and a shin with a hip and a knee joint; the legs symmetric left and right',
423
- name: 'Quadruped',
424
- check: after => {
425
- const parts = scenarioPartsOf(after)
426
- const misses = [...loose(parts)]
427
- const moving = parts.filter(p => p.motion.length)
428
- if (moving.length < 8) misses.push(`${moving.length} moving parts, four legs of two joints asked`)
429
- /* Left and right: every moving part has its reflection across the body's middle along Z or X. */
430
- const mirrored = (p: ScenarioPart, axis: Axis) => moving.some(q => q !== p && near(q.centre[axis], -p.centre[axis], 1) && (['x', 'y', 'z'] as const).filter(x => x !== axis).every(x => near(q.centre[x], p.centre[x], 1)))
431
- const lonely = moving.filter(p => !mirrored(p, 'z') && !mirrored(p, 'x'))
432
- if (lonely.length) misses.push(`no mirror of ${lonely.map(p => p.id).join(', ')}`)
433
- return misses
434
- },
435
- reference: steps([
436
- { kind: 'add-part', part: { id: 'body', kind: 'box', dimensions: { width: 800, height: 200, depth: 300 } } },
437
- { kind: 'set-placement', placement: 'floor' },
438
- { kind: 'attach', part: 'body', to: { plane: 'mounting-plane' }, gap: 500 },
439
- { kind: 'add-part', part: { id: 'fl-thigh', kind: 'box', dimensions: { width: 60, height: 250, depth: 60 } } },
440
- { kind: 'add-part', part: { id: 'fl-shin', kind: 'box', dimensions: { width: 40, height: 250, depth: 40 } } },
441
- { kind: 'set-joint', joint: { id: 'fl-hip', body0: { part: 'body', face: 'bottom' }, body1: { part: 'fl-thigh' }, origin: { align: { x: 'max', z: 'max' } }, motion: [{ type: 'revolute', axis: 'Z', lowerLimit: -45, upperLimit: 45 }] } },
442
- { kind: 'set-joint', joint: { id: 'fl-knee', body0: { part: 'fl-thigh', face: 'bottom' }, body1: { part: 'fl-shin' }, motion: [{ type: 'revolute', axis: 'Z', lowerLimit: 0, upperLimit: 120 }] } },
443
- { kind: 'mirror-part', target: 'fl-thigh', axis: 'z', chain: true, prefix: { from: 'fl', to: 'fr' } },
444
- { kind: 'mirror-part', target: 'fl-thigh', axis: 'x', chain: true, prefix: { from: 'fl', to: 'bl' }, keepMotion: true },
445
- { kind: 'mirror-part', target: 'fr-thigh', axis: 'x', chain: true, prefix: { from: 'fr', to: 'br' }, keepMotion: true }
446
- ]),
447
- wrong: steps([
448
- { kind: 'add-part', part: { id: 'body', kind: 'box', dimensions: { width: 800, height: 200, depth: 300 } } },
449
- { kind: 'set-placement', placement: 'floor' },
450
- { kind: 'attach', part: 'body', to: { plane: 'mounting-plane' }, gap: 500 },
451
- { kind: 'add-part', part: { id: 'fl-thigh', kind: 'box', dimensions: { width: 60, height: 250, depth: 60 } } },
452
- { kind: 'add-part', part: { id: 'fl-shin', kind: 'box', dimensions: { width: 40, height: 250, depth: 40 } } },
453
- { kind: 'set-joint', joint: { id: 'fl-hip', body0: { part: 'body', face: 'bottom' }, body1: { part: 'fl-thigh' }, origin: { align: { x: 'max', z: 'max' } }, motion: [{ type: 'revolute', axis: 'Z', lowerLimit: -45, upperLimit: 45 }] } },
454
- { kind: 'set-joint', joint: { id: 'fl-knee', body0: { part: 'fl-thigh', face: 'bottom' }, body1: { part: 'fl-shin' }, motion: [{ type: 'revolute', axis: 'Z', lowerLimit: 0, upperLimit: 120 }] } }
455
- ])
456
- },
457
- {
458
- id: 'pipeline-run',
459
- title: '새 피규어: 굽힘 셋 이상인 곡선 배관과 끝 플랜지 (ADR-0100 §16.2)',
460
- covers: ['add-part pipe', 'several bends', 'attach to a pipe end'],
461
- prompt: '펌프에서 탱크로 가는 지름 100 배관: 바닥에서 1m 올라가 옆으로 꺾고, 다시 앞으로 꺾고, 마지막에 다시 옆으로 꺾여 탱크 옆면으로 들어가게. 배관 끝에는 플랜지',
462
- name: 'Pipeline',
463
- check: after => {
464
- const parts = scenarioPartsOf(after)
465
- const misses = [...loose(parts)]
466
- const pipes = parts.filter(p => p.kind === 'sweep')
467
- const bends = pipes.reduce((n, p) => n + (p.shape?.sweep?.path ?? []).filter((s: Dynamic) => s.kind === 'bend').length, 0)
468
- if (!pipes.length) return [...misses, 'no part along a path (a pipe)']
469
- if (bends < 3) misses.push(`${bends} bends, three asked`)
470
- /* A flange on the pipe's far end, up in the air: not on its start, on the floor. */
471
- if (!parts.some(p => pipes.some(q => q.id === p.on) && p.kind !== 'sweep' && bottom(p) > 100)) misses.push('no flange on the end of a pipe')
472
- return misses
473
- },
474
- /* Up Y; toward 90 is +X; heading +X, toward 0 is +Z; heading +Z, toward 180 is +X again -- its end the right face. */
475
- reference: steps([
476
- { kind: 'add-part', part: { id: 'line', kind: 'pipe', dimensions: { radius: 50, wall: 5 }, path: [{ line: 1000 }, { bend: { radius: 150, angle: 90, toward: 90 } }, { line: 800 }, { bend: { radius: 150, angle: 90, toward: 0 } }, { line: 600 }, { bend: { radius: 150, angle: 90, toward: 180 } }, { line: 400 }] } },
477
- { kind: 'attach', part: 'line', to: { plane: 'mounting-plane' } },
478
- { kind: 'add-part', part: { id: 'flange', kind: 'cylinder', dimensions: { radius: 90, length: 20 } } },
479
- { kind: 'attach', part: 'flange', to: { part: 'line', face: 'right' } }
480
- ]),
481
- wrong: steps([
482
- { kind: 'add-part', part: { id: 'line', kind: 'pipe', dimensions: { radius: 50, wall: 5 }, path: [{ line: 1000 }, { bend: { radius: 150, angle: 90, toward: 90 } }, { line: 800 }] } },
483
- { kind: 'attach', part: 'line', to: { plane: 'mounting-plane' } },
484
- { kind: 'add-part', part: { id: 'flange', kind: 'cylinder', dimensions: { radius: 90, length: 20 } } },
485
- { kind: 'attach', part: 'flange', to: { part: 'line', face: 'right' } }
486
- ])
487
- },
488
- {
489
- id: 'pipe-rack',
490
- title: '새 피규어: 나란히 가는 곡선 배관 두 줄',
491
- covers: ['several pipes', 'attach align'],
492
- prompt: 'two parallel pipes side by side, 300 mm apart, each rising 800 mm and bending 90 degrees to run 1 m sideways',
493
- name: 'Pipe rack',
494
- check: after => {
495
- const parts = scenarioPartsOf(after)
496
- const misses = [...loose(parts)]
497
- const bent = parts.filter(p => p.kind === 'sweep' && (p.shape?.sweep?.path ?? []).some((s: Dynamic) => s.kind === 'bend'))
498
- if (bent.length < 2) return [...misses, `${bent.length} bent pipes, two asked`]
499
- const [a, b] = bent
500
- const apart = Math.hypot(a!.centre.x - b!.centre.x, a!.centre.z - b!.centre.z)
501
- if (!(apart > 200 && apart < 400)) misses.push(`the pipes are ${Math.round(apart)} mm apart, 300 asked`)
502
- if (!near(a!.extent.y, b!.extent.y, 1)) misses.push('the pipes rise to different heights')
503
- return misses
504
- },
505
- reference: steps([
506
- { kind: 'add-part', part: { id: 'pipe-a', kind: 'pipe', dimensions: { radius: 40, wall: 4 }, path: [{ line: 800 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 1000 }] } },
507
- { kind: 'add-part', part: { id: 'pipe-b', kind: 'pipe', dimensions: { radius: 40, wall: 4 }, path: [{ line: 800 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 1000 }] } },
508
- { kind: 'attach', part: 'pipe-a', to: { plane: 'mounting-plane' }, align: { z: { mm: -150 } } },
509
- { kind: 'attach', part: 'pipe-b', to: { plane: 'mounting-plane' }, align: { z: { mm: 150 } } }
510
- ]),
511
- wrong: steps([
512
- { kind: 'add-part', part: { id: 'pipe-a', kind: 'pipe', dimensions: { radius: 40, wall: 4 }, path: [{ line: 800 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 1000 }] } },
513
- { kind: 'add-part', part: { id: 'pipe-b', kind: 'pipe', dimensions: { radius: 40, wall: 4 }, path: [{ line: 800 }] } },
514
- { kind: 'attach', part: 'pipe-a', to: { plane: 'mounting-plane' }, align: { z: { mm: -150 } } },
515
- { kind: 'attach', part: 'pipe-b', to: { plane: 'mounting-plane' }, align: { z: { mm: 150 } } }
516
- ])
517
- },
518
- {
519
- id: 'tapering-bent-bar',
520
- title: '새 피규어: 아래는 굵고 위로 갈수록 가는 휜 막대 (ADR-0100 §16.2.9)',
521
- /*
522
- One pipe narrowing along its length (endRadius), or pieces of different sizes fastened end to end: any such making
523
- passes. The check reads only what stands: something bends, and it is thicker at its lowest than at its highest.
524
- */
525
- covers: ['pipe endRadius', 'pipe wall 0', 'pieces of different sizes fastened end to end'],
526
- prompt: '바닥에서 올라가며 한 번 휘어지는 막대. 아래쪽은 지름 80으로 굵고, 위로 갈수록 가늘어져 끝은 지름 40',
527
- name: 'Bent bar',
528
- check: after => {
529
- const parts = scenarioPartsOf(after)
530
- const misses = [...loose(parts)]
531
- if (!parts.some(p => p.kind === 'sweep' && (p.shape?.sweep?.path ?? []).some((s: Dynamic) => s.kind === 'bend'))) misses.push('nothing bends')
532
- /* How thick each part is at each height: a pipe at its stations, its section there; anything else at its bottom and top. */
533
- const across = (section: Dynamic) => 2 * Math.max(...Object.values(section.radius ?? {}).map(Number), ...Object.values(section.size ?? {}).map(v => Number(v) / 2))
534
- const samples = parts.flatMap(p => {
535
- const w = p.shape?.sweep
536
- if (!w) return [{ y: bottom(p), thick: Math.min(p.extent.x, p.extent.z) }, { y: top(p), thick: Math.min(p.extent.x, p.extent.z) }]
537
- const pose = (compileFigureAsset(after).evaluate().geometry as Dynamic[]).find(g => g.id === p.id)?.pose
538
- const y = (q: number[]) => (pose ? pose.r[1][0] * q[0]! + pose.r[1][1] * q[1]! + pose.r[1][2] * q[2]! + pose.t[1] : q[1]!)
539
- return w.stations.map((st: Dynamic) => ({ y: y(st.p), thick: across(figureSweepSectionAt(w, st.t)) }))
540
- })
541
- const low = samples.reduce((a, b) => (b.y < a.y ? b : a))
542
- const high = samples.reduce((a, b) => (b.y > a.y ? b : a))
543
- if (!(low.thick > high.thick + 1)) misses.push(`${Math.round(low.thick)} thick at its lowest, ${Math.round(high.thick)} at its highest: thicker below asked`)
544
- if (parts.some(p => p.shape?.sweep?.wall !== undefined)) misses.push('a bar is hollow')
545
- return misses
546
- },
547
- reference: steps([
548
- { kind: 'add-part', part: { id: 'bar', kind: 'pipe', dimensions: { radius: 40, wall: 0, endRadius: 20 }, path: [{ line: 600 }, { bend: { radius: 200, angle: 60, toward: 90 } }, { line: 300 }] } },
549
- { kind: 'attach', part: 'bar', to: { plane: 'mounting-plane' } }
550
- ]),
551
- wrong: steps([
552
- { kind: 'add-part', part: { id: 'bar', kind: 'pipe', dimensions: { radius: 20, wall: 0, endRadius: 40 }, path: [{ line: 600 }, { bend: { radius: 200, angle: 60, toward: 90 } }, { line: 300 }] } },
553
- { kind: 'attach', part: 'bar', to: { plane: 'mounting-plane' } }
554
- ])
555
- },
556
- {
557
- id: 'pipe-down-into-tank',
558
- title: '새 피규어: 아래로 꺾여 내려가는 배관 끝에 플랜지 (ADR-0100 §16.2.7)',
559
- covers: ['pipe end heading down', 'attach to a pipe end'],
560
- prompt: '바닥에서 1m 올라가 옆으로 800mm 가다가 아래로 꺾여 500mm 내려가는 배관. 내려간 끝에 플랜지를 달아 줘',
561
- name: 'Drop pipe',
562
- check: after => {
563
- const parts = scenarioPartsOf(after)
564
- const misses = [...loose(parts)]
565
- const pipe = parts.find(p => p.kind === 'sweep' && (p.shape.sweep.stations.at(-1).n as number[])[1]! < -0.999)
566
- if (!pipe) return [...misses, 'no pipe ends heading down']
567
- const joints = ((after as Dynamic).joints ?? []) as Dynamic[]
568
- const onEnd = joints.find(j => j.body0?.part === pipe.id && pipe.shape.faces[j.body0.face]?.station === 'last')
569
- if (!onEnd) misses.push("nothing is fastened to the pipe's lower end")
570
- return misses
571
- },
572
- /* Up; toward 90 is +X; heading +X, toward 90 turns it down. Its end, heading down, is its bottom face. */
573
- reference: steps([
574
- { kind: 'add-part', part: { id: 'drop', kind: 'pipe', dimensions: { radius: 50, wall: 5 }, path: [{ line: 1000 }, { bend: { radius: 150, angle: 90, toward: 90 } }, { line: 800 }, { bend: { radius: 150, angle: 90, toward: 90 } }, { line: 500 }] } },
575
- { kind: 'attach', part: 'drop', to: { plane: 'mounting-plane' } },
576
- { kind: 'add-part', part: { id: 'flange', kind: 'cylinder', dimensions: { radius: 90, length: 20 } } },
577
- { kind: 'attach', part: 'flange', to: { part: 'drop', face: 'bottom' } }
578
- ]),
579
- wrong: steps([
580
- { kind: 'add-part', part: { id: 'drop', kind: 'pipe', dimensions: { radius: 50, wall: 5 }, path: [{ line: 1000 }, { bend: { radius: 150, angle: 90, toward: 90 } }, { line: 800 }, { bend: { radius: 150, angle: 90, toward: 90 } }, { line: 500 }] } },
581
- { kind: 'attach', part: 'drop', to: { plane: 'mounting-plane' } },
582
- { kind: 'add-part', part: { id: 'flange', kind: 'cylinder', dimensions: { radius: 90, length: 20 } } },
583
- { kind: 'attach', part: 'flange', to: { plane: 'mounting-plane' } }
584
- ])
585
- },
586
- {
587
- id: 'mixer-port',
588
- title: '고치기: 포트 폭 두 배와 새 색, 몸통은 그대로',
589
- covers: ['set-section across', 'set-material', 'a revision changes only what is asked'],
590
- prompt: 'make the port twice as wide and give it an accent colour',
591
- base: mixerDraft,
592
- check: (after, before) => portRevisionMisses(before!, after),
593
- reference: steps([{ kind: 'set-section', part: 'port', across: { x: 160 } }, accent('port', '#d08a2c')]),
594
- wrong: steps([accent('port', '#d08a2c')])
595
- },
596
- {
597
- id: 'open-tote',
598
- title: '고치기: 상자를 위가 열린 통으로, 벽 10mm',
599
- covers: ['set-cavity'],
600
- prompt: '이 상자를 위가 열린 통으로 만들어 줘. 벽 두께 10mm, 바닥 두께 15mm',
601
- base: boxDraft,
602
- /* Read from the shape the kernel evaluated, not the answer's numbers: other steps can reach the same box. */
603
- check: (after, before) => {
604
- const bin = scenarioPartsOf(after).find(p => p.id === 'bin')
605
- if (!bin) return ['the box is gone']
606
- const was = scenarioPartsOf(before!).find(p => p.id === 'bin')!
607
- const misses: string[] = []
608
- for (const axis of ['x', 'y', 'z'] as const)
609
- if (!near(bin.extent[axis], was.extent[axis])) misses.push(`the box's ${axis} size is ${bin.extent[axis]}, it was ${was.extent[axis]}`)
610
- const c = bin.shape?.cavity
611
- if (!c) return [...misses, 'no inside']
612
- if (c.end !== 'open') misses.push('its top is not open')
613
- /* An end is 'open' or { closed: <thickness left there> }. */
614
- if (c.start === 'open') misses.push('its bottom is open too')
615
- else if (!near(Number(c.start?.closed), 15)) misses.push(`its bottom is ${c.start?.closed} mm, 15 asked`)
616
- if (!Object.values(c.wall).every(w => near(w as number, 10))) misses.push(`walls ${Object.values(c.wall).join(', ')}, 10 asked`)
617
- return misses
618
- },
619
- reference: steps([{ kind: 'set-cavity', part: 'bin', cavity: { wall: 10, start: { closed: 15 }, end: 'open' } }]),
620
- wrong: steps([{ kind: 'set-cavity', part: 'bin', cavity: { wall: 10, start: 'open', end: 'open' } }])
621
- },
622
- {
623
- id: 'pipe-extend',
624
- title: '고치기: 관 끝에 아래로 꺾이는 굽힘과 직선 더하기 (ADR-0100 §16.2)',
625
- covers: ['set-pipe path', 'bend direction'],
626
- prompt: '이 관의 끝에서 아래쪽으로 90도 한 번 더 꺾고 300mm 더 뻗게 해 줘. 앞부분은 그대로',
627
- base: elbowDraft,
628
- check: (after, before) => {
629
- const was = scenarioPartsOf(before!).find(p => p.id === 'pipe')!
630
- const now = scenarioPartsOf(after).find(p => p.id === 'pipe')
631
- if (!now?.shape?.sweep) return ['the pipe is gone']
632
- const misses: string[] = []
633
- const [p0, p1] = [was.shape.sweep.path, now.shape.sweep.path]
634
- if (JSON.stringify(p1.slice(0, p0.length)) !== JSON.stringify(p0)) misses.push('the pipe as it was is changed')
635
- if (p1.length !== p0.length + 2) misses.push(`${p1.length - p0.length} pieces added, a bend and a run asked`)
636
- else {
637
- const [bend, run] = p1.slice(p0.length)
638
- if (!(bend.kind === 'bend' && near(bend.angle, 90))) misses.push(`it adds ${JSON.stringify(bend)}, a 90° bend asked`)
639
- if (!(run.kind === 'line' && near(run.length, 300))) misses.push(`it adds ${JSON.stringify(run)}, a 300 mm run asked`)
640
- }
641
- const heading = now.shape.sweep.stations.at(-1).n as number[]
642
- if (!(heading[1]! < -0.999)) misses.push(`it ends heading ${heading.map(v => Math.round(v * 100) / 100).join(', ')}, down asked`)
643
- return misses
644
- },
645
- /* Heading +X after the first bend, its section's first axis is still +Z and its second is now -Y: 90 turns it down. */
646
- reference: steps([{ kind: 'set-pipe', part: 'pipe', path: [{ line: 500 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 400 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 300 }] }]),
647
- wrong: steps([{ kind: 'set-pipe', part: 'pipe', path: [{ line: 500 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 400 }, { bend: { radius: 120, angle: 90, toward: 270 } }, { line: 300 }] }])
648
- },
649
- {
650
- id: 'pipe-to-duct',
651
- title: '고치기: 원형 관을 사각 덕트로, 경로는 그대로',
652
- covers: ['set-pipe section'],
653
- prompt: '이 관을 가로 120, 세로 80 의 사각 덕트로 바꿔 줘. 경로는 그대로',
654
- base: elbowDraft,
655
- check: (after, before) => {
656
- const was = scenarioPartsOf(before!).find(p => p.id === 'pipe')!
657
- const now = scenarioPartsOf(after).find(p => p.id === 'pipe')
658
- if (!now?.shape?.sweep) return ['the pipe is gone']
659
- const misses: string[] = []
660
- const s = now.shape.sweep.section
661
- if (s.kind !== 'rectangle') return [`its section is a ${s.kind}, a rectangle asked`]
662
- const sizes = [s.size.x, s.size.z].sort((a: number, b: number) => a - b)
663
- if (!(near(sizes[0], 80) && near(sizes[1], 120))) misses.push(`its section is ${s.size.x}×${s.size.z}, 120×80 asked`)
664
- if (JSON.stringify(now.shape.sweep.path) !== JSON.stringify(was.shape.sweep.path)) misses.push('its path changed')
665
- return misses
666
- },
667
- reference: steps([{ kind: 'set-pipe', part: 'pipe', width: 120, depth: 80, round: 0 }]),
668
- wrong: steps([{ kind: 'set-pipe', part: 'pipe', width: 120, depth: 80, round: 0, path: [{ line: 500 }, { bend: { radius: 120, angle: 90, toward: 90 } }, { line: 300 }] }])
669
- },
670
- {
671
- id: 'pipe-to-solid-bar',
672
- title: '고치기: 관을 굵은 속찬 막대로, 경로는 그대로',
673
- covers: ['set-pipe radius', 'wall 0'],
674
- prompt: '이 관을 지름 60 의 속이 찬 막대로 바꿔 줘',
675
- base: elbowDraft,
676
- check: (after, before) => {
677
- const was = scenarioPartsOf(before!).find(p => p.id === 'pipe')!
678
- const now = scenarioPartsOf(after).find(p => p.id === 'pipe')
679
- if (!now?.shape?.sweep) return ['the pipe is gone']
680
- const misses: string[] = []
681
- const s = now.shape.sweep.section
682
- if (s.kind !== 'ellipse' || !near(s.radius.x, 30)) misses.push(`its section is ${JSON.stringify(s)}, a 60 mm circle asked`)
683
- if (now.shape.sweep.wall !== undefined) misses.push('it is still hollow')
684
- if (JSON.stringify(now.shape.sweep.path) !== JSON.stringify(was.shape.sweep.path)) misses.push('its path changed')
685
- return misses
686
- },
687
- reference: steps([{ kind: 'set-pipe', part: 'pipe', radius: 30, wall: 0 }]),
688
- wrong: steps([{ kind: 'set-pipe', part: 'pipe', radius: 30 }])
689
- },
690
- {
691
- id: 'pipe-narrow',
692
- title: '고치기: 관이 끝으로 갈수록 가늘어지게 (ADR-0100 §16.2.9)',
693
- covers: ['set-pipe endRadius'],
694
- prompt: '이 관이 끝으로 갈수록 가늘어져서 끝에서는 지름 40 이 되게 해 줘. 시작 굵기와 경로는 그대로',
695
- base: elbowDraft,
696
- check: (after, before) => {
697
- const was = scenarioPartsOf(before!).find(p => p.id === 'pipe')!
698
- const now = scenarioPartsOf(after).find(p => p.id === 'pipe')
699
- if (!now?.shape?.sweep) return ['the pipe is gone']
700
- const w = now.shape.sweep
701
- const misses: string[] = []
702
- if (!w.to) misses.push(`it does not narrow: one section, ${JSON.stringify(w.section)}, end to end`)
703
- else if (!(w.to.kind === 'ellipse' && near(w.to.radius.x, 20))) misses.push(`its end is ${JSON.stringify(w.to)}, a 40 mm circle asked`)
704
- if (!near(w.section.radius?.x ?? 0, was.shape.sweep.section.radius.x)) misses.push('its start changed')
705
- if (JSON.stringify(w.path) !== JSON.stringify(was.shape.sweep.path)) misses.push('its path changed')
706
- return misses
707
- },
708
- reference: steps([{ kind: 'set-pipe', part: 'pipe', endRadius: 20 }]),
709
- wrong: steps([{ kind: 'set-pipe', part: 'pipe', radius: 20 }])
710
- },
711
- {
712
- id: 'pipe-turn-other-way',
713
- title: '고치기: 관이 반대쪽(-X)으로 꺾이게',
714
- covers: ['set-pipe bend toward'],
715
- prompt: '이 관이 오른쪽이 아니라 반대쪽(-X 방향)으로 꺾이게 해 줘. 길이와 굵기는 그대로',
716
- base: elbowDraft,
717
- check: after => {
718
- const now = scenarioPartsOf(after).find(p => p.id === 'pipe')
719
- if (!now?.shape?.sweep) return ['the pipe is gone']
720
- const misses: string[] = []
721
- const end = now.shape.sweep.stations.at(-1)
722
- if (!(end.n[0] < -0.999)) misses.push(`it ends heading ${end.n.map((v: number) => Math.round(v * 100) / 100).join(', ')}, -X asked`)
723
- const lengths = now.shape.sweep.path.map((p: Dynamic) => p.length ?? p.radius)
724
- if (JSON.stringify(lengths) !== JSON.stringify([500, 120, 400])) misses.push(`its runs and radius are ${lengths.join(', ')}, kept asked`)
725
- return misses
726
- },
727
- reference: steps([{ kind: 'set-pipe', part: 'pipe', path: [{ line: 500 }, { bend: { radius: 120, angle: 90, toward: 270 } }, { line: 400 }] }]),
728
- wrong: steps([{ kind: 'set-pipe', part: 'pipe', path: [{ line: 500 }, { bend: { radius: 120, angle: 90, toward: 0 } }, { line: 400 }] }])
729
- },
730
- {
731
- id: 'box-tapered-top',
732
- title: '고치기: 상자 윗면을 절반 크기로 (ADR-0100 §16.1)',
733
- covers: ['set-section top'],
734
- prompt: '이 상자의 윗면을 가로세로 절반 크기로 줄여서 위로 갈수록 좁아지게 해 줘. 아랫면은 그대로',
735
- base: boxDraft,
736
- check: (after, before) => {
737
- const was = scenarioPartsOf(before!).find(p => p.id === 'bin')!
738
- const now = scenarioPartsOf(after).find(p => p.id === 'bin')
739
- if (!now) return ['the box is gone']
740
- if (now.kind !== 'tapered') return [`it is a ${now.kind}, a tapered box asked`]
741
- const misses: string[] = []
742
- const [from, to] = [now.shape.loft.section.size, now.shape.loft.to.size]
743
- if (!(near(from.x, was.extent.x) && near(from.z, was.extent.z))) misses.push(`its bottom is ${from.x}×${from.z}, kept asked`)
744
- if (!(near(to.x, from.x / 2) && near(to.z, from.z / 2))) misses.push(`its top is ${to.x}×${to.z}, half asked`)
745
- return misses
746
- },
747
- reference: steps([{ kind: 'set-section', part: 'bin', top: { across: { x: 300, z: 200 } } }]),
748
- wrong: steps([{ kind: 'set-section', part: 'bin', across: { x: 300, z: 200 } }])
749
- },
750
- {
751
- id: 'table-follows-width',
752
- title: '고치기: 보드에서 폭을 바꾸면 상판이 따라가게',
753
- covers: ['declare-instance-size', 'follow-size'],
754
- prompt: '보드에서 이 테이블의 폭을 바꾸면 상판 폭이 따라 늘어나게 해 줘. 다리는 그대로',
755
- base: tableDraft,
756
- check: after => {
757
- const inputs = (after.document.model as Dynamic).inputs as Dynamic[]
758
- const width = inputs.find(i => i.id === 'size.x')
759
- if (!width) return ["the figure's size is not declared"]
760
- const at = (x: number) => scenarioPartsOf({ ...after, designInputs: { ...after.designInputs, 'size.x': x } } as FigureAsset)
761
- const was = Object.fromEntries(at(after.designInputs['size.x'] as number).map(p => [p.id, p]))
762
- const wider = Object.fromEntries(at((after.designInputs['size.x'] as number) * 1.5).map(p => [p.id, p]))
763
- const misses: string[] = []
764
- if (!(wider.top!.extent.x > was.top!.extent.x + 1)) misses.push('the top does not grow with the width')
765
- if (!near(wider.leg!.extent.x, was.leg!.extent.x)) misses.push('the leg grows with the width')
766
- return misses
767
- },
768
- reference: steps([{ kind: 'declare-instance-size' }, { kind: 'follow-size', part: 'top', axes: ['x'] }]),
769
- wrong: steps([{ kind: 'declare-instance-size' }])
770
- },
771
- {
772
- id: 'status-lamp',
773
- title: '고치기: 상태 값으로 램프 색 (데이터 바인딩)',
774
- covers: ['set-data-schema', 'set-data-binding table'],
775
- prompt: 'status 값이 ALARM 이면 램프를 빨간색으로 깜빡이고, NORMAL 이면 초록색으로 켜지게 해 줘',
776
- base: lampDraft,
777
- check: after => {
778
- const bindings = ((after as Dynamic).dataInterface?.bindings ?? []) as Dynamic[]
779
- const table = bindings.find(b => b.rule === 'table' && (b.targets?.parts ?? []).includes('lamp'))
780
- if (!table) return ['no table binding on the lamp']
781
- const misses: string[] = []
782
- const red = (c: string | undefined) => !!c && /^#([ef][0-9a-f]|d[89a-f])[0-4][0-9a-f][0-4][0-9a-f]$/i.test(c)
783
- const green = (c: string | undefined) => !!c && /^#[0-4][0-9a-f]([89a-f][0-9a-f])[0-6][0-9a-f]$/i.test(c)
784
- if (!red(table.table?.ALARM?.color)) misses.push(`ALARM is ${table.table?.ALARM?.color ?? 'not there'}, red asked`)
785
- if (table.table?.ALARM?.effect?.kind !== 'blink') misses.push('ALARM does not blink')
786
- if (!green(table.table?.NORMAL?.color)) misses.push(`NORMAL is ${table.table?.NORMAL?.color ?? 'not there'}, green asked`)
787
- return misses
788
- },
789
- reference: steps([
790
- { kind: 'set-data-schema', schema: [{ name: 'status', kind: 'text', values: ['NORMAL', 'ALARM'] }] },
791
- { kind: 'set-data-binding', binding: { id: 'lamp-status', accessor: 'status', rule: 'table', lookup: 'code', targets: { parts: ['lamp'] }, table: { ALARM: { color: '#ef4444', effect: { kind: 'blink' } }, NORMAL: { color: '#22c55e' } } } }
792
- ]),
793
- wrong: steps([
794
- { kind: 'set-data-schema', schema: [{ name: 'status', kind: 'text', values: ['NORMAL', 'ALARM'] }] },
795
- { kind: 'set-data-binding', binding: { id: 'lamp-status', accessor: 'status', rule: 'table', lookup: 'code', targets: { parts: ['lamp'] }, table: { ALARM: { color: '#ef4444' }, NORMAL: { color: '#22c55e' } } } }
796
- ])
797
- }
798
- ]