@things-factory/figure-viewer 10.1.266 → 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.
- package/dist-client/data-words.d.ts +5 -0
- package/dist-client/data-words.js +13 -3
- package/package.json +17 -3
- package/translations/en.json +1 -1
- package/translations/es.json +1 -1
- package/translations/ja.json +1 -1
- package/translations/ko.json +1 -1
- package/translations/ms.json +1 -1
- package/translations/zh.json +1 -1
- package/client/capability-rung.ts +0 -22
- package/client/controls.ts +0 -54
- package/client/data-connection.ts +0 -82
- package/client/data-words.ts +0 -31
- package/client/detail-facts.ts +0 -86
- package/client/detail-motion.ts +0 -61
- package/client/figure-asset-viewer.ts +0 -472
- package/client/figure-data-list.ts +0 -87
- package/client/figure-data-report.ts +0 -142
- package/client/figure-facts-list.ts +0 -59
- package/client/figure-thumb-mark.ts +0 -34
- package/client/figure-view.ts +0 -151
- package/client/index.ts +0 -19
- package/client/preview-model.ts +0 -162
- package/client/side-panel-styles.ts +0 -480
- package/client/tsconfig.json +0 -19
- package/client/unit-words.ts +0 -11
- package/dist-client/capability-rung.js.map +0 -1
- package/dist-client/controls.js.map +0 -1
- package/dist-client/data-connection.js.map +0 -1
- package/dist-client/data-words.js.map +0 -1
- package/dist-client/detail-facts.js.map +0 -1
- package/dist-client/detail-motion.js.map +0 -1
- package/dist-client/figure-asset-viewer.js.map +0 -1
- package/dist-client/figure-data-list.js.map +0 -1
- package/dist-client/figure-data-report.js.map +0 -1
- package/dist-client/figure-facts-list.js.map +0 -1
- package/dist-client/figure-thumb-mark.js.map +0 -1
- package/dist-client/figure-view.js.map +0 -1
- package/dist-client/index.js.map +0 -1
- package/dist-client/preview-model.js.map +0 -1
- package/dist-client/side-panel-styles.js.map +0 -1
- package/dist-client/tsconfig.tsbuildinfo +0 -1
- package/dist-client/unit-words.js.map +0 -1
- package/dist-server/index.js.map +0 -1
- package/dist-server/tsconfig.tsbuildinfo +0 -1
- package/server/index.ts +0 -4
- package/server/tsconfig.json +0 -10
- package/test/controls.test.ts +0 -51
- package/test/data-connection.test.ts +0 -35
- package/test/detail-facts.test.ts +0 -89
- package/test/detail-motion.test.ts +0 -110
- package/test/figure-data-report.test.ts +0 -88
- package/test/joints.ts +0 -30
- package/test/preview.test.ts +0 -101
- package/test/resolve-ts-siblings.mjs +0 -85
- package/test/view.test.ts +0 -13
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* What a figure's data list shows (data binding design, decision 3) -- the board's 「피규어 데이터」 section for a placed
|
|
3
|
-
* figure, the preview's 「데이터」 tab for a release with no data given: the figure's data
|
|
4
|
-
* shape as a tree, each value now and where it came from -- the component's data, a value saved on the board, the
|
|
5
|
-
* shape's default, or none -- what it moves, a control the board's own state values hold over the data, why data was
|
|
6
|
-
* refused, the fields the data has that the shape does not name, and an example to copy.
|
|
7
|
-
*
|
|
8
|
-
* Nothing here reads data: the values and their sources are things-scene's figure inputs', given in. Kept apart from the
|
|
9
|
-
* element so it is tested without a board.
|
|
10
|
-
*/
|
|
11
|
-
import { figureDataExample, figureDataRows } from '@hatiolab/figure-model'
|
|
12
|
-
import { ITEM_FIELDS, type FigureItemField } from './data-connection.js'
|
|
13
|
-
import type { FigureAsset, FigureDataBehavior, FigureDataBinding, FigureDataNode, FigureDataTargets, FigureDataValue, FigureDataValueIssue } from '@hatiolab/figure-model'
|
|
14
|
-
|
|
15
|
-
/** Where a value came from, as things-scene's figure inputs say. */
|
|
16
|
-
export type FigureDataSource = 'live' | 'manual' | 'default' | 'absent'
|
|
17
|
-
|
|
18
|
-
/** A placed figure as the section reads it: its asset, its state, and what its figure inputs worked out. */
|
|
19
|
-
export interface FigureDataSnapshot {
|
|
20
|
-
asset: FigureAsset
|
|
21
|
-
/** The component's data, as the board's data source or a mapping gave it. */
|
|
22
|
-
data: unknown
|
|
23
|
-
/** The board's own state values (`parameters`), by control. */
|
|
24
|
-
parameters?: Record<string, unknown> | null
|
|
25
|
-
/** Each binding's value now and its source, by binding id (figure inputs' `dataValues`). */
|
|
26
|
-
values: Readonly<Record<string, { value: FigureDataValue | undefined; source: FigureDataSource }>>
|
|
27
|
-
/** Why the last things given were refused (figure inputs' `diagnostics()`). */
|
|
28
|
-
refused: ReadonlyArray<{ source: string; reason: string; issues?: FigureDataValueIssue[] }>
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface FigureDataReportRow {
|
|
32
|
-
path: string
|
|
33
|
-
depth: number
|
|
34
|
-
name: string
|
|
35
|
-
label?: string
|
|
36
|
-
node: FigureDataNode
|
|
37
|
-
/** A value field's value now; a list's element count in the data. */
|
|
38
|
-
value?: FigureDataValue
|
|
39
|
-
count?: number
|
|
40
|
-
source?: FigureDataSource
|
|
41
|
-
/** What the bindings reading it move: a behavior each, or a table and its targets. */
|
|
42
|
-
behaviors: FigureDataMove[]
|
|
43
|
-
/** Controls it moves that the board's state values hold instead. */
|
|
44
|
-
heldByBoard: string[]
|
|
45
|
-
/**
|
|
46
|
-
* A field inside an items list's element, the part of an item it says: its id, its type, the place it is in, its
|
|
47
|
-
* height in the stack, its status. Its row says that instead of repeating the list's behavior.
|
|
48
|
-
*/
|
|
49
|
-
itemField?: FigureItemField
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** What one binding moves: a value binding's behavior, or a table's targets (ADR-0166 3). */
|
|
54
|
-
export type FigureDataMove = FigureDataBehavior | { kind: 'table'; targets: FigureDataTargets }
|
|
55
|
-
|
|
56
|
-
export interface FigureDataReport {
|
|
57
|
-
/** The figure, for the names of what its fields move (dataMoveOf). */
|
|
58
|
-
asset: FigureAsset
|
|
59
|
-
rows: FigureDataReportRow[]
|
|
60
|
-
/** Fields the data has that the shape does not name, as paths (`[]` for a list's elements). */
|
|
61
|
-
unused: string[]
|
|
62
|
-
refused: FigureDataSnapshot['refused']
|
|
63
|
-
/** Data with every field of the shape, to copy. */
|
|
64
|
-
example: Record<string, unknown>
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const isRecord = (v: unknown): v is Record<string, unknown> => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
68
|
-
|
|
69
|
-
/** The value at a path with no list in it (`A.B`), or undefined. */
|
|
70
|
-
function valueAt(data: unknown, path: string): unknown {
|
|
71
|
-
let at: unknown = data
|
|
72
|
-
for (const name of path.split('.')) {
|
|
73
|
-
if (!isRecord(at)) return undefined
|
|
74
|
-
at = at[name]
|
|
75
|
-
}
|
|
76
|
-
return at
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Every field path the data has that the shape does not name. A JSON text in place of an object or a list is not looked into. */
|
|
80
|
-
function unusedOf(data: unknown, fields: ReadonlyArray<{ name: string } & FigureDataNode>, at: string, out: Set<string>): void {
|
|
81
|
-
if (!isRecord(data)) return
|
|
82
|
-
for (const [key, value] of Object.entries(data)) {
|
|
83
|
-
const path = at ? `${at}.${key}` : key
|
|
84
|
-
const field = fields.find(f => f.name === key)
|
|
85
|
-
if (!field) {
|
|
86
|
-
out.add(path)
|
|
87
|
-
continue
|
|
88
|
-
}
|
|
89
|
-
let node: FigureDataNode = field
|
|
90
|
-
let value_: unknown = value
|
|
91
|
-
let p = path
|
|
92
|
-
while (node.kind === 'list' && Array.isArray(value_)) {
|
|
93
|
-
const item: FigureDataNode = node.item
|
|
94
|
-
p = `${p}[]`
|
|
95
|
-
for (const element of value_) if (item.kind === 'object') unusedOf(element, item.fields, p, out)
|
|
96
|
-
value_ = undefined
|
|
97
|
-
node = item
|
|
98
|
-
}
|
|
99
|
-
if (node.kind === 'object' && isRecord(value_)) unusedOf(value_, node.fields, p, out)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function figureDataReportOf(s: FigureDataSnapshot): FigureDataReport | null {
|
|
104
|
-
const di = s.asset.dataInterface
|
|
105
|
-
if (!di) return null
|
|
106
|
-
const bindings = new Map(di.bindings.map(b => [b.id, b] as const))
|
|
107
|
-
const held = new Set(Object.keys(s.parameters ?? {}))
|
|
108
|
-
/* The row path of each field an items binding reads inside its list's element, as figureDataRows writes it. */
|
|
109
|
-
const asRow = (accessor: string) => accessor.replace(/\[\d+\]/g, '[]')
|
|
110
|
-
const itemFields = new Map<string, FigureItemField>()
|
|
111
|
-
for (const b of di.bindings)
|
|
112
|
-
if (b.rule !== 'table' && b.behavior.kind === 'items')
|
|
113
|
-
for (const field of ITEM_FIELDS) {
|
|
114
|
-
const rel = b.behavior[field]
|
|
115
|
-
if (rel) itemFields.set(`${asRow(b.accessor)}[].${asRow(rel)}`, field)
|
|
116
|
-
}
|
|
117
|
-
const rows = figureDataRows(di).map((row): FigureDataReportRow => {
|
|
118
|
-
const itemField = itemFields.get(row.path)
|
|
119
|
-
/* An item's field says its part of the item; the list's own row says the items go into the places. */
|
|
120
|
-
const reading = row.bindings.map(id => bindings.get(id))
|
|
121
|
-
.filter((b): b is FigureDataBinding => !!b && !(itemField && b.rule !== 'table' && b.behavior.kind === 'items'))
|
|
122
|
-
const behaviors = reading.map((b): FigureDataMove => (b.rule === 'table' ? { kind: 'table', targets: b.targets } : b.behavior))
|
|
123
|
-
const heldByBoard = behaviors.flatMap(b => (b.kind === 'state' ? [b.input] : b.kind === 'table' ? (b.targets.inputs ?? []) : []).filter(input => held.has(input)))
|
|
124
|
-
const out: FigureDataReportRow = { path: row.path, depth: row.depth, name: row.name, ...(row.label ? { label: row.label } : {}), node: row.node, behaviors, heldByBoard, ...(itemField ? { itemField } : {}) }
|
|
125
|
-
if (row.node.kind === 'list') {
|
|
126
|
-
const list = row.path.includes('[]') ? undefined : valueAt(s.data, row.path)
|
|
127
|
-
if (Array.isArray(list)) out.count = list.length
|
|
128
|
-
} else if (row.node.kind !== 'object') {
|
|
129
|
-
/* The value a binding read: the first that reads this place and is not an items binding (items read the list). */
|
|
130
|
-
const read = reading.find(b => (b.rule === 'table' || b.behavior.kind !== 'items') && s.values[b.id])
|
|
131
|
-
if (read) {
|
|
132
|
-
const { value, source } = s.values[read.id]!
|
|
133
|
-
out.source = source
|
|
134
|
-
if (value !== undefined) out.value = value
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return out
|
|
138
|
-
})
|
|
139
|
-
const unused = new Set<string>()
|
|
140
|
-
unusedOf(s.data, di.schema, '', unused)
|
|
141
|
-
return { asset: s.asset, rows, unused: [...unused], refused: s.refused, example: figureDataExample(di) }
|
|
142
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { css, html, LitElement, nothing } from 'lit'
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
-
|
|
4
|
-
import { i18next, localize } from '@operato/i18n'
|
|
5
|
-
import type { FigureAsset } from '@hatiolab/figure-model'
|
|
6
|
-
|
|
7
|
-
import { detailFactsOf, type DetailFactsRow } from './detail-facts.js'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* What a figure is, as labelled lines under its live canvas: category, tags, placement, the sizes a board may give it,
|
|
11
|
-
* what it does, its places (one line each: name · role · accepts · how many), joints, extensions, and the score and the
|
|
12
|
-
* last change when the row keeps them. operato-figure's catalogue preview and a board server's release compare show it
|
|
13
|
-
* alike; it goes into figure-asset-viewer's `facts` slot.
|
|
14
|
-
*/
|
|
15
|
-
@customElement('figure-facts-list')
|
|
16
|
-
export class FigureFactsList extends localize(i18next)(LitElement) {
|
|
17
|
-
static styles = css`
|
|
18
|
-
:host {
|
|
19
|
-
display: block;
|
|
20
|
-
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
21
|
-
}
|
|
22
|
-
dl {
|
|
23
|
-
display: grid;
|
|
24
|
-
grid-template-columns: 96px minmax(0, 1fr);
|
|
25
|
-
gap: 3px 12px;
|
|
26
|
-
margin: 0;
|
|
27
|
-
padding: 10px 16px;
|
|
28
|
-
line-height: 1.45;
|
|
29
|
-
}
|
|
30
|
-
dt {
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
text-overflow: ellipsis;
|
|
33
|
-
white-space: nowrap;
|
|
34
|
-
color: var(--md-sys-color-on-surface-variant);
|
|
35
|
-
}
|
|
36
|
-
dd {
|
|
37
|
-
margin: 0;
|
|
38
|
-
overflow-wrap: anywhere;
|
|
39
|
-
}
|
|
40
|
-
dd small {
|
|
41
|
-
display: block;
|
|
42
|
-
color: var(--md-sys-color-on-surface-variant);
|
|
43
|
-
}
|
|
44
|
-
`
|
|
45
|
-
|
|
46
|
-
@property({ attribute: false }) asset?: FigureAsset
|
|
47
|
-
@property({ attribute: false }) row?: DetailFactsRow
|
|
48
|
-
|
|
49
|
-
render() {
|
|
50
|
-
if (!this.asset || !this.row) return nothing
|
|
51
|
-
const facts = detailFactsOf(this.asset, this.row, (key, params) => i18next.t(key, params))
|
|
52
|
-
return html`<dl>
|
|
53
|
-
${facts.map(
|
|
54
|
-
fact => html`<dt title=${fact.label}>${fact.label}</dt>
|
|
55
|
-
<dd>${fact.value}${fact.lines?.map(line => html`<small>${line}</small>`)}</dd>`
|
|
56
|
-
)}
|
|
57
|
-
</dl>`
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js'
|
|
2
|
-
|
|
3
|
-
import { css, html, LitElement } from 'lit'
|
|
4
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A figure without a thumbnail: a faint 3D mark filling most of the picture's height, no text (the sentence is the
|
|
8
|
-
* label a screen reader reads). Its own element because a card draws its picture inside the card, out of the page's
|
|
9
|
-
* styles. operato-figure's catalog card (figure-ui figure-thumb) draws the same mark at the same size.
|
|
10
|
-
*/
|
|
11
|
-
@customElement('figure-thumb-mark')
|
|
12
|
-
export class FigureThumbMark extends LitElement {
|
|
13
|
-
static styles = css`
|
|
14
|
-
:host {
|
|
15
|
-
display: grid;
|
|
16
|
-
place-items: center;
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 100%;
|
|
19
|
-
container-type: size;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
md-icon {
|
|
23
|
-
--md-icon-size: 60cqh;
|
|
24
|
-
color: var(--md-sys-color-on-surface);
|
|
25
|
-
opacity: 0.12;
|
|
26
|
-
}
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
@property() label = ''
|
|
30
|
-
|
|
31
|
-
render() {
|
|
32
|
-
return html`<md-icon role="img" aria-label=${this.label}>deployed_code</md-icon>`
|
|
33
|
-
}
|
|
34
|
-
}
|
package/client/figure-view.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 저작 화면의 **보기 설정**.
|
|
3
|
-
*
|
|
4
|
-
* ## 저장되지 않는다
|
|
5
|
-
*
|
|
6
|
-
* 이것은 자산이 아니라 **작업대**다. 조명을 밝게 하고 바닥을 켠 것은 그 사람이 지금
|
|
7
|
-
* 보기 편한 상태일 뿐, 그 자산의 성질이 아니다. 그래서 자산에 안 들어가고, 보는 사람의
|
|
8
|
-
* 브라우저에 남는다.
|
|
9
|
-
*
|
|
10
|
-
* 다른 사람이 같은 자산을 열면 자기 설정으로 본다. 그것이 맞다.
|
|
11
|
-
*
|
|
12
|
-
* ## 씬이 아는 이름을 그대로 쓴다
|
|
13
|
-
*
|
|
14
|
-
* 여기 이름은 전부 `model-layer` 의 상태 이름이다. 옮겨 적는 표를 두지 않는다 — 표를
|
|
15
|
-
* 두면 씬이 새 설정을 받아도 이쪽이 모른다.
|
|
16
|
-
*
|
|
17
|
-
* 값이 바뀌면 씬이 스스로 반영한다(`three-capability` 의 `onchange`). 다만 `grid` 는
|
|
18
|
-
* 한동안 3D 를 세울 때만 읽혔다 — things-scene 10.1.5 에서 고쳤다.
|
|
19
|
-
*/
|
|
20
|
-
export interface ViewSettings {
|
|
21
|
-
/**
|
|
22
|
-
* 어떤 도면에 놓인 것으로 보나 — 씬 전체의 좌표 모드.
|
|
23
|
-
*
|
|
24
|
-
* **피규어의 `placement` 와 다른 것이다.** 피규어의 것은 「이 종류는 바닥에 서나, 천장에
|
|
25
|
-
* 매달리나」이고, 이것은 「지금 보고 있는 도면이 어느 쪽을 기준으로 재나」다. 바닥
|
|
26
|
-
* 기준 도면에 천정 기반 OHT 를 놓으면 도면은 안 뒤집히고 OHT 가 천장 높이에 매달린다.
|
|
27
|
-
*
|
|
28
|
-
* 한동안 피규어의 `placement` 를 이 자리에 흘려 넣었다. 모델러에 피규어가 하나뿐이라
|
|
29
|
-
* 그럴듯해 보였지만, 그러면 피규어의 성질이 씬 전체를 뒤집는다 — 도면에서는 성립할 수가
|
|
30
|
-
* 없고(도면에는 피규어가 여럿이다), 저작 중에는 배치를 고를 때마다 저작자가 적어 둔
|
|
31
|
-
* 높이가 전부 다른 숫자로 보였다.
|
|
32
|
-
*
|
|
33
|
-
* 씬의 낱말 그대로다: `floor` 바닥 기준 · `space` 중심 기준(바닥 없음) · `inverted`
|
|
34
|
-
* 천장 기준. **미리보기에만 먹인다** — 편집 캔버스의 `zPos` 는 저작자가 직접 적는
|
|
35
|
-
* 숫자라 그 뜻이 보기 설정에 따라 바뀌면 안 된다.
|
|
36
|
-
*/
|
|
37
|
-
placement: 'floor' | 'space' | 'inverted'
|
|
38
|
-
/**
|
|
39
|
-
* 천장 높이 (mm). 천정 기반 피규어를 미리보기에서 어디에 매달 것인가.
|
|
40
|
-
*
|
|
41
|
-
* 피규어는 제가 놓일 방의 높이를 모른다. 도면은 알지만 미리보기에는 도면이 없으므로,
|
|
42
|
-
* 저작자가 가정할 값을 여기서 정한다.
|
|
43
|
-
*/
|
|
44
|
-
ceilingHeight: number
|
|
45
|
-
/** 좌표 바탕(축 가이드). 원점과 눈금을 보인다. */
|
|
46
|
-
grid: boolean
|
|
47
|
-
/** 축 이름표(X · Y · Z). 눈금만 두고 글자를 끌 수 있다. */
|
|
48
|
-
gridLabels: boolean
|
|
49
|
-
/** 판의 바닥면. 좌표 바탕과 겹치므로 기본은 끈다. */
|
|
50
|
-
floor: boolean
|
|
51
|
-
/** Environment — 반사(IBL). 금속 재질이 무엇을 비출지 정한다. */
|
|
52
|
-
environment: EnvironmentName
|
|
53
|
-
/** Sky Color — 배경색. */
|
|
54
|
-
skyColor: string
|
|
55
|
-
/** Key Light Intensity. */
|
|
56
|
-
dirLightIntensity: number
|
|
57
|
-
/** Key Light — Follow Camera. 끄면 그림자 방향이 고정된다. */
|
|
58
|
-
dirLightFollowCamera: boolean
|
|
59
|
-
/** Key Light — Cast Shadow. */
|
|
60
|
-
dirShadowEnabled: boolean
|
|
61
|
-
/** Hemisphere Light Intensity — 그늘진 면을 들어올린다. */
|
|
62
|
-
hemiIntensity: number
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 환경 프리셋 — **`scene-manager` 의 `SkyPreset` 과 같은 여덟이다.**
|
|
67
|
-
*
|
|
68
|
-
* 한동안 다섯만 적었다. 씬은 여덟을 다 받는데 이쪽이 셋을 몰라서 고를 수 없었다.
|
|
69
|
-
* operato-board 의 3D 씬 속성 패널도 같은 여덟을 보인다.
|
|
70
|
-
*/
|
|
71
|
-
export const ENVIRONMENTS = [
|
|
72
|
-
'studio',
|
|
73
|
-
'warehouse',
|
|
74
|
-
'factory',
|
|
75
|
-
'office',
|
|
76
|
-
'home',
|
|
77
|
-
'sunny',
|
|
78
|
-
'cloudy',
|
|
79
|
-
'rainy'
|
|
80
|
-
] as const
|
|
81
|
-
export type EnvironmentName = (typeof ENVIRONMENTS)[number]
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 씬에 그대로 넣는 보기 설정 — **좌표 기준과 천장 높이는 빼고.**
|
|
85
|
-
*
|
|
86
|
-
* 나머지는 전부 `model-layer` 의 상태 이름이라 그대로 넣으면 씬이 알아서 반응한다.
|
|
87
|
-
* 그런데 `placement` 는 편집 캔버스에 들어가면 안 되고(거기는 늘 상자 기준이다),
|
|
88
|
-
* `ceilingHeight` 는 씬이 모르는 이름이다.
|
|
89
|
-
*
|
|
90
|
-
* **rest spread 로 넘기지 않으려고 이 함수가 있다.** 캔버스가 한동안
|
|
91
|
-
* `const { grid, ..., ...light } = view` 로 나머지를 통째로 넘겼는데, 그러면 설정을
|
|
92
|
-
* 하나 더할 때마다 그것이 두 화면에 **말없이** 실린다. 새로 더한 좌표 기준이 바로
|
|
93
|
-
* 그 길로 캔버스에 들어갈 뻔했다.
|
|
94
|
-
*/
|
|
95
|
-
export function sceneLook(view: ViewSettings): Record<string, unknown> {
|
|
96
|
-
const { placement, ceilingHeight, ...look } = view
|
|
97
|
-
return look
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* 씬의 좌표 기준 — **씬의 낱말 그대로 셋이다.**
|
|
102
|
-
*
|
|
103
|
-
* 형식의 `floor` · `center` · `ceiling` 과 짝이 맞지만 철자가 다르다. 옮겨 적는 표를 두지
|
|
104
|
-
* 않는 것이 이 파일의 규칙이므로 씬 쪽을 쓴다. 화면에는 둘 다 보인다 — 「천장 기준
|
|
105
|
-
* (inverted)」.
|
|
106
|
-
*/
|
|
107
|
-
export const SCENE_REFERENCES = ['floor', 'space', 'inverted'] as const
|
|
108
|
-
|
|
109
|
-
/** 배경색 기본값. 회색이라 부품 색이 제 색으로 보인다. */
|
|
110
|
-
export const WORKBENCH = '#7c7c7c'
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 처음 값.
|
|
114
|
-
*
|
|
115
|
-
* **지금 저작 화면이 실제로 쓰던 값 그대로다.** 설정을 만들면서 화면이 달라지면
|
|
116
|
-
* 무엇이 설정 때문이고 무엇이 원래 그랬는지 갈리지 않는다.
|
|
117
|
-
*/
|
|
118
|
-
export const DEFAULT_VIEW: ViewSettings = {
|
|
119
|
-
placement: 'floor',
|
|
120
|
-
/* 공장 천장의 흔한 높이. 반도체 fab 의 OHT 레일이 대체로 이 언저리다. */
|
|
121
|
-
ceilingHeight: 4000,
|
|
122
|
-
grid: true,
|
|
123
|
-
gridLabels: true,
|
|
124
|
-
floor: false,
|
|
125
|
-
environment: 'studio',
|
|
126
|
-
skyColor: WORKBENCH,
|
|
127
|
-
dirLightIntensity: 2.0,
|
|
128
|
-
dirLightFollowCamera: true,
|
|
129
|
-
dirShadowEnabled: true,
|
|
130
|
-
hemiIntensity: 4.0
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* How tall the preview board is: enough room for the tallest instance where the figure actually stands.
|
|
135
|
-
*
|
|
136
|
-
* A floor or center figure stands on the floor, so the tallest instance is the whole height. Only a
|
|
137
|
-
* ceiling figure needs the room up to the ceiling. The board used to reach the ceiling for every figure,
|
|
138
|
-
* which made a 920 tall AGV preview 4400 tall.
|
|
139
|
-
*
|
|
140
|
-
* This is an envelope, not a placement rule: where each instance goes is still the scene's
|
|
141
|
-
* (`FigureRealObject.effectiveZPos`), and the camera fits what the scene drew.
|
|
142
|
-
*/
|
|
143
|
-
export function previewBoardDepth(
|
|
144
|
-
figure: { placement?: 'floor' | 'ceiling' | 'center' | 'wall'; base: { y: number } },
|
|
145
|
-
ceilingHeight: number,
|
|
146
|
-
factor: number
|
|
147
|
-
): number {
|
|
148
|
-
const tallest = figure.base.y * factor
|
|
149
|
-
const reach = figure.placement === 'ceiling' ? Math.max(ceilingHeight, tallest) : tallest
|
|
150
|
-
return Math.round(reach * 1.1)
|
|
151
|
-
}
|
package/client/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* A released figure on a live canvas, shared by figure-ui (the authoring catalogue) and figure-library (a board
|
|
3
|
-
* server's library). Importers use the files by path (`@things-factory/figure-viewer/dist-client/<file>.js`).
|
|
4
|
-
*/
|
|
5
|
-
export * from './capability-rung.js'
|
|
6
|
-
export * from './controls.js'
|
|
7
|
-
export * from './data-connection.js'
|
|
8
|
-
export * from './data-words.js'
|
|
9
|
-
export * from './detail-facts.js'
|
|
10
|
-
export * from './detail-motion.js'
|
|
11
|
-
export * from './figure-data-list.js'
|
|
12
|
-
export * from './figure-data-report.js'
|
|
13
|
-
export * from './figure-asset-viewer.js'
|
|
14
|
-
export * from './figure-facts-list.js'
|
|
15
|
-
export * from './figure-thumb-mark.js'
|
|
16
|
-
export * from './figure-view.js'
|
|
17
|
-
export * from './preview-model.js'
|
|
18
|
-
export * from './side-panel-styles.js'
|
|
19
|
-
export * from './unit-words.js'
|
package/client/preview-model.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { figureInstanceSizeRangeOf, figurePartsExtentOf, FIGURE_INSTANCE_SIZE_INPUTS } from '@hatiolab/figure-model'
|
|
2
|
-
import type { FigureAsset } from '@hatiolab/figure-model'
|
|
3
|
-
|
|
4
|
-
/* The preview's arithmetic, apart from the element so it is tested without a browser (see figure-preview.ts). */
|
|
5
|
-
|
|
6
|
-
export const PREVIEW_FACTOR = 2
|
|
7
|
-
|
|
8
|
-
/** The type the preview registers the figure under: this figure's own, never a real type a board uses. */
|
|
9
|
-
export function previewTypeOf(context: string): string {
|
|
10
|
-
return `figure-preview-${context || 'new'}`
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const PREVIEW_WAYS: readonly { name: string; axes: readonly ('x' | 'y' | 'z')[] }[] = [
|
|
14
|
-
{ name: 'base', axes: [] },
|
|
15
|
-
{ name: 'x', axes: ['x'] },
|
|
16
|
-
{ name: 'y', axes: ['y'] },
|
|
17
|
-
{ name: 'z', axes: ['z'] },
|
|
18
|
-
{ name: 'x·y', axes: ['x', 'y'] },
|
|
19
|
-
{ name: 'x·z', axes: ['x', 'z'] },
|
|
20
|
-
{ name: 'y·z', axes: ['y', 'z'] },
|
|
21
|
-
{ name: 'x·y·z', axes: ['x', 'y', 'z'] }
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
/** The size the figure was made at: its instance size when it declares one, else the room its bodies take. */
|
|
25
|
-
export function authoredSizeOf(asset: FigureAsset): { x: number; y: number; z: number } {
|
|
26
|
-
const d = asset.designInputs
|
|
27
|
-
const declared = (['x', 'y', 'z'] as const).map(axis => d[FIGURE_INSTANCE_SIZE_INPUTS[axis]])
|
|
28
|
-
if (declared.every(v => typeof v === 'number' && v > 0)) return { x: declared[0]!, y: declared[1]!, z: declared[2]! }
|
|
29
|
-
/* No declared size: the size its parts are, as the board takes it for a figure that declares no space yet. */
|
|
30
|
-
const parts = figurePartsExtentOf(asset)
|
|
31
|
-
return { x: Math.max(1, Math.round(parts.x)), y: Math.max(1, Math.round(parts.y)), z: Math.max(1, Math.round(parts.z)) }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type Size = { x: number; y: number; z: number }
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The box a board instance stands in at these size inputs: the figure's body evaluated there, as things-scene reads an
|
|
38
|
-
* instance's width, height and depth -- the body, never the inputs (ADR-0087, 2026-10-06; ADR-0145). The two differ by
|
|
39
|
-
* whatever the parts reach past the size, and a preview that asked for the inputs drew the figure at the wrong size
|
|
40
|
-
* (first 15 minutes, re-measured 2026-10-16). Undefined for a figure with no size inputs: the board scales it whole from
|
|
41
|
-
* the box asked, so the size is its box already; and for sizes the figure cannot be made at.
|
|
42
|
-
*/
|
|
43
|
-
export function bodyAtSize(asset: FigureAsset, size: Size): Size | undefined {
|
|
44
|
-
const inputs = asset.document.model.inputs
|
|
45
|
-
if (!(['x', 'y', 'z'] as const).every(axis => inputs.some(i => i.id === FIGURE_INSTANCE_SIZE_INPUTS[axis]))) return undefined
|
|
46
|
-
try {
|
|
47
|
-
const body = figurePartsExtentOf(asset, Object.fromEntries((['x', 'y', 'z'] as const).map(axis => [FIGURE_INSTANCE_SIZE_INPUTS[axis], size[axis]])))
|
|
48
|
-
return { x: Math.max(body.x, 1), y: Math.max(body.y, 1), z: Math.max(body.z, 1) }
|
|
49
|
-
} catch {
|
|
50
|
-
return undefined
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The eight instances: where each stands on the board and how large, in the scene's words. `boxOf` gives the box an
|
|
56
|
-
* instance asked at a size stands in (`bodyAtSize`); without it, the size itself.
|
|
57
|
-
*/
|
|
58
|
-
export function previewInstances(type: string, size: Size, boxOf: (asked: Size) => Size = asked => asked) {
|
|
59
|
-
const COLUMNS = 4
|
|
60
|
-
const largest = boxOf({ x: size.x * PREVIEW_FACTOR, y: size.y * PREVIEW_FACTOR, z: size.z * PREVIEW_FACTOR })
|
|
61
|
-
const cell = { x: largest.x * 1.25, z: largest.z * 1.25 }
|
|
62
|
-
const components = PREVIEW_WAYS.map((way, at) => {
|
|
63
|
-
const grow = (axis: 'x' | 'y' | 'z') => (way.axes.includes(axis) ? PREVIEW_FACTOR : 1)
|
|
64
|
-
const box = boxOf({ x: size.x * grow('x'), y: size.y * grow('y'), z: size.z * grow('z') })
|
|
65
|
-
const width = Math.round(box.x)
|
|
66
|
-
const height = Math.round(box.z)
|
|
67
|
-
const column = at % COLUMNS
|
|
68
|
-
const row = Math.floor(at / COLUMNS)
|
|
69
|
-
return {
|
|
70
|
-
type,
|
|
71
|
-
id: `at-${way.name}`,
|
|
72
|
-
left: Math.round(column * cell.x + (cell.x - width) / 2),
|
|
73
|
-
top: Math.round(row * cell.z + (cell.z - height) / 2),
|
|
74
|
-
width,
|
|
75
|
-
height,
|
|
76
|
-
/* Always written: without it the height is taken as the plan's mean and "grow y only" would not grow it. */
|
|
77
|
-
depth: Math.round(box.y)
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
return { components, board: { width: Math.round(cell.x * COLUMNS), height: Math.round(cell.z * Math.ceil(PREVIEW_WAYS.length / COLUMNS)) } }
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* One instance in the box given -- the space it takes at the authored size (`bodyAtSize`) -- on a board twice its
|
|
86
|
-
* plan so it can grow in place: the catalogue's detail view and the modeller's preview both stand the figure this way
|
|
87
|
-
* (first 15 minutes, 2026-10-16: eight variants at one scale made a 60 mm roller on a 3 m conveyor a speck nobody could
|
|
88
|
-
* count). The instance's corner is placed so its centre is the board's.
|
|
89
|
-
*/
|
|
90
|
-
export function previewOneInstance(type: string, size: { x: number; y: number; z: number }) {
|
|
91
|
-
const board = { width: Math.round(size.x * 2), height: Math.round(size.z * 2) }
|
|
92
|
-
return {
|
|
93
|
-
board,
|
|
94
|
-
components: [{ type, id: 'one', left: Math.round(size.x / 2), top: Math.round(size.z / 2), width: size.x, height: size.z, depth: size.y }]
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/* One asset is one version: its range is computed once (figure-model evaluates the figure at its edges). */
|
|
99
|
-
const ranges = new WeakMap<FigureAsset, ReturnType<typeof figureInstanceSizeRangeOf>>()
|
|
100
|
-
const rangesOf = (asset: FigureAsset) => {
|
|
101
|
-
let found = ranges.get(asset)
|
|
102
|
-
if (!found) ranges.set(asset, (found = figureInstanceSizeRangeOf(asset)))
|
|
103
|
-
return found
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The range a board may size the figure over on an axis, as figure-model computes it: the ends its author narrowed and
|
|
108
|
-
* the rest as far as its parts allow (0 and Infinity where nothing limits it; ADR-0087 decision 6). Undefined when the
|
|
109
|
-
* figure does not let that axis change (no declared size, or one fixed at a single value).
|
|
110
|
-
*/
|
|
111
|
-
export function sizeRangeOf(asset: FigureAsset, axis: 'x' | 'y' | 'z'): { min: number; max: number } | undefined {
|
|
112
|
-
const range = rangesOf(asset)[axis]
|
|
113
|
-
return range && range.max > range.min ? { min: range.min, max: range.max } : undefined
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Where a slider for an axis runs: the range's ends, and an end nothing limits PREVIEW_FACTOR times the authored size
|
|
118
|
-
* up, or as far down. Undefined where the axis does not change.
|
|
119
|
-
*/
|
|
120
|
-
export function sizeSpanOf(asset: FigureAsset, axis: 'x' | 'y' | 'z'): { min: number; max: number } | undefined {
|
|
121
|
-
const range = sizeRangeOf(asset, axis)
|
|
122
|
-
const at = asset.designInputs[FIGURE_INSTANCE_SIZE_INPUTS[axis]]
|
|
123
|
-
if (!range || typeof at !== 'number') return undefined
|
|
124
|
-
return { min: range.min > 0 ? range.min : at / PREVIEW_FACTOR, max: Number.isFinite(range.max) ? range.max : at * PREVIEW_FACTOR }
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** A size asked on an axis, held to what the figure declares -- as the board clamps it. NaN and unopened axes give undefined. */
|
|
128
|
-
export function sizeWithinRange(asset: FigureAsset, axis: 'x' | 'y' | 'z', value: number): number | undefined {
|
|
129
|
-
const range = sizeRangeOf(asset, axis)
|
|
130
|
-
if (!range || !Number.isFinite(value)) return undefined
|
|
131
|
-
return Math.min(range.max, Math.max(range.min, value))
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Where a variant asks a size the figure does not declare, the size it is drawn at instead -- as the board draws it
|
|
136
|
-
* (things-scene clamps each axis to the declared range; chief architect's ruling 2026-09-25). Per variant, empty when
|
|
137
|
-
* it is drawn as asked. A figure that follows its height only is drawn at its one width in the wider variants, and
|
|
138
|
-
* the preview says so rather than drawing them as though they grew.
|
|
139
|
-
*/
|
|
140
|
-
export function previewClampsOf(asset: FigureAsset, size: { x: number; y: number; z: number }): Record<string, Array<{ axis: 'x' | 'y' | 'z'; asked: number; used: number }>> {
|
|
141
|
-
const inputs = asset.document.model.inputs
|
|
142
|
-
return Object.fromEntries(
|
|
143
|
-
PREVIEW_WAYS.map(way => [
|
|
144
|
-
way.name,
|
|
145
|
-
(['x', 'y', 'z'] as const).flatMap(axis => {
|
|
146
|
-
if (!inputs.some(i => i.id === FIGURE_INSTANCE_SIZE_INPUTS[axis])) return []
|
|
147
|
-
const range = rangesOf(asset)[axis]
|
|
148
|
-
const asked = Math.round(size[axis] * (way.axes.includes(axis) ? PREVIEW_FACTOR : 1))
|
|
149
|
-
const used = Math.round(Math.min(Math.max(asked, range?.min ?? -Infinity), range?.max ?? Infinity))
|
|
150
|
-
return used === asked ? [] : [{ axis, asked, used }]
|
|
151
|
-
})
|
|
152
|
-
])
|
|
153
|
-
)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* The part the preview's size help speaks of: the one picked in the help, else the one chosen in the editor, else the
|
|
158
|
-
* first that has a size rule. A choice that is not among the parts (removed, or a part with no rule) is passed over.
|
|
159
|
-
*/
|
|
160
|
-
export function setupPartOf(picked: string, chosen: string, targets: string[]): string {
|
|
161
|
-
return [picked, chosen].find(id => !!id && targets.includes(id)) ?? targets[0] ?? ''
|
|
162
|
-
}
|