@things-factory/figure-ui 10.1.83 → 10.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/modeller/command-preview.ts +4 -2
- package/client/modeller/drawn-shapes.ts +29 -0
- package/client/modeller/editor.ts +17 -1
- package/client/modeller/figure-material-panel.ts +2 -3
- package/client/modeller/figure-parts.ts +13 -15
- package/client/modeller/figure-section-panel.ts +304 -0
- package/client/modeller/gizmo.ts +26 -16
- package/client/modeller/joint-fan.ts +4 -3
- package/client/modeller/links.ts +24 -24
- package/client/modeller/live.ts +8 -4
- package/client/modeller/maturity.ts +12 -6
- package/client/modeller/motion-ends.ts +2 -1
- package/client/modeller/refusals.ts +20 -0
- package/client/modeller/renderer.ts +3 -2
- package/client/modeller/section-controls.ts +115 -0
- package/client/modeller/starting-shape.ts +34 -0
- package/dist-client/modeller/command-preview.js +4 -2
- package/dist-client/modeller/command-preview.js.map +1 -1
- package/dist-client/modeller/drawn-shapes.d.ts +44 -0
- package/dist-client/modeller/drawn-shapes.js +12 -0
- package/dist-client/modeller/drawn-shapes.js.map +1 -0
- package/dist-client/modeller/editor.d.ts +3 -0
- package/dist-client/modeller/editor.js +16 -1
- package/dist-client/modeller/editor.js.map +1 -1
- package/dist-client/modeller/figure-capability-panel.d.ts +1 -1
- package/dist-client/modeller/figure-clips.d.ts +1 -1
- package/dist-client/modeller/figure-controls.d.ts +1 -1
- package/dist-client/modeller/figure-links.d.ts +1 -1
- package/dist-client/modeller/figure-material-panel.d.ts +1 -1
- package/dist-client/modeller/figure-material-panel.js +2 -3
- package/dist-client/modeller/figure-material-panel.js.map +1 -1
- package/dist-client/modeller/figure-parts.d.ts +3 -2
- package/dist-client/modeller/figure-parts.js +7 -12
- package/dist-client/modeller/figure-parts.js.map +1 -1
- package/dist-client/modeller/figure-properties.d.ts +1 -1
- package/dist-client/modeller/figure-section-panel.d.ts +42 -0
- package/dist-client/modeller/figure-section-panel.js +289 -0
- package/dist-client/modeller/figure-section-panel.js.map +1 -0
- package/dist-client/modeller/gizmo.d.ts +3 -3
- package/dist-client/modeller/gizmo.js +24 -11
- package/dist-client/modeller/gizmo.js.map +1 -1
- package/dist-client/modeller/joint-fan.js +4 -3
- package/dist-client/modeller/joint-fan.js.map +1 -1
- package/dist-client/modeller/links.d.ts +4 -1
- package/dist-client/modeller/links.js +23 -25
- package/dist-client/modeller/links.js.map +1 -1
- package/dist-client/modeller/live.d.ts +3 -1
- package/dist-client/modeller/live.js +6 -3
- package/dist-client/modeller/live.js.map +1 -1
- package/dist-client/modeller/maturity.d.ts +3 -2
- package/dist-client/modeller/maturity.js +9 -6
- package/dist-client/modeller/maturity.js.map +1 -1
- package/dist-client/modeller/motion-ends.js +2 -1
- package/dist-client/modeller/motion-ends.js.map +1 -1
- package/dist-client/modeller/refusals.d.ts +0 -5
- package/dist-client/modeller/refusals.js +25 -0
- package/dist-client/modeller/refusals.js.map +1 -1
- package/dist-client/modeller/renderer.d.ts +3 -4
- package/dist-client/modeller/renderer.js +3 -2
- package/dist-client/modeller/renderer.js.map +1 -1
- package/dist-client/modeller/section-controls.d.ts +44 -0
- package/dist-client/modeller/section-controls.js +91 -0
- package/dist-client/modeller/section-controls.js.map +1 -0
- package/dist-client/modeller/starting-shape.d.ts +32 -0
- package/dist-client/modeller/starting-shape.js +37 -0
- package/dist-client/modeller/starting-shape.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/test/browser/acceptance-page.js +8 -0
- package/test/command-preview.test.ts +3 -2
- package/test/fixtures/joint-column.json +110 -15
- package/test/fixtures/joint-roller.json +66 -9
- package/test/fixtures/robot-arm-6dof.json +203 -27
- package/test/joint-fan.test.ts +10 -7
- package/test/links.test.ts +4 -4
- package/test/material.test.ts +7 -2
- package/test/palette-icons.test.ts +1 -1
- package/test/parts-wiring.test.ts +6 -2
- package/test/renderer.test.ts +2 -1
- package/test/resize-with-placement.test.ts +3 -3
- package/test/scene-canvas.test.ts +2 -1
- package/test/section-panel.test.ts +192 -0
- package/translations/en.json +24 -0
- package/translations/ja.json +24 -0
- package/translations/ko.json +24 -0
- package/translations/ms.json +24 -0
- package/translations/zh.json +24 -0
- package/dist-client/tsconfig.localkernel.tsbuildinfo +0 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
|
+
import { live } from 'lit/directives/live.js';
|
|
5
|
+
import { i18next, localize } from '@operato/i18n';
|
|
6
|
+
import { SidePanelStyles } from './side-panel-styles.js';
|
|
7
|
+
import { END_FACE, SIDE_FACE, cavityDepthOf, cavityRefusalOf, cavityRequestOf, cavityResultOf, cornerLimitOf, cornerRefusalOf, defaultWallOf, mm, sameOf, sidesOf, sideWallLimitOf, wallLimitOf } from './section-controls.js';
|
|
8
|
+
/**
|
|
9
|
+
* 단면 — a pushed part's rounded corners and its inside (ADR-0100 §3.3).
|
|
10
|
+
*
|
|
11
|
+
* Corners for a rectangle; an inside for a rectangle or an ellipse, with its walls (one thickness, or one per side when
|
|
12
|
+
* asked for), its two ends open or closed, and what that makes of the part and how deep. A drawn section says beside
|
|
13
|
+
* the inside why it has none. A turned body shows nothing here.
|
|
14
|
+
*
|
|
15
|
+
* A value being typed is drawn at once and recorded nowhere (`command-live`); a value the kernel would refuse is said
|
|
16
|
+
* under its field with the most it can be, and is not sent. Enter or leaving the field sends the one `command`, one step
|
|
17
|
+
* of the undo history; Esc puts the value back.
|
|
18
|
+
*/
|
|
19
|
+
let FigureSectionPanel = class FigureSectionPanel extends localize(i18next)(LitElement) {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.locked = false;
|
|
23
|
+
/** What each field would not take, by field, said under it. */
|
|
24
|
+
this.refusals = {};
|
|
25
|
+
/** What is typed in a field and not yet sent, by field: the figure drawn with it must not type over it. */
|
|
26
|
+
this.typed = {};
|
|
27
|
+
/** Walls one per side, asked for or because they already differ. */
|
|
28
|
+
this.perSide = false;
|
|
29
|
+
}
|
|
30
|
+
static { this.styles = [SidePanelStyles, css `
|
|
31
|
+
:host {
|
|
32
|
+
display: block;
|
|
33
|
+
}
|
|
34
|
+
div[row] {
|
|
35
|
+
display: flex;
|
|
36
|
+
gap: 6px;
|
|
37
|
+
align-items: center;
|
|
38
|
+
}
|
|
39
|
+
div[row] > * {
|
|
40
|
+
flex: 1;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
}
|
|
43
|
+
div[sides] {
|
|
44
|
+
display: grid;
|
|
45
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
46
|
+
gap: 6px;
|
|
47
|
+
/* A side's refusal under its field lengthens its cell only: the field beside it stays level. */
|
|
48
|
+
align-items: start;
|
|
49
|
+
}
|
|
50
|
+
div[sides] > label {
|
|
51
|
+
display: grid;
|
|
52
|
+
gap: 2px;
|
|
53
|
+
}
|
|
54
|
+
small[refusal] {
|
|
55
|
+
color: var(--md-sys-color-error);
|
|
56
|
+
}
|
|
57
|
+
input[aria-invalid='true'] {
|
|
58
|
+
outline: 2px solid var(--md-sys-color-error);
|
|
59
|
+
}
|
|
60
|
+
`]; }
|
|
61
|
+
willUpdate(changed) {
|
|
62
|
+
const before = changed.get('body');
|
|
63
|
+
if (changed.has('body') && before?.id !== this.body?.id) {
|
|
64
|
+
this.refusals = {};
|
|
65
|
+
this.typed = {};
|
|
66
|
+
/* A part whose walls already differ opens with them one per side. */
|
|
67
|
+
const walls = this.body?.shape.cavity?.wall;
|
|
68
|
+
this.perSide = !!walls && sameOf(Object.values(walls)) === undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
const body = this.body;
|
|
73
|
+
const e = body?.shape?.provider === 'extrude' ? body.shape.extrusion : undefined;
|
|
74
|
+
if (!body || !e)
|
|
75
|
+
return nothing;
|
|
76
|
+
const kind = e.section.kind;
|
|
77
|
+
return html `<section>
|
|
78
|
+
<h3>${i18next.t('figure.label.group-section')}</h3>
|
|
79
|
+
${kind === 'rectangle' ? this.renderCorner(body) : nothing}
|
|
80
|
+
${kind === 'rectangle' || kind === 'ellipse'
|
|
81
|
+
? this.renderCavity(body, e.axis)
|
|
82
|
+
: html `<div field>
|
|
83
|
+
<small>${i18next.t('figure.text.section-cavity-unavailable')}</small>
|
|
84
|
+
</div>`}
|
|
85
|
+
</section>`;
|
|
86
|
+
}
|
|
87
|
+
renderCorner(body) {
|
|
88
|
+
const d = body.shape.dimensions;
|
|
89
|
+
const reaches = Object.keys(d)
|
|
90
|
+
.filter(k => k.startsWith('corner.'))
|
|
91
|
+
.map(k => d[k]);
|
|
92
|
+
const now = reaches.length ? sameOf(reaches) : 0;
|
|
93
|
+
const max = cornerLimitOf(body.shape);
|
|
94
|
+
return html `<div field>
|
|
95
|
+
<label for="corner">${i18next.t('figure.label.section-corner')}</label>
|
|
96
|
+
${this.number('corner', now, {
|
|
97
|
+
min: 0,
|
|
98
|
+
ask: value => {
|
|
99
|
+
const r = cornerRefusalOf(body.shape, value);
|
|
100
|
+
return r ? i18next.t('figure.text.section-corner-over', { max: String(mm(r.max)) }) : '';
|
|
101
|
+
},
|
|
102
|
+
action: value => ({ kind: 'set-section-corner', part: body.id, corner: value > 0 ? value : null }),
|
|
103
|
+
placeholder: now === undefined ? i18next.t('figure.text.section-corner-differs') : ''
|
|
104
|
+
})}
|
|
105
|
+
${this.refusals.corner ? nothing : max !== undefined ? html `<small>${i18next.t('figure.text.section-at-most', { max: String(mm(max)) })}</small>` : nothing}
|
|
106
|
+
</div>`;
|
|
107
|
+
}
|
|
108
|
+
renderCavity(body, axis) {
|
|
109
|
+
const cavity = body.shape.cavity;
|
|
110
|
+
const request = (patch) => cavityRequestOf(body.shape, patch);
|
|
111
|
+
const said = (ask) => !ask
|
|
112
|
+
? ''
|
|
113
|
+
: ask.code === 'not-positive'
|
|
114
|
+
? i18next.t('figure.text.section-not-positive')
|
|
115
|
+
: i18next.t(`figure.text.section-${ask.code === 'wall-too-thick' ? 'wall' : 'ends'}-over`, { max: String(ask.max) });
|
|
116
|
+
const cavityField = (key, now, patch) => this.number(key, now, {
|
|
117
|
+
min: 0,
|
|
118
|
+
ask: value => {
|
|
119
|
+
if (!(value > 0))
|
|
120
|
+
return i18next.t('figure.text.section-not-positive');
|
|
121
|
+
const ask = cavityRefusalOf(body.shape, request(patch(value)));
|
|
122
|
+
/* One side too thick: the most it can be is the width across less the wall opposite, not the even limit. */
|
|
123
|
+
const side = key.startsWith('wall.') ? key.slice(5) : undefined;
|
|
124
|
+
if (ask?.code === 'wall-too-thick' && side && cavity)
|
|
125
|
+
return said({ code: 'wall-too-thick', max: mm(sideWallLimitOf(body.shape, cavity.wall, side)) });
|
|
126
|
+
return said(ask);
|
|
127
|
+
},
|
|
128
|
+
action: value => ({ kind: 'set-cavity', part: body.id, cavity: request(patch(value)) })
|
|
129
|
+
});
|
|
130
|
+
return html `<div field>
|
|
131
|
+
<label>
|
|
132
|
+
<input
|
|
133
|
+
type="checkbox"
|
|
134
|
+
.checked=${live(!!cavity)}
|
|
135
|
+
?disabled=${this.locked}
|
|
136
|
+
@change=${(ev) => {
|
|
137
|
+
const on = ev.target.checked;
|
|
138
|
+
ev.target.checked = !!cavity;
|
|
139
|
+
this.command({ kind: 'set-cavity', part: body.id, cavity: on ? request({}) : null });
|
|
140
|
+
}}
|
|
141
|
+
/>
|
|
142
|
+
${i18next.t('figure.label.section-cavity')}
|
|
143
|
+
</label>
|
|
144
|
+
${cavity
|
|
145
|
+
? html `<small result>
|
|
146
|
+
${i18next.t('figure.text.section-depth', {
|
|
147
|
+
result: i18next.t(`figure.label.section-result-${cavityResultOf(cavity)}`),
|
|
148
|
+
depth: String(cavityDepthOf(body.shape))
|
|
149
|
+
})}
|
|
150
|
+
</small>`
|
|
151
|
+
: nothing}
|
|
152
|
+
</div>
|
|
153
|
+
${cavity
|
|
154
|
+
? html `<div field>
|
|
155
|
+
<label>${i18next.t('figure.label.section-wall')}</label>
|
|
156
|
+
${this.perSide
|
|
157
|
+
? html `<div sides>
|
|
158
|
+
${[...sidesOf(axis)].sort((a, b) => a[0].localeCompare(b[0]) || (a[1] === '-' ? -1 : 1)).map(side => html `<label>
|
|
159
|
+
<span>${i18next.t('figure.label.face-' + SIDE_FACE[side])}</span>
|
|
160
|
+
${cavityField(`wall.${side}`, cavity.wall[side], value => ({ wall: { ...cavity.wall, [side]: value } }))}
|
|
161
|
+
</label>`)}
|
|
162
|
+
</div>`
|
|
163
|
+
: cavityField('wall', sameOf(Object.values(cavity.wall)), value => ({ wall: value }))}
|
|
164
|
+
${this.perSide || this.refusals.wall
|
|
165
|
+
? nothing
|
|
166
|
+
: html `<small>${i18next.t('figure.text.section-wall-at-most', { max: String(mm(wallLimitOf(body.shape))) })}</small>`}
|
|
167
|
+
<label>
|
|
168
|
+
<input
|
|
169
|
+
type="checkbox"
|
|
170
|
+
.checked=${live(this.perSide)}
|
|
171
|
+
?disabled=${this.locked}
|
|
172
|
+
@change=${(ev) => (this.perSide = ev.target.checked)}
|
|
173
|
+
/>
|
|
174
|
+
${i18next.t('figure.label.section-wall-per-side')}
|
|
175
|
+
</label>
|
|
176
|
+
</div>
|
|
177
|
+
${['start', 'end'].map(end => this.renderEnd(body, axis, end, cavity[end], request, cavityField))}`
|
|
178
|
+
: nothing}`;
|
|
179
|
+
}
|
|
180
|
+
renderEnd(body, axis, end, now, request, cavityField) {
|
|
181
|
+
const closed = now !== 'open';
|
|
182
|
+
return html `<div field>
|
|
183
|
+
<label>${i18next.t('figure.label.face-' + END_FACE(axis, end))}</label>
|
|
184
|
+
<div row>
|
|
185
|
+
<select
|
|
186
|
+
.value=${live(closed ? 'closed' : 'open')}
|
|
187
|
+
?disabled=${this.locked}
|
|
188
|
+
@change=${(ev) => {
|
|
189
|
+
const select = ev.target;
|
|
190
|
+
const want = select.value;
|
|
191
|
+
select.value = closed ? 'closed' : 'open';
|
|
192
|
+
this.command({ kind: 'set-cavity', part: body.id, cavity: request({ [end]: want === 'open' ? 'open' : { closed: defaultWallOf(body.shape) } }) });
|
|
193
|
+
}}
|
|
194
|
+
>
|
|
195
|
+
<option value="closed">${i18next.t('figure.label.section-end-closed')}</option>
|
|
196
|
+
<option value="open">${i18next.t('figure.label.section-end-open')}</option>
|
|
197
|
+
</select>
|
|
198
|
+
${closed ? cavityField(`closed.${end}`, now.closed, value => ({ [end]: { closed: value } })) : html `<span></span>`}
|
|
199
|
+
</div>
|
|
200
|
+
</div>`;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A millimetre field. Typing draws the value (or, if the kernel would refuse it, says why under the field and draws the
|
|
204
|
+
* figure as it stands); Enter or leaving sends it once; Esc puts the value back.
|
|
205
|
+
*/
|
|
206
|
+
number(key, now, o) {
|
|
207
|
+
const shown = now === undefined ? '' : String(mm(now));
|
|
208
|
+
const done = () => {
|
|
209
|
+
const { [key]: _, ...rest } = this.typed;
|
|
210
|
+
this.typed = rest;
|
|
211
|
+
};
|
|
212
|
+
const read = (input) => (input.value === '' ? NaN : Number(input.value));
|
|
213
|
+
const judge = (input) => {
|
|
214
|
+
const value = read(input);
|
|
215
|
+
const refusal = !Number.isFinite(value) || value < o.min ? '' : o.ask(value);
|
|
216
|
+
this.refusals = { ...this.refusals, [key]: refusal };
|
|
217
|
+
return Number.isFinite(value) && value >= o.min && !refusal ? value : undefined;
|
|
218
|
+
};
|
|
219
|
+
return html `<input
|
|
220
|
+
id=${key}
|
|
221
|
+
type="number"
|
|
222
|
+
min=${o.min}
|
|
223
|
+
step="any"
|
|
224
|
+
inputmode="decimal"
|
|
225
|
+
.value=${live(this.typed[key] ?? shown)}
|
|
226
|
+
placeholder=${o.placeholder ?? ''}
|
|
227
|
+
aria-invalid=${this.refusals[key] ? 'true' : 'false'}
|
|
228
|
+
aria-describedby=${`${key}-refusal`}
|
|
229
|
+
?disabled=${this.locked}
|
|
230
|
+
@input=${(ev) => {
|
|
231
|
+
this.typed = { ...this.typed, [key]: ev.target.value };
|
|
232
|
+
const value = judge(ev.target);
|
|
233
|
+
this.preview(value === undefined ? null : o.action(value));
|
|
234
|
+
}}
|
|
235
|
+
@change=${(ev) => {
|
|
236
|
+
const input = ev.target;
|
|
237
|
+
if (input.value === shown)
|
|
238
|
+
return done(), this.preview(null);
|
|
239
|
+
const value = judge(input);
|
|
240
|
+
/* A refused value stays typed with its reason under it, to be corrected; nothing is sent. */
|
|
241
|
+
if (value === undefined)
|
|
242
|
+
return this.preview(null);
|
|
243
|
+
done();
|
|
244
|
+
this.command(o.action(value));
|
|
245
|
+
}}
|
|
246
|
+
@keydown=${(ev) => {
|
|
247
|
+
if (ev.key !== 'Escape')
|
|
248
|
+
return;
|
|
249
|
+
const input = ev.target;
|
|
250
|
+
input.value = shown;
|
|
251
|
+
done();
|
|
252
|
+
this.refusals = { ...this.refusals, [key]: '' };
|
|
253
|
+
this.preview(null);
|
|
254
|
+
}}
|
|
255
|
+
/>
|
|
256
|
+
${this.refusals[key] ? html `<small refusal id=${`${key}-refusal`} role="alert">${this.refusals[key]}</small>` : nothing}`;
|
|
257
|
+
}
|
|
258
|
+
preview(action) {
|
|
259
|
+
this.dispatchEvent(new CustomEvent('command-live', { detail: { action }, bubbles: true, composed: true }));
|
|
260
|
+
}
|
|
261
|
+
command(action) {
|
|
262
|
+
this.dispatchEvent(new CustomEvent('command', { detail: { action }, bubbles: true, composed: true }));
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
__decorate([
|
|
266
|
+
property({ attribute: false }),
|
|
267
|
+
__metadata("design:type", Object)
|
|
268
|
+
], FigureSectionPanel.prototype, "body", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
property({ type: Boolean }),
|
|
271
|
+
__metadata("design:type", Object)
|
|
272
|
+
], FigureSectionPanel.prototype, "locked", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
state(),
|
|
275
|
+
__metadata("design:type", Object)
|
|
276
|
+
], FigureSectionPanel.prototype, "refusals", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
state(),
|
|
279
|
+
__metadata("design:type", Object)
|
|
280
|
+
], FigureSectionPanel.prototype, "typed", void 0);
|
|
281
|
+
__decorate([
|
|
282
|
+
state(),
|
|
283
|
+
__metadata("design:type", Object)
|
|
284
|
+
], FigureSectionPanel.prototype, "perSide", void 0);
|
|
285
|
+
FigureSectionPanel = __decorate([
|
|
286
|
+
customElement('figure-section-panel')
|
|
287
|
+
], FigureSectionPanel);
|
|
288
|
+
export { FigureSectionPanel };
|
|
289
|
+
//# sourceMappingURL=figure-section-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure-section-panel.js","sourceRoot":"","sources":["../../client/modeller/figure-section-panel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,eAAe,EACf,aAAa,EACb,EAAE,EACF,MAAM,EACN,OAAO,EACP,eAAe,EACf,WAAW,EAEZ,MAAM,uBAAuB,CAAA;AAM9B;;;;;;;;;;GAUG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;IAA9D;;QAkCwB,WAAM,GAAG,KAAK,CAAA;QAC3C,+DAA+D;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, state } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport type { FigureAuthoringAction, FigureCavityRequest, FigureEvaluatedShape } from '@hatiolab/figure-model'\nimport { SidePanelStyles } from './side-panel-styles.js'\nimport {\n END_FACE,\n SIDE_FACE,\n cavityDepthOf,\n cavityRefusalOf,\n cavityRequestOf,\n cavityResultOf,\n cornerLimitOf,\n cornerRefusalOf,\n defaultWallOf,\n mm,\n sameOf,\n sidesOf,\n sideWallLimitOf,\n wallLimitOf,\n type FigureCavityAsk\n} from './section-controls.js'\n\ntype Axis = 'x' | 'y' | 'z'\ntype End = 'start' | 'end'\ntype Body = { id: string; shape: FigureEvaluatedShape }\n\n/**\n * 단면 — a pushed part's rounded corners and its inside (ADR-0100 §3.3).\n *\n * Corners for a rectangle; an inside for a rectangle or an ellipse, with its walls (one thickness, or one per side when\n * asked for), its two ends open or closed, and what that makes of the part and how deep. A drawn section says beside\n * the inside why it has none. A turned body shows nothing here.\n *\n * A value being typed is drawn at once and recorded nowhere (`command-live`); a value the kernel would refuse is said\n * under its field with the most it can be, and is not sent. Enter or leaving the field sends the one `command`, one step\n * of the undo history; Esc puts the value back.\n */\n@customElement('figure-section-panel')\nexport class FigureSectionPanel extends localize(i18next)(LitElement) {\n static styles = [SidePanelStyles, css`\n :host {\n display: block;\n }\n div[row] {\n display: flex;\n gap: 6px;\n align-items: center;\n }\n div[row] > * {\n flex: 1;\n min-width: 0;\n }\n div[sides] {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 6px;\n /* A side's refusal under its field lengthens its cell only: the field beside it stays level. */\n align-items: start;\n }\n div[sides] > label {\n display: grid;\n gap: 2px;\n }\n small[refusal] {\n color: var(--md-sys-color-error);\n }\n input[aria-invalid='true'] {\n outline: 2px solid var(--md-sys-color-error);\n }\n `]\n\n @property({ attribute: false }) body?: Body\n @property({ type: Boolean }) locked = false\n /** What each field would not take, by field, said under it. */\n @state() private refusals: Record<string, string> = {}\n /** What is typed in a field and not yet sent, by field: the figure drawn with it must not type over it. */\n @state() private typed: Record<string, string> = {}\n /** Walls one per side, asked for or because they already differ. */\n @state() private perSide = false\n\n protected willUpdate(changed: PropertyValues<this>) {\n const before = changed.get('body') as Body | undefined\n if (changed.has('body') && before?.id !== this.body?.id) {\n this.refusals = {}\n this.typed = {}\n /* A part whose walls already differ opens with them one per side. */\n const walls = this.body?.shape.cavity?.wall\n this.perSide = !!walls && sameOf(Object.values(walls)) === undefined\n }\n }\n\n render() {\n const body = this.body\n const e = body?.shape?.provider === 'extrude' ? body.shape.extrusion : undefined\n if (!body || !e) return nothing\n const kind = e.section.kind\n return html`<section>\n <h3>${i18next.t('figure.label.group-section')}</h3>\n ${kind === 'rectangle' ? this.renderCorner(body) : nothing}\n ${kind === 'rectangle' || kind === 'ellipse'\n ? this.renderCavity(body, e.axis)\n : html`<div field>\n <small>${i18next.t('figure.text.section-cavity-unavailable')}</small>\n </div>`}\n </section>`\n }\n\n private renderCorner(body: Body) {\n const d = body.shape.dimensions\n const reaches = Object.keys(d)\n .filter(k => k.startsWith('corner.'))\n .map(k => d[k])\n const now = reaches.length ? sameOf(reaches) : 0\n const max = cornerLimitOf(body.shape)\n return html`<div field>\n <label for=\"corner\">${i18next.t('figure.label.section-corner')}</label>\n ${this.number('corner', now, {\n min: 0,\n ask: value => {\n const r = cornerRefusalOf(body.shape, value)\n return r ? i18next.t('figure.text.section-corner-over', { max: String(mm(r.max)) }) : ''\n },\n action: value => ({ kind: 'set-section-corner', part: body.id, corner: value > 0 ? value : null }),\n placeholder: now === undefined ? i18next.t('figure.text.section-corner-differs') : ''\n })}\n ${this.refusals.corner ? nothing : max !== undefined ? html`<small>${i18next.t('figure.text.section-at-most', { max: String(mm(max)) })}</small>` : nothing}\n </div>`\n }\n\n private renderCavity(body: Body, axis: Axis) {\n const cavity = body.shape.cavity\n const request = (patch: Partial<FigureCavityRequest>) => cavityRequestOf(body.shape, patch)\n const said = (ask: FigureCavityAsk | null) =>\n !ask\n ? ''\n : ask.code === 'not-positive'\n ? i18next.t('figure.text.section-not-positive')\n : i18next.t(`figure.text.section-${ask.code === 'wall-too-thick' ? 'wall' : 'ends'}-over`, { max: String(ask.max) })\n const cavityField = (key: string, now: number | undefined, patch: (value: number) => Partial<FigureCavityRequest>) =>\n this.number(key, now, {\n min: 0,\n ask: value => {\n if (!(value > 0)) return i18next.t('figure.text.section-not-positive')\n const ask = cavityRefusalOf(body.shape, request(patch(value)))\n /* One side too thick: the most it can be is the width across less the wall opposite, not the even limit. */\n const side = key.startsWith('wall.') ? key.slice(5) : undefined\n if (ask?.code === 'wall-too-thick' && side && cavity)\n return said({ code: 'wall-too-thick', max: mm(sideWallLimitOf(body.shape, cavity.wall, side)) })\n return said(ask)\n },\n action: value => ({ kind: 'set-cavity', part: body.id, cavity: request(patch(value)) })\n })\n return html`<div field>\n <label>\n <input\n type=\"checkbox\"\n .checked=${live(!!cavity)}\n ?disabled=${this.locked}\n @change=${(ev: Event) => {\n const on = (ev.target as HTMLInputElement).checked\n ;(ev.target as HTMLInputElement).checked = !!cavity\n this.command({ kind: 'set-cavity', part: body.id, cavity: on ? request({}) : null })\n }}\n />\n ${i18next.t('figure.label.section-cavity')}\n </label>\n ${cavity\n ? html`<small result>\n ${i18next.t('figure.text.section-depth', {\n result: i18next.t(`figure.label.section-result-${cavityResultOf(cavity)}`),\n depth: String(cavityDepthOf(body.shape))\n })}\n </small>`\n : nothing}\n </div>\n ${cavity\n ? html`<div field>\n <label>${i18next.t('figure.label.section-wall')}</label>\n ${this.perSide\n ? html`<div sides>\n ${[...sidesOf(axis)].sort((a, b) => a[0]!.localeCompare(b[0]!) || (a[1] === '-' ? -1 : 1)).map(\n side => html`<label>\n <span>${i18next.t('figure.label.face-' + SIDE_FACE[side])}</span>\n ${cavityField(`wall.${side}`, cavity.wall[side], value => ({ wall: { ...cavity.wall, [side]: value } }))}\n </label>`\n )}\n </div>`\n : cavityField('wall', sameOf(Object.values(cavity.wall)), value => ({ wall: value }))}\n ${this.perSide || this.refusals.wall\n ? nothing\n : html`<small>${i18next.t('figure.text.section-wall-at-most', { max: String(mm(wallLimitOf(body.shape))) })}</small>`}\n <label>\n <input\n type=\"checkbox\"\n .checked=${live(this.perSide)}\n ?disabled=${this.locked}\n @change=${(ev: Event) => (this.perSide = (ev.target as HTMLInputElement).checked)}\n />\n ${i18next.t('figure.label.section-wall-per-side')}\n </label>\n </div>\n ${(['start', 'end'] as const).map(end => this.renderEnd(body, axis, end, cavity[end], request, cavityField))}`\n : nothing}`\n }\n\n private renderEnd(\n body: Body,\n axis: Axis,\n end: End,\n now: 'open' | { closed: number },\n request: (patch: Partial<FigureCavityRequest>) => FigureCavityRequest,\n cavityField: (key: string, now: number | undefined, patch: (value: number) => Partial<FigureCavityRequest>) => unknown\n ) {\n const closed = now !== 'open'\n return html`<div field>\n <label>${i18next.t('figure.label.face-' + END_FACE(axis, end))}</label>\n <div row>\n <select\n .value=${live(closed ? 'closed' : 'open')}\n ?disabled=${this.locked}\n @change=${(ev: Event) => {\n const select = ev.target as HTMLSelectElement\n const want = select.value\n select.value = closed ? 'closed' : 'open'\n this.command({ kind: 'set-cavity', part: body.id, cavity: request({ [end]: want === 'open' ? 'open' : { closed: defaultWallOf(body.shape) } }) })\n }}\n >\n <option value=\"closed\">${i18next.t('figure.label.section-end-closed')}</option>\n <option value=\"open\">${i18next.t('figure.label.section-end-open')}</option>\n </select>\n ${closed ? cavityField(`closed.${end}`, now.closed, value => ({ [end]: { closed: value } })) : html`<span></span>`}\n </div>\n </div>`\n }\n\n /**\n * A millimetre field. Typing draws the value (or, if the kernel would refuse it, says why under the field and draws the\n * figure as it stands); Enter or leaving sends it once; Esc puts the value back.\n */\n private number(\n key: string,\n now: number | undefined,\n o: { min: number; ask: (value: number) => string; action: (value: number) => FigureAuthoringAction; placeholder?: string }\n ) {\n const shown = now === undefined ? '' : String(mm(now))\n const done = () => {\n const { [key]: _, ...rest } = this.typed\n this.typed = rest\n }\n const read = (input: HTMLInputElement) => (input.value === '' ? NaN : Number(input.value))\n const judge = (input: HTMLInputElement) => {\n const value = read(input)\n const refusal = !Number.isFinite(value) || value < o.min ? '' : o.ask(value)\n this.refusals = { ...this.refusals, [key]: refusal }\n return Number.isFinite(value) && value >= o.min && !refusal ? value : undefined\n }\n return html`<input\n id=${key}\n type=\"number\"\n min=${o.min}\n step=\"any\"\n inputmode=\"decimal\"\n .value=${live(this.typed[key] ?? shown)}\n placeholder=${o.placeholder ?? ''}\n aria-invalid=${this.refusals[key] ? 'true' : 'false'}\n aria-describedby=${`${key}-refusal`}\n ?disabled=${this.locked}\n @input=${(ev: Event) => {\n this.typed = { ...this.typed, [key]: (ev.target as HTMLInputElement).value }\n const value = judge(ev.target as HTMLInputElement)\n this.preview(value === undefined ? null : o.action(value))\n }}\n @change=${(ev: Event) => {\n const input = ev.target as HTMLInputElement\n if (input.value === shown) return done(), this.preview(null)\n const value = judge(input)\n /* A refused value stays typed with its reason under it, to be corrected; nothing is sent. */\n if (value === undefined) return this.preview(null)\n done()\n this.command(o.action(value))\n }}\n @keydown=${(ev: KeyboardEvent) => {\n if (ev.key !== 'Escape') return\n const input = ev.target as HTMLInputElement\n input.value = shown\n done()\n this.refusals = { ...this.refusals, [key]: '' }\n this.preview(null)\n }}\n />\n ${this.refusals[key] ? html`<small refusal id=${`${key}-refusal`} role=\"alert\">${this.refusals[key]}</small>` : nothing}`\n }\n\n private preview(action: FigureAuthoringAction | null) {\n this.dispatchEvent(new CustomEvent('command-live', { detail: { action }, bubbles: true, composed: true }))\n }\n\n private command(action: FigureAuthoringAction) {\n this.dispatchEvent(new CustomEvent('command', { detail: { action }, bubbles: true, composed: true }))\n }\n}\n"]}
|
|
@@ -3,9 +3,9 @@ import type { FigureInputChange } from '@hatiolab/figure-model';
|
|
|
3
3
|
* What the gizmo may write for a part: move · turn · size, on a asset.
|
|
4
4
|
*
|
|
5
5
|
* A drag can only be written back where the part is placed by its own numbers. A part the create commands made is:
|
|
6
|
-
* its pose is `rigid@1` into the asset frame from `<part>.position.*` and `<part>.rotation.*`, and
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* its pose is `rigid@1` into the asset frame from `<part>.position.*` and `<part>.rotation.*`, and its shape takes its
|
|
7
|
+
* measures from inputs of its own — `<part>.size.*` from `addFigureBox`, `<part>.dimension.*` from the editor's shape
|
|
8
|
+
* palette — at the arguments the shape itself names (figure-model's provider). A part fastened to another, following an instance size or placed by
|
|
9
9
|
* expressions has no such numbers; the gizmo does not offer what it could not write back, rather
|
|
10
10
|
* than move something the next evaluation would put back.
|
|
11
11
|
*/
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { figureAttachmentsOf } from '@hatiolab/figure-model';
|
|
2
|
-
/** Shapes whose first three arguments are the extent along X, Y and Z: a door frame's too (its width, height, depth). */
|
|
3
|
-
const BOXES = new Set(['box-shape@1', 'rounded-box@1', 'portal-profile@2', 'hollow-box@2']);
|
|
1
|
+
import { figureAttachmentsOf, figureShapeProviderOf } from '@hatiolab/figure-model';
|
|
4
2
|
const AXES = ['x', 'y', 'z'];
|
|
5
3
|
export function gizmoReachOf(asset, part) {
|
|
6
4
|
const { nodes, inputs } = asset.document.model;
|
|
@@ -21,14 +19,29 @@ export function gizmoReachOf(asset, part) {
|
|
|
21
19
|
const posed = direct || reseated;
|
|
22
20
|
const shape = nodes.find(node => node.id === `${part}.shape`);
|
|
23
21
|
const mine = (ids) => ids.every(id => id.startsWith(`${part}.`) && design.has(id));
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
22
|
+
/*
|
|
23
|
+
Which argument sizes the part along X, Y and Z: the shape says (figure-model's provider, ADR-0100) -- never its first
|
|
24
|
+
three arguments. A round section written from one radius, a sphere and a taper keep their shape: their radii take one
|
|
25
|
+
factor together.
|
|
26
|
+
*/
|
|
27
|
+
const provider = shape ? figureShapeProviderOf(shape) : undefined;
|
|
28
|
+
const edit = provider?.edit;
|
|
29
|
+
const refOf = (axis) => {
|
|
30
|
+
const e = edit?.[axis];
|
|
31
|
+
return e && !('refused' in e) ? shape.args[e.arg] : undefined;
|
|
32
|
+
};
|
|
33
|
+
const measures = AXES.map(refOf);
|
|
34
|
+
const shared = !!edit && AXES.some(axis => { const e = edit[axis]; return !('refused' in e) && !!(e.sameAs || e.with?.length); });
|
|
35
|
+
let round;
|
|
36
|
+
if (shared && edit) {
|
|
37
|
+
const withs = AXES.flatMap(axis => { const e = edit[axis]; return !('refused' in e) ? (e.with ?? []).map(i => shape.args[i]) : []; });
|
|
38
|
+
const sphere = !!provider && Object.keys(provider.faces).length === 0;
|
|
39
|
+
const across = [...new Set([refOf('x'), ...withs])];
|
|
40
|
+
const along = sphere ? [] : [refOf('y')];
|
|
41
|
+
if ([...across, ...along].every(id => id && mine([id])))
|
|
42
|
+
round = { across: sphere ? [...new Set([...across, refOf('y')])] : across, along };
|
|
43
|
+
}
|
|
44
|
+
const extent = !round && measures.every(Boolean) ? measures : [];
|
|
32
45
|
const sizes = extent.length === 3 && extent.every(id => id.startsWith(`${part}.`) && design.has(id)) ? extent : undefined;
|
|
33
46
|
/*
|
|
34
47
|
The part's own measure, also when another reads it: a measure some other part follows is read through a node of its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gizmo.js","sourceRoot":"","sources":["../../client/modeller/gizmo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AA+B5D,yHAAyH;AACzH,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAA;AAa3F,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAA;AAErC,MAAM,UAAU,YAAY,CAAC,KAAgB,EAAE,IAAY;IACzD,MAAM,EAAE,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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC5G,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAA;QAC7C,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAG,EAAE,EAAG,EAAE,EAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAG,EAAE,EAAG,CAAC,CAAC,CAAA;QAChE,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM;YAAE,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,SAAS;gBAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QAC7H,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK;YAAE,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,SAAS;gBAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,GAAG,EAAG,CAAC,CAAC,CAAC,CAAA;IAC3H,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { figureAttachmentsOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureInputChange } from '@hatiolab/figure-model'\n\n/**\n * What the gizmo may write for a part: move · turn · size, on a asset.\n *\n * A drag can only be written back where the part is placed by its own numbers. A part the create commands made is:\n * its pose is `rigid@1` into the asset frame from `<part>.position.*` and `<part>.rotation.*`, and a box's shape\n * (`box-shape@1` or `rounded-box@1`) takes its width, height and depth from inputs of its own — `<part>.size.*` from\n * `addFigureBox`, `<part>.dimension.*` from the editor's shape palette. A part fastened to another, following an instance size or placed by\n * expressions has no such numbers; the gizmo does not offer what it could not write back, rather\n * than move something the next evaluation would put back.\n */\nexport interface GizmoReach {\n translate: boolean\n rotate: boolean\n scale: boolean\n /** The inputs sizing the part along X, Y and Z, when it can be sized. */\n sizes?: [string, string, string]\n /**\n * Per axis, the part's own measure, or null where the measure follows another (a square section's depth following\n * its width): a scale drag writes the own ones and leaves a followed one to what it follows.\n */\n ownSizes?: (string | null)[]\n /**\n * A round part keeps its section round: the radii across (X and Z) take the one factor\n * the drag gave most; the length along Y takes its own. A sphere's three radii take one factor together.\n */\n round?: { across: string[]; along: string[] }\n}\n\n/** Shapes whose first three arguments are the extent along X, Y and Z: a door frame's too (its width, height, depth). */\nconst BOXES = new Set(['box-shape@1', 'rounded-box@1', 'portal-profile@2', 'hollow-box@2'])\n\ninterface Node {\n id: string\n op: string\n args: string[]\n outputs?: Record<string, string>\n params?: Record<string, unknown>\n}\ninterface AssetLike {\n document: { model: { nodes: Node[]; inputs: Array<{ id: string; role?: string }>; constants?: Array<{ id: string; value: number }> } }\n}\n\nconst AXES = ['x', 'y', 'z'] as const\n\nexport function gizmoReachOf(asset: AssetLike, part: string): GizmoReach {\n const { nodes, inputs } = asset.document.model\n const design = new Set(inputs.filter(input => input.role === 'design').map(input => input.id))\n const own = (name: string) => AXES.map(axis => `${part}.${name}.${axis}`)\n const allDesign = (ids: string[]) => ids.every(id => design.has(id))\n const pose = nodes.find(node => node.id === `${part}.pose`)\n const placed = nodes.find(node => node.id === part && node.op === 'place@1')\n const direct = !!pose && pose.op === 'rigid@1' && pose.params?.to === 'asset' && placed?.args[1] === `${part}.poseValue`\n /*\n A part taken off another (detach) stands on a seat into the asset frame with its own position numbers back. It\n can be moved like a part never fastened — unless it moves by itself, when where it is drawn is not its position.\n */\n const reseated =\n !!pose &&\n pose.op === 'rigid@1' &&\n !nodes.some(node => node.id === `${part}.motion`) &&\n figureAttachmentsOf(asset as unknown as FigureAsset)[part] === null\n const posed = direct || reseated\n const shape = nodes.find(node => node.id === `${part}.shape`)\n const mine = (ids: string[]) => ids.every(id => id.startsWith(`${part}.`) && design.has(id))\n const round =\n shape?.op === 'cylinder-shape@1' && mine(shape.args.slice(0, 2))\n ? { across: [shape.args[0]!], along: [shape.args[1]!] }\n : shape?.op === 'frustum-shape@1' && mine(shape.args.slice(0, 3))\n ? { across: shape.args.slice(0, 2), along: [shape.args[2]!] }\n : shape?.op === 'sphere-shape@1' && mine(shape.args.slice(0, 3))\n ? { across: shape.args.slice(0, 3), along: [] }\n : undefined\n const extent = shape && BOXES.has(shape.op) ? shape.args.slice(0, 3) : []\n const sizes =\n extent.length === 3 && extent.every(id => id.startsWith(`${part}.`) && design.has(id)) ? (extent as [string, string, string]) : undefined\n /*\n The part's own measure, also when another reads it: a measure some other part follows is read through a node of its\n own times 1 (`link-dimension`), and it is still the author's number -- the upper arm's width, which the forearm\n follows, is the upper arm's to drag.\n */\n const constants = asset.document.model.constants ?? []\n const ownMeasure = (id: string): string | null => {\n if (id.startsWith(`${part}.`) && design.has(id)) return id\n const writer = nodes.find(node => Object.values(node.outputs ?? {}).includes(id))\n const one = writer?.op === 'mul@1' && writer.args.length === 2 && constants.find(c => c.id === writer.args[1])?.value === 1\n return one && writer!.args[0]!.startsWith(`${part}.`) && design.has(writer!.args[0]!) ? writer!.args[0]! : null\n }\n const ownSizes = extent.length === 3 && !sizes ? extent.map(ownMeasure) : undefined\n const someOwn = !!ownSizes?.some(Boolean)\n return {\n translate: posed && allDesign(own('position')) && own('position').every((id, i) => pose!.args[i] === id),\n rotate: posed && allDesign(own('rotation')) && own('rotation').every((id, i) => pose!.args[3 + i] === id),\n scale: !!sizes || !!round || someOwn,\n ...(sizes ? { sizes } : {}),\n ...(someOwn ? { ownSizes } : {}),\n ...(round ? { round } : {})\n }\n}\n\n/** Where a drag left the part, in the asset frame: millimetres, degrees and per-axis scale. */\nexport interface GizmoResult {\n position?: [number, number, number]\n rotation?: [number, number, number]\n scale?: [number, number, number]\n}\n\n/**\n * The input changes a drag makes — one list, applied as one step. Millimetres to the millimetre and degrees to a\n * tenth (a drag otherwise stores 722.4180046035418 mm). A size never goes below 1 mm.\n */\nexport function gizmoChanges(part: string, reach: GizmoReach, result: GizmoResult, sizes: Record<string, number>): FigureInputChange[] {\n const changes: FigureInputChange[] = []\n const put = (input: string, unit: FigureInputChange['unit'], value: number) =>\n changes.push({ kind: 'set-design', input, unit, value } as FigureInputChange)\n if (result.position && reach.translate)\n AXES.forEach((axis, i) => put(`${part}.position.${axis}`, 'mm', Math.round(result.position![i]!)))\n if (result.rotation && reach.rotate)\n AXES.forEach((axis, i) => put(`${part}.rotation.${axis}`, 'deg', Math.round(result.rotation![i]! * 10) / 10))\n if (result.scale && reach.scale && reach.sizes)\n reach.sizes.forEach((id, i) => {\n if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * result.scale![i]!)))\n })\n if (result.scale && reach.scale && reach.ownSizes)\n reach.ownSizes.forEach((id, i) => {\n if (id && sizes[id] !== undefined && Math.abs(result.scale![i]! - 1) > 1e-4) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * result.scale![i]!)))\n })\n if (result.scale && reach.scale && reach.round) {\n const [sx, sy, sz] = result.scale\n /* The factor the drag moved most: across for a cylinder (X or Z), any axis for a sphere. */\n const most = (factors: number[]) => factors.reduce((a, b) => (Math.abs(b - 1) > Math.abs(a - 1) ? b : a), 1)\n const sphere = reach.round.along.length === 0\n const across = sphere ? most([sx!, sy!, sz!]) : most([sx!, sz!])\n for (const id of reach.round.across) if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * across)))\n for (const id of reach.round.along) if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * sy!)))\n }\n return changes\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gizmo.js","sourceRoot":"","sources":["../../client/modeller/gizmo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB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C,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC5G,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAA;QAC7C,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAG,EAAE,EAAG,EAAE,EAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAG,EAAE,EAAG,CAAC,CAAC,CAAA;QAChE,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM;YAAE,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,SAAS;gBAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QAC7H,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK;YAAE,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,SAAS;gBAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,GAAG,EAAG,CAAC,CAAC,CAAC,CAAA;IAC3H,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import { figureAttachmentsOf, figureShapeProviderOf } from '@hatiolab/figure-model'\nimport type { FigureAsset, FigureInputChange } from '@hatiolab/figure-model'\n\n/**\n * What the gizmo may write for a part: move · turn · size, on a asset.\n *\n * A drag can only be written back where the part is placed by its own numbers. A part the create commands made is:\n * its pose is `rigid@1` into the asset frame from `<part>.position.*` and `<part>.rotation.*`, and its shape takes its\n * measures from inputs of its own — `<part>.size.*` from `addFigureBox`, `<part>.dimension.*` from the editor's shape\n * palette — at the arguments the shape itself names (figure-model's provider). A part fastened to another, following an instance size or placed by\n * expressions has no such numbers; the gizmo does not offer what it could not write back, rather\n * than move something the next evaluation would put back.\n */\nexport interface GizmoReach {\n translate: boolean\n rotate: boolean\n scale: boolean\n /** The inputs sizing the part along X, Y and Z, when it can be sized. */\n sizes?: [string, string, string]\n /**\n * Per axis, the part's own measure, or null where the measure follows another (a square section's depth following\n * its width): a scale drag writes the own ones and leaves a followed one to what it follows.\n */\n ownSizes?: (string | null)[]\n /**\n * A round part keeps its section round: the radii across (X and Z) take the one factor\n * the drag gave most; the length along Y takes its own. A sphere's three radii take one factor together.\n */\n round?: { across: string[]; along: string[] }\n}\n\ninterface Node {\n id: string\n op: string\n args: string[]\n outputs?: Record<string, string>\n params?: Record<string, unknown>\n}\ninterface AssetLike {\n document: { model: { nodes: Node[]; inputs: Array<{ id: string; role?: string }>; constants?: Array<{ id: string; value: number }> } }\n}\n\nconst AXES = ['x', 'y', 'z'] as const\n\nexport function gizmoReachOf(asset: AssetLike, part: string): GizmoReach {\n const { nodes, inputs } = asset.document.model\n const design = new Set(inputs.filter(input => input.role === 'design').map(input => input.id))\n const own = (name: string) => AXES.map(axis => `${part}.${name}.${axis}`)\n const allDesign = (ids: string[]) => ids.every(id => design.has(id))\n const pose = nodes.find(node => node.id === `${part}.pose`)\n const placed = nodes.find(node => node.id === part && node.op === 'place@1')\n const direct = !!pose && pose.op === 'rigid@1' && pose.params?.to === 'asset' && placed?.args[1] === `${part}.poseValue`\n /*\n A part taken off another (detach) stands on a seat into the asset frame with its own position numbers back. It\n can be moved like a part never fastened — unless it moves by itself, when where it is drawn is not its position.\n */\n const reseated =\n !!pose &&\n pose.op === 'rigid@1' &&\n !nodes.some(node => node.id === `${part}.motion`) &&\n figureAttachmentsOf(asset as unknown as FigureAsset)[part] === null\n const posed = direct || reseated\n const shape = nodes.find(node => node.id === `${part}.shape`)\n const mine = (ids: string[]) => ids.every(id => id.startsWith(`${part}.`) && design.has(id))\n /*\n Which argument sizes the part along X, Y and Z: the shape says (figure-model's provider, ADR-0100) -- never its first\n three arguments. A round section written from one radius, a sphere and a taper keep their shape: their radii take one\n factor together.\n */\n const provider = shape ? figureShapeProviderOf(shape as never) : undefined\n const edit = provider?.edit\n const refOf = (axis: 'x' | 'y' | 'z') => {\n const e = edit?.[axis]\n return e && !('refused' in e) ? shape!.args[e.arg]! : undefined\n }\n const measures = AXES.map(refOf)\n const shared = !!edit && AXES.some(axis => { const e = edit[axis]; return !('refused' in e) && !!(e.sameAs || e.with?.length) })\n let round: GizmoReach['round']\n if (shared && edit) {\n const withs = AXES.flatMap(axis => { const e = edit[axis]; return !('refused' in e) ? (e.with ?? []).map(i => shape!.args[i]!) : [] })\n const sphere = !!provider && Object.keys(provider.faces).length === 0\n const across = [...new Set([refOf('x')!, ...withs])]\n const along = sphere ? [] : [refOf('y')!]\n if ([...across, ...along].every(id => id && mine([id]))) round = { across: sphere ? [...new Set([...across, refOf('y')!])] : across, along }\n }\n const extent = !round && measures.every(Boolean) ? (measures as string[]) : []\n const sizes =\n extent.length === 3 && extent.every(id => id.startsWith(`${part}.`) && design.has(id)) ? (extent as [string, string, string]) : undefined\n /*\n The part's own measure, also when another reads it: a measure some other part follows is read through a node of its\n own times 1 (`link-dimension`), and it is still the author's number -- the upper arm's width, which the forearm\n follows, is the upper arm's to drag.\n */\n const constants = asset.document.model.constants ?? []\n const ownMeasure = (id: string): string | null => {\n if (id.startsWith(`${part}.`) && design.has(id)) return id\n const writer = nodes.find(node => Object.values(node.outputs ?? {}).includes(id))\n const one = writer?.op === 'mul@1' && writer.args.length === 2 && constants.find(c => c.id === writer.args[1])?.value === 1\n return one && writer!.args[0]!.startsWith(`${part}.`) && design.has(writer!.args[0]!) ? writer!.args[0]! : null\n }\n const ownSizes = extent.length === 3 && !sizes ? extent.map(ownMeasure) : undefined\n const someOwn = !!ownSizes?.some(Boolean)\n return {\n translate: posed && allDesign(own('position')) && own('position').every((id, i) => pose!.args[i] === id),\n rotate: posed && allDesign(own('rotation')) && own('rotation').every((id, i) => pose!.args[3 + i] === id),\n scale: !!sizes || !!round || someOwn,\n ...(sizes ? { sizes } : {}),\n ...(someOwn ? { ownSizes } : {}),\n ...(round ? { round } : {})\n }\n}\n\n/** Where a drag left the part, in the asset frame: millimetres, degrees and per-axis scale. */\nexport interface GizmoResult {\n position?: [number, number, number]\n rotation?: [number, number, number]\n scale?: [number, number, number]\n}\n\n/**\n * The input changes a drag makes — one list, applied as one step. Millimetres to the millimetre and degrees to a\n * tenth (a drag otherwise stores 722.4180046035418 mm). A size never goes below 1 mm.\n */\nexport function gizmoChanges(part: string, reach: GizmoReach, result: GizmoResult, sizes: Record<string, number>): FigureInputChange[] {\n const changes: FigureInputChange[] = []\n const put = (input: string, unit: FigureInputChange['unit'], value: number) =>\n changes.push({ kind: 'set-design', input, unit, value } as FigureInputChange)\n if (result.position && reach.translate)\n AXES.forEach((axis, i) => put(`${part}.position.${axis}`, 'mm', Math.round(result.position![i]!)))\n if (result.rotation && reach.rotate)\n AXES.forEach((axis, i) => put(`${part}.rotation.${axis}`, 'deg', Math.round(result.rotation![i]! * 10) / 10))\n if (result.scale && reach.scale && reach.sizes)\n reach.sizes.forEach((id, i) => {\n if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * result.scale![i]!)))\n })\n if (result.scale && reach.scale && reach.ownSizes)\n reach.ownSizes.forEach((id, i) => {\n if (id && sizes[id] !== undefined && Math.abs(result.scale![i]! - 1) > 1e-4) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * result.scale![i]!)))\n })\n if (result.scale && reach.scale && reach.round) {\n const [sx, sy, sz] = result.scale\n /* The factor the drag moved most: across for a cylinder (X or Z), any axis for a sphere. */\n const most = (factors: number[]) => factors.reduce((a, b) => (Math.abs(b - 1) > Math.abs(a - 1) ? b : a), 1)\n const sphere = reach.round.along.length === 0\n const across = sphere ? most([sx!, sy!, sz!]) : most([sx!, sz!])\n for (const id of reach.round.across) if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * across)))\n for (const id of reach.round.along) if (sizes[id] !== undefined) put(id, 'mm', Math.max(1, Math.round(sizes[id]! * sy!)))\n }\n return changes\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compileFigureAsset, compileFigureGraph, figureWorldBoxesOf, figureWritersOf } from '@hatiolab/figure-model';
|
|
2
|
+
import { sectionShape } from './drawn-shapes.js';
|
|
2
3
|
/*
|
|
3
4
|
* Where the selected part turns, and how far -- a translucent fan on the editing board. An axis name says nothing about which way a part swings; on a six-axis arm the author went to the preview and
|
|
4
5
|
* pushed each slider to its end to find out. The fan lies in the plane the part turns in, at the pivot, open from the
|
|
@@ -225,13 +226,13 @@ export function jointFanOf(asset, part, values = {}) {
|
|
|
225
226
|
const r = [0, 1, 2].map(i => [first[i], axisNow[i], zAxis[i]]);
|
|
226
227
|
const local = (p) => {
|
|
227
228
|
const v = sub(p, pivot);
|
|
228
|
-
return { x: dot(v, first),
|
|
229
|
+
return { x: dot(v, first), z: dot(v, zAxis) };
|
|
229
230
|
};
|
|
230
231
|
const full = max - min >= 359.999;
|
|
231
|
-
const profile = [...(full ? [] : [{ x: 0,
|
|
232
|
+
const profile = [...(full ? [] : [{ x: 0, z: 0 }]), ...traced.map(local)].map(p => ({ x: Math.round(p.x * 1000) / 1000, z: Math.round(p.z * 1000) / 1000 }));
|
|
232
233
|
return {
|
|
233
234
|
id: JOINT_FAN,
|
|
234
|
-
shape:
|
|
235
|
+
shape: sectionShape(profile, THICKNESS),
|
|
235
236
|
pose: { t: pivot, r },
|
|
236
237
|
material: { token: '__joint-fan', transparent: true },
|
|
237
238
|
/** Which control turns it: the joint the fan shows. */
|