@things-factory/figure-ui 10.1.74 → 10.1.76
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/figure-assistant.ts +3 -3
- package/client/graphql/{v3-store.ts → store.ts} +6 -6
- package/client/modeller/{v3-ai-proposal.ts → ai-proposal.ts} +8 -8
- package/client/modeller/{v3-align.ts → align.ts} +14 -14
- package/client/modeller/{v3-canvas.ts → canvas.ts} +13 -13
- package/client/modeller/{v3-clips.ts → clips.ts} +5 -5
- package/client/modeller/{v3-controls.ts → controls.ts} +2 -2
- package/client/modeller/{v3-editor.ts → editor.ts} +137 -126
- package/client/modeller/{figure-v3-capability.ts → figure-capability-panel.ts} +7 -7
- package/client/modeller/{figure-v3-clips.ts → figure-clips.ts} +10 -10
- package/client/modeller/{figure-v3-controls.ts → figure-controls.ts} +9 -9
- package/client/modeller/{v3-figure-facts.ts → figure-facts.ts} +11 -11
- package/client/modeller/{figure-v3-first-save.ts → figure-first-save.ts} +3 -3
- package/client/modeller/figure-history-panel.ts +1 -1
- package/client/modeller/{figure-v3-links.ts → figure-links.ts} +35 -35
- package/client/modeller/{figure-v3-material.ts → figure-material-panel.ts} +20 -20
- package/client/modeller/{figure-v3-parts.ts → figure-parts.ts} +15 -15
- package/client/modeller/{figure-v3-preview.ts → figure-preview.ts} +14 -14
- package/client/modeller/{figure-v3-properties.ts → figure-properties.ts} +25 -25
- package/client/modeller/{figure-v3-recipe-catalog.ts → figure-recipe-catalog.ts} +10 -10
- package/client/modeller/{figure-v3-verdict.ts → figure-verdict.ts} +24 -24
- package/client/modeller/gate-findings.ts +2 -2
- package/client/modeller/{v3-gizmo.ts → gizmo.ts} +11 -11
- package/client/modeller/{v3-joint-drag.ts → joint-drag.ts} +11 -11
- package/client/modeller/{v3-joint-fan.ts → joint-fan.ts} +13 -13
- package/client/modeller/{v3-links.ts → links.ts} +59 -59
- package/client/modeller/{v3-live.ts → live.ts} +9 -9
- package/client/modeller/{v3-maturity.ts → maturity.ts} +65 -65
- package/client/modeller/modeller-route.ts +1 -1
- package/client/modeller/{v3-occupancy.ts → occupancy.ts} +6 -6
- package/client/modeller/{v3-palette.ts → palette.ts} +3 -3
- package/client/modeller/{v3-preview-model.ts → preview-model.ts} +8 -8
- package/client/modeller/{v3-product-session.ts → product-session.ts} +25 -25
- package/client/modeller/{v3-recipe-source.ts → recipe-source.ts} +2 -2
- package/client/modeller/{v3-recipes.ts → recipes.ts} +9 -9
- package/client/modeller/{v3-refusals.ts → refusals.ts} +62 -13
- package/client/modeller/{v3-renderer.ts → renderer.ts} +16 -16
- package/client/modeller/{v3-stage-model.ts → stage-model.ts} +15 -15
- package/client/modeller/{v3-thumbnail.ts → thumbnail.ts} +8 -8
- package/client/pages/figure-list-page.ts +4 -4
- package/client/pages/{figure-v3-modeller-page.ts → figure-modeller-page.ts} +37 -37
- package/client/route.ts +1 -5
- package/dist-client/figure-assistant.js +3 -3
- package/dist-client/figure-assistant.js.map +1 -1
- package/dist-client/graphql/store.d.ts +3 -0
- package/dist-client/graphql/store.js +39 -0
- package/dist-client/graphql/store.js.map +1 -0
- package/dist-client/modeller/ai-proposal.d.ts +51 -0
- package/dist-client/modeller/ai-proposal.js +64 -0
- package/dist-client/modeller/ai-proposal.js.map +1 -0
- package/dist-client/modeller/align.d.ts +30 -0
- package/dist-client/modeller/align.js +75 -0
- package/dist-client/modeller/align.js.map +1 -0
- package/dist-client/modeller/canvas.d.ts +72 -0
- package/dist-client/modeller/canvas.js +379 -0
- package/dist-client/modeller/canvas.js.map +1 -0
- package/dist-client/modeller/clips.d.ts +39 -0
- package/dist-client/modeller/clips.js +58 -0
- package/dist-client/modeller/clips.js.map +1 -0
- package/dist-client/modeller/controls.d.ts +28 -0
- package/dist-client/modeller/controls.js +28 -0
- package/dist-client/modeller/controls.js.map +1 -0
- package/dist-client/modeller/editor.d.ts +203 -0
- package/dist-client/modeller/editor.js +1526 -0
- package/dist-client/modeller/editor.js.map +1 -0
- package/dist-client/modeller/fields.d.ts +45 -0
- package/dist-client/modeller/fields.js +83 -0
- package/dist-client/modeller/fields.js.map +1 -0
- package/dist-client/modeller/figure-capability-panel.d.ts +22 -0
- package/dist-client/modeller/figure-capability-panel.js +141 -0
- package/dist-client/modeller/figure-capability-panel.js.map +1 -0
- package/dist-client/modeller/figure-clips.d.ts +31 -0
- package/dist-client/modeller/figure-clips.js +268 -0
- package/dist-client/modeller/figure-clips.js.map +1 -0
- package/dist-client/modeller/figure-controls.d.ts +36 -0
- package/dist-client/modeller/figure-controls.js +226 -0
- package/dist-client/modeller/figure-controls.js.map +1 -0
- package/dist-client/modeller/figure-facts.d.ts +35 -0
- package/dist-client/modeller/figure-facts.js +55 -0
- package/dist-client/modeller/figure-facts.js.map +1 -0
- package/dist-client/modeller/figure-first-save.d.ts +20 -0
- package/dist-client/modeller/figure-first-save.js +118 -0
- package/dist-client/modeller/figure-first-save.js.map +1 -0
- package/dist-client/modeller/figure-history-panel.d.ts +1 -1
- package/dist-client/modeller/figure-history-panel.js.map +1 -1
- package/dist-client/modeller/figure-links.d.ts +77 -0
- package/dist-client/modeller/figure-links.js +649 -0
- package/dist-client/modeller/figure-links.js.map +1 -0
- package/dist-client/modeller/figure-material-panel.d.ts +39 -0
- package/dist-client/modeller/figure-material-panel.js +323 -0
- package/dist-client/modeller/figure-material-panel.js.map +1 -0
- package/dist-client/modeller/figure-parts.d.ts +69 -0
- package/dist-client/modeller/figure-parts.js +559 -0
- package/dist-client/modeller/figure-parts.js.map +1 -0
- package/dist-client/modeller/figure-preview.d.ts +34 -0
- package/dist-client/modeller/figure-preview.js +346 -0
- package/dist-client/modeller/figure-preview.js.map +1 -0
- package/dist-client/modeller/figure-properties.d.ts +45 -0
- package/dist-client/modeller/figure-properties.js +239 -0
- package/dist-client/modeller/figure-properties.js.map +1 -0
- package/dist-client/modeller/figure-recipe-catalog.d.ts +38 -0
- package/dist-client/modeller/figure-recipe-catalog.js +399 -0
- package/dist-client/modeller/figure-recipe-catalog.js.map +1 -0
- package/dist-client/modeller/figure-verdict.d.ts +64 -0
- package/dist-client/modeller/figure-verdict.js +787 -0
- package/dist-client/modeller/figure-verdict.js.map +1 -0
- package/dist-client/modeller/first-save.d.ts +17 -0
- package/dist-client/modeller/first-save.js +26 -0
- package/dist-client/modeller/first-save.js.map +1 -0
- package/dist-client/modeller/gate-findings.d.ts +2 -2
- package/dist-client/modeller/gate-findings.js +2 -2
- package/dist-client/modeller/gate-findings.js.map +1 -1
- package/dist-client/modeller/gizmo.d.ts +72 -0
- package/dist-client/modeller/gizmo.js +111 -0
- package/dist-client/modeller/gizmo.js.map +1 -0
- package/dist-client/modeller/help.d.ts +18 -0
- package/dist-client/modeller/help.js +37 -0
- package/dist-client/modeller/help.js.map +1 -0
- package/dist-client/modeller/joint-drag.d.ts +19 -0
- package/dist-client/modeller/joint-drag.js +97 -0
- package/dist-client/modeller/joint-drag.js.map +1 -0
- package/dist-client/modeller/joint-fan.d.ts +9 -0
- package/dist-client/modeller/joint-fan.js +276 -0
- package/dist-client/modeller/joint-fan.js.map +1 -0
- package/dist-client/modeller/keys.d.ts +22 -0
- package/dist-client/modeller/keys.js +26 -0
- package/dist-client/modeller/keys.js.map +1 -0
- package/dist-client/modeller/links.d.ts +267 -0
- package/dist-client/modeller/links.js +480 -0
- package/dist-client/modeller/links.js.map +1 -0
- package/dist-client/modeller/live.d.ts +37 -0
- package/dist-client/modeller/live.js +68 -0
- package/dist-client/modeller/live.js.map +1 -0
- package/dist-client/modeller/maturity.d.ts +120 -0
- package/dist-client/modeller/maturity.js +313 -0
- package/dist-client/modeller/maturity.js.map +1 -0
- package/dist-client/modeller/modeller-route.d.ts +1 -1
- package/dist-client/modeller/modeller-route.js +1 -1
- package/dist-client/modeller/modeller-route.js.map +1 -1
- package/dist-client/modeller/occupancy.d.ts +18 -0
- package/dist-client/modeller/occupancy.js +24 -0
- package/dist-client/modeller/occupancy.js.map +1 -0
- package/dist-client/modeller/palette.d.ts +7 -0
- package/dist-client/modeller/palette.js +46 -0
- package/dist-client/modeller/palette.js.map +1 -0
- package/dist-client/modeller/preview-model.d.ts +47 -0
- package/dist-client/modeller/preview-model.js +68 -0
- package/dist-client/modeller/preview-model.js.map +1 -0
- package/dist-client/modeller/product-session.d.ts +510 -0
- package/dist-client/modeller/product-session.js +157 -0
- package/dist-client/modeller/product-session.js.map +1 -0
- package/dist-client/modeller/recipe-source.d.ts +8 -0
- package/dist-client/modeller/recipe-source.js +14 -0
- package/dist-client/modeller/recipe-source.js.map +1 -0
- package/dist-client/modeller/recipes.d.ts +37 -0
- package/dist-client/modeller/recipes.js +103 -0
- package/dist-client/modeller/recipes.js.map +1 -0
- package/dist-client/modeller/refusals.d.ts +68 -0
- package/dist-client/modeller/refusals.js +142 -0
- package/dist-client/modeller/refusals.js.map +1 -0
- package/dist-client/modeller/renderer.d.ts +40 -0
- package/dist-client/modeller/renderer.js +73 -0
- package/dist-client/modeller/renderer.js.map +1 -0
- package/dist-client/modeller/stage-model.d.ts +39 -0
- package/dist-client/modeller/stage-model.js +147 -0
- package/dist-client/modeller/stage-model.js.map +1 -0
- package/dist-client/modeller/thumbnail.d.ts +3 -0
- package/dist-client/modeller/thumbnail.js +75 -0
- package/dist-client/modeller/thumbnail.js.map +1 -0
- package/dist-client/modeller/v3-clips.d.ts +1 -1
- package/dist-client/modeller/v3-editor.d.ts +5 -0
- package/dist-client/modeller/v3-editor.js +21 -10
- package/dist-client/modeller/v3-editor.js.map +1 -1
- package/dist-client/modeller/v3-product-session.d.ts +31 -0
- package/dist-client/modeller/v3-refusals.d.ts +37 -5
- package/dist-client/modeller/v3-refusals.js +59 -16
- package/dist-client/modeller/v3-refusals.js.map +1 -1
- package/dist-client/pages/figure-list-page.d.ts +1 -1
- package/dist-client/pages/figure-list-page.js +4 -4
- package/dist-client/pages/figure-list-page.js.map +1 -1
- package/dist-client/pages/figure-modeller-page.d.ts +102 -0
- package/dist-client/pages/figure-modeller-page.js +548 -0
- package/dist-client/pages/figure-modeller-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +1 -5
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/docs/product-cutover.md +25 -0
- package/package.json +5 -5
- package/test/{v3-ai-proposal.test.ts → ai-proposal.test.ts} +6 -6
- package/test/{v3-align.test.ts → align.test.ts} +8 -8
- package/test/browser/modeller-page.js +30 -30
- package/test/browser/modeller.check.mjs +17 -16
- package/test/browser/serve.mjs +1 -1
- package/test/browser/thumbnail-page.js +6 -6
- package/test/{v3-clips.test.ts → clips.test.ts} +18 -18
- package/test/{v3-controls.test.ts → controls.test.ts} +15 -15
- package/test/{v3-fields.test.ts → fields.test.ts} +13 -13
- package/test/figure-assistant-surface.test.ts +3 -3
- package/test/{v3-first-save.test.ts → first-save.test.ts} +10 -10
- package/test/fixtures/joint-column.json +2 -2
- package/test/fixtures/joint-roller.json +2 -2
- package/test/fixtures/robot-arm-6dof.json +2 -2
- package/test/{v3-gizmo.test.ts → gizmo.test.ts} +33 -33
- package/test/{v3-joint-drag.test.ts → joint-drag.test.ts} +17 -17
- package/test/{v3-joint-fan.test.ts → joint-fan.test.ts} +18 -18
- package/test/joints.ts +6 -6
- package/test/{v3-keys.test.ts → keys.test.ts} +2 -2
- package/test/{v3-layout.test.ts → layout.test.ts} +8 -8
- package/test/{v3-links.test.ts → links.test.ts} +201 -201
- package/test/{v3-live.test.ts → live.test.ts} +18 -18
- package/test/{v3-material.test.ts → material.test.ts} +12 -12
- package/test/{v3-maturity.test.ts → maturity.test.ts} +74 -74
- package/test/modeller-route.test.ts +5 -6
- package/test/{v3-palette-icons.test.ts → palette-icons.test.ts} +1 -1
- package/test/{v3-parts-wiring.test.ts → parts-wiring.test.ts} +11 -7
- package/test/{v3-preview.test.ts → preview.test.ts} +12 -12
- package/test/{v3-product-session.test.ts → product-session.test.ts} +17 -17
- package/test/{v3-product-write.test.ts → product-write.test.ts} +20 -20
- package/test/{v3-properties.test.ts → properties.test.ts} +24 -24
- package/test/{v3-recipes.test.ts → recipes.test.ts} +10 -10
- package/test/refusals.test.ts +166 -0
- package/test/{v3-release-panel.test.ts → release-panel.test.ts} +21 -21
- package/test/renderer.test.ts +24 -0
- package/test/resolve-ts-siblings.mjs +1 -1
- package/test/{v3-scene-canvas.test.ts → scene-canvas.test.ts} +6 -6
- package/test/{v3-stage-model.test.ts → stage-model.test.ts} +5 -5
- package/test/{v3-theme.test.ts → theme.test.ts} +4 -4
- package/test/{v3-thumbnail.test.ts → thumbnail.test.ts} +4 -4
- package/test/{v3-verdict.test.ts → verdict.test.ts} +17 -17
- package/test/{v3-view.test.ts → view.test.ts} +2 -2
- package/things-factory.config.js +2 -3
- package/translations/en.json +15 -7
- package/translations/ja.json +15 -7
- package/translations/ko.json +15 -7
- package/translations/ms.json +15 -7
- package/translations/zh.json +15 -7
- package/docs/v3-product-cutover.md +0 -25
- package/test/v3-refusals.test.ts +0 -136
- package/test/v3-renderer.test.ts +0 -24
- /package/client/modeller/{v3-fields.ts → fields.ts} +0 -0
- /package/client/modeller/{v3-first-save.ts → first-save.ts} +0 -0
- /package/client/modeller/{v3-help.ts → help.ts} +0 -0
- /package/client/modeller/{v3-keys.ts → keys.ts} +0 -0
|
@@ -0,0 +1,1526 @@
|
|
|
1
|
+
var FigureEditor_1;
|
|
2
|
+
import { __decorate, __metadata } from "tslib";
|
|
3
|
+
import { LitElement, html, css, nothing } from 'lit';
|
|
4
|
+
import { i18next } from '@operato/i18n';
|
|
5
|
+
import '@operato/layout';
|
|
6
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
7
|
+
import { live } from 'lit/directives/live.js';
|
|
8
|
+
import { PART_LIMIT, parseFigureRecipe, resolveFigureRecipe, figurePartCountOf, figureRecipeIdFor } from '@hatiolab/figure-model';
|
|
9
|
+
import './figure-recipe-catalog.js';
|
|
10
|
+
import { captureFigureThumbnail } from './thumbnail.js';
|
|
11
|
+
import { drawableFigureParts } from './renderer.js';
|
|
12
|
+
import './canvas.js';
|
|
13
|
+
import './figure-parts.js';
|
|
14
|
+
import './figure-material-panel.js';
|
|
15
|
+
import './figure-links.js';
|
|
16
|
+
import './figure-controls.js';
|
|
17
|
+
import './figure-clips.js';
|
|
18
|
+
import './figure-preview.js';
|
|
19
|
+
import './figure-settings.js';
|
|
20
|
+
import { DEFAULT_VIEW } from './figure-view.js';
|
|
21
|
+
import './figure-capability-panel.js';
|
|
22
|
+
import { gizmoChanges, gizmoReachOf, keepBottomChanges } from './gizmo.js';
|
|
23
|
+
import { keyActionOf } from './keys.js';
|
|
24
|
+
import { groupFields, ownerOf, partLabelOf, repeatOf } from './fields.js';
|
|
25
|
+
import { SidePanelStyles } from './side-panel-styles.js';
|
|
26
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
27
|
+
import { alignChanges, boxOf, canMirror, mirrorChanges } from './align.js';
|
|
28
|
+
import { paletteRecipe } from './palette.js';
|
|
29
|
+
import { nudgeOf } from './stage-model.js';
|
|
30
|
+
import { editRefusalOf, inDeclaredRoom, inputRangeRefusalOf, narrowingRetryOf, partRefusalOf, placementRefusalOf, recipeRefusalOf, removalNoticeOf, sizeRangeRefusalOf } from './refusals.js';
|
|
31
|
+
import { instanceRangeOf, instanceRangeToDeclare, proportionToFollow, rangeDiffers, rangeWith, turnsAboutAJoint, valueNow } from './links.js';
|
|
32
|
+
import { jointFanOf } from './joint-fan.js';
|
|
33
|
+
import { jointDragOf } from './joint-drag.js';
|
|
34
|
+
import { liveOverSession, NOTHING_LIVE, scrubbed, scrubStep } from './live.js';
|
|
35
|
+
/** Product editor surface. The injected session is shared by page persistence and AI commands. */
|
|
36
|
+
let FigureEditor = class FigureEditor extends LitElement {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
/** The recipe templates (ADR-0095), read by the page from the server. */
|
|
40
|
+
this.templates = [];
|
|
41
|
+
this.catalogOpen = false;
|
|
42
|
+
/** Why the last recipe was refused, in the kernel's words. */
|
|
43
|
+
this.recipeError = '';
|
|
44
|
+
this.revision = 0;
|
|
45
|
+
this.selected = '';
|
|
46
|
+
this.error = '';
|
|
47
|
+
this.tab = 'properties';
|
|
48
|
+
/** What the middle shows: the parts being edited, or the figure placed on a board at eight sizes. */
|
|
49
|
+
this.middle = 'edit';
|
|
50
|
+
/** A line saying what a command did besides what was asked; gone at the next command. */
|
|
51
|
+
this.notice = '';
|
|
52
|
+
/**
|
|
53
|
+
* How the workbench shows the figure, in the board's own state names. The viewer's, kept in
|
|
54
|
+
* their browser, never in the figure.
|
|
55
|
+
*/
|
|
56
|
+
this.view = FigureEditor_1.storedView();
|
|
57
|
+
/**
|
|
58
|
+
* Parts hidden on the workbench — the author's view while working, not the asset's visibility. Not saved: a part
|
|
59
|
+
* hidden here is still in the figure, still checked, still drawn on a board.
|
|
60
|
+
*/
|
|
61
|
+
this.hiddenParts = new Set();
|
|
62
|
+
/** A value in hand -- typed, held on a spinner, scrubbed, dragged -- drawn at once and recorded on release. */
|
|
63
|
+
this.live = NOTHING_LIVE;
|
|
64
|
+
this.lastContext = null;
|
|
65
|
+
/** The modeller's keys (`keys.ts`): undo, redo, duplicate, remove, back to the whole figure, the gizmo's modes. */
|
|
66
|
+
this.onKey = (e) => {
|
|
67
|
+
const view = this.session?.read();
|
|
68
|
+
if (!view || view.loading || view.saving || !view.context || !this.isConnected)
|
|
69
|
+
return;
|
|
70
|
+
const canvas = this.renderRoot.querySelector('figure-canvas');
|
|
71
|
+
const path = e.composedPath();
|
|
72
|
+
const action = keyActionOf({ key: e.key, ctrlKey: e.ctrlKey, metaKey: e.metaKey, shiftKey: e.shiftKey, altKey: e.altKey, target: path[0], inScene: !!canvas && path.includes(canvas) }, this.selected);
|
|
73
|
+
if (!action)
|
|
74
|
+
return;
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
/*
|
|
77
|
+
The session's history is the only one. With the canvas focused the scene took Ctrl+Z as well, undoing on its own
|
|
78
|
+
board the last value the canvas had written -- which the canvas then told as a drag: an undo of a drag on a
|
|
79
|
+
part placed by a rule wrote the drag again (2026-09-25). Heard first (capture) and kept from the scene.
|
|
80
|
+
*/
|
|
81
|
+
e.stopPropagation();
|
|
82
|
+
if (action === 'translate' || action === 'rotate' || action === 'scale')
|
|
83
|
+
canvas && this.useGizmo(action);
|
|
84
|
+
else if (action === 'undo')
|
|
85
|
+
view.canUndo && this.run(() => this.session.undo());
|
|
86
|
+
else if (action === 'redo')
|
|
87
|
+
view.canRedo && this.run(() => this.session.redo());
|
|
88
|
+
else if (action === 'duplicate')
|
|
89
|
+
this.duplicatePart(this.selected);
|
|
90
|
+
else if (action === 'remove')
|
|
91
|
+
this.removePart(this.selected);
|
|
92
|
+
else
|
|
93
|
+
this.selected = '';
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
static { FigureEditor_1 = this; }
|
|
97
|
+
/* The operato scrollbar, as every scrolling panel of the app has it -- the side panel scrolled with the browser's own. */
|
|
98
|
+
static { this.styles = [ScrollbarStyles, SidePanelStyles, css `
|
|
99
|
+
:host {
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
min-height: 0;
|
|
103
|
+
height: 100%;
|
|
104
|
+
/* The editor folds by the width it is given, not the window's (UX ruling, 2026-09-24). */
|
|
105
|
+
container-type: inline-size;
|
|
106
|
+
font: 13px sans-serif;
|
|
107
|
+
color: var(--md-sys-color-on-surface);
|
|
108
|
+
}
|
|
109
|
+
/* The bar over the work is ox-canvas-bar (ADR-0060 decision 8): the folds at its edges, undo, redo and
|
|
110
|
+
fit in the suite's places. What the editor puts in it - the mode switch, the status, save - is styled here. */
|
|
111
|
+
ox-canvas-bar button[mode] {
|
|
112
|
+
height: 28px;
|
|
113
|
+
padding: 0 10px;
|
|
114
|
+
border-radius: 999em;
|
|
115
|
+
border-color: transparent;
|
|
116
|
+
background: none;
|
|
117
|
+
}
|
|
118
|
+
ox-canvas-bar button[mode][aria-pressed='true'] {
|
|
119
|
+
border-color: var(--md-sys-color-primary);
|
|
120
|
+
}
|
|
121
|
+
/* The gizmo's tools, drawn as the bar's own icon buttons (undo, redo, fit). */
|
|
122
|
+
ox-canvas-bar .gizmo-tools {
|
|
123
|
+
display: inline-flex;
|
|
124
|
+
gap: 2px;
|
|
125
|
+
padding-left: 4px;
|
|
126
|
+
border-left: 1px solid var(--md-sys-color-outline-variant);
|
|
127
|
+
}
|
|
128
|
+
ox-canvas-bar button[tool] {
|
|
129
|
+
display: inline-grid;
|
|
130
|
+
place-items: center;
|
|
131
|
+
width: 32px;
|
|
132
|
+
height: 32px;
|
|
133
|
+
padding: 0;
|
|
134
|
+
border: none;
|
|
135
|
+
border-radius: var(--md-sys-shape-corner-small, 8px);
|
|
136
|
+
background: transparent;
|
|
137
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
}
|
|
140
|
+
ox-canvas-bar button[tool]:hover:not(:disabled) {
|
|
141
|
+
background: var(--md-sys-color-surface-container-high);
|
|
142
|
+
color: var(--md-sys-color-on-surface);
|
|
143
|
+
}
|
|
144
|
+
ox-canvas-bar button[tool][aria-pressed='true'] {
|
|
145
|
+
background: var(--md-sys-color-secondary-container);
|
|
146
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
147
|
+
}
|
|
148
|
+
ox-canvas-bar button[tool]:disabled {
|
|
149
|
+
opacity: 0.38;
|
|
150
|
+
cursor: default;
|
|
151
|
+
}
|
|
152
|
+
figure-preview {
|
|
153
|
+
min-width: 0;
|
|
154
|
+
min-height: 0;
|
|
155
|
+
}
|
|
156
|
+
ox-canvas-bar .status {
|
|
157
|
+
padding: 0 8px;
|
|
158
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
159
|
+
}
|
|
160
|
+
ox-canvas-bar .status[dirty] {
|
|
161
|
+
color: var(--md-sys-color-primary);
|
|
162
|
+
font-weight: 600;
|
|
163
|
+
}
|
|
164
|
+
ox-canvas-bar button[save] {
|
|
165
|
+
height: 32px;
|
|
166
|
+
padding: 0 14px;
|
|
167
|
+
border: none;
|
|
168
|
+
border-radius: 999em;
|
|
169
|
+
color: var(--md-sys-color-on-primary);
|
|
170
|
+
background: var(--md-sys-color-primary);
|
|
171
|
+
}
|
|
172
|
+
/* The three panes are ox-three-pane's (ADR-0060 decision 8): widths 200 | 1fr | 340, 160 | 300 under
|
|
173
|
+
860px and one column with the middle first under 560px are the frame's, as are the dividers. */
|
|
174
|
+
ox-three-pane {
|
|
175
|
+
flex: 1;
|
|
176
|
+
min-height: 0;
|
|
177
|
+
}
|
|
178
|
+
figure-parts {
|
|
179
|
+
min-height: 0;
|
|
180
|
+
}
|
|
181
|
+
figure-canvas {
|
|
182
|
+
min-width: 0;
|
|
183
|
+
min-height: 0;
|
|
184
|
+
}
|
|
185
|
+
/* The side: tabs over one panel at a time, each using the whole height. */
|
|
186
|
+
aside {
|
|
187
|
+
display: flex;
|
|
188
|
+
flex-direction: column;
|
|
189
|
+
min-height: 0;
|
|
190
|
+
background: var(--md-sys-color-surface-container-lowest);
|
|
191
|
+
}
|
|
192
|
+
div[tabs] {
|
|
193
|
+
display: flex;
|
|
194
|
+
flex: none;
|
|
195
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
196
|
+
}
|
|
197
|
+
button[tab] {
|
|
198
|
+
flex: 1;
|
|
199
|
+
position: relative;
|
|
200
|
+
display: flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
justify-content: center;
|
|
203
|
+
height: 38px;
|
|
204
|
+
padding: 0;
|
|
205
|
+
border: none;
|
|
206
|
+
border-radius: 0;
|
|
207
|
+
border-bottom: 2px solid transparent;
|
|
208
|
+
background: none;
|
|
209
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
210
|
+
}
|
|
211
|
+
button[tab]:hover:not([on]) {
|
|
212
|
+
background: var(--md-sys-color-surface-container);
|
|
213
|
+
}
|
|
214
|
+
button[tab][on] {
|
|
215
|
+
color: var(--md-sys-color-primary);
|
|
216
|
+
border-bottom-color: var(--md-sys-color-primary);
|
|
217
|
+
}
|
|
218
|
+
button[tab] md-icon {
|
|
219
|
+
font-size: 20px;
|
|
220
|
+
width: 20px;
|
|
221
|
+
height: 20px;
|
|
222
|
+
}
|
|
223
|
+
span[badge] {
|
|
224
|
+
position: absolute;
|
|
225
|
+
top: 3px;
|
|
226
|
+
right: 2px;
|
|
227
|
+
padding: 0 5px;
|
|
228
|
+
font-size: 0.62rem;
|
|
229
|
+
font-weight: 700;
|
|
230
|
+
line-height: 1.5;
|
|
231
|
+
color: var(--md-sys-color-on-primary-container);
|
|
232
|
+
background: var(--md-sys-color-primary-container);
|
|
233
|
+
border-radius: 999em;
|
|
234
|
+
pointer-events: none;
|
|
235
|
+
}
|
|
236
|
+
/* The sections inside carry the margins (side-panel-styles); the panel only scrolls. */
|
|
237
|
+
div[panel] {
|
|
238
|
+
flex: 1;
|
|
239
|
+
min-height: 0;
|
|
240
|
+
overflow: auto;
|
|
241
|
+
padding: 0;
|
|
242
|
+
}
|
|
243
|
+
div[panel][flush] {
|
|
244
|
+
padding: 0;
|
|
245
|
+
}
|
|
246
|
+
/* Hidden, not removed: a panel keeps what it holds (the verdict its last answer) while another tab is open. */
|
|
247
|
+
[off] {
|
|
248
|
+
display: none !important;
|
|
249
|
+
}
|
|
250
|
+
/* Which part the panel speaks of, and the way back to the whole figure. */
|
|
251
|
+
div[subject] {
|
|
252
|
+
display: flex;
|
|
253
|
+
align-items: center;
|
|
254
|
+
gap: 6px;
|
|
255
|
+
padding: 6px 10px 0;
|
|
256
|
+
}
|
|
257
|
+
div[subject] button[chip] {
|
|
258
|
+
display: inline-flex;
|
|
259
|
+
align-items: center;
|
|
260
|
+
gap: 2px;
|
|
261
|
+
height: 26px;
|
|
262
|
+
padding: 0 10px 0 6px;
|
|
263
|
+
border-radius: 999em;
|
|
264
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
265
|
+
}
|
|
266
|
+
div[subject] md-icon {
|
|
267
|
+
font-size: 16px;
|
|
268
|
+
width: 16px;
|
|
269
|
+
height: 16px;
|
|
270
|
+
}
|
|
271
|
+
button {
|
|
272
|
+
font: inherit;
|
|
273
|
+
box-sizing: border-box;
|
|
274
|
+
height: 32px;
|
|
275
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
276
|
+
border-radius: 6px;
|
|
277
|
+
background: var(--md-sys-color-surface);
|
|
278
|
+
color: inherit;
|
|
279
|
+
padding: 0 8px;
|
|
280
|
+
min-width: 0;
|
|
281
|
+
}
|
|
282
|
+
button {
|
|
283
|
+
cursor: pointer;
|
|
284
|
+
}
|
|
285
|
+
button:disabled {
|
|
286
|
+
opacity: 0.45;
|
|
287
|
+
cursor: default;
|
|
288
|
+
}
|
|
289
|
+
button[aria-pressed='true'] {
|
|
290
|
+
background: var(--md-sys-color-secondary-container);
|
|
291
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
292
|
+
border-color: var(--md-sys-color-primary);
|
|
293
|
+
}
|
|
294
|
+
.error {
|
|
295
|
+
padding: 10px;
|
|
296
|
+
background: var(--md-sys-color-error-container);
|
|
297
|
+
color: var(--md-sys-color-on-error-container);
|
|
298
|
+
white-space: pre-wrap;
|
|
299
|
+
}
|
|
300
|
+
.notice {
|
|
301
|
+
padding: 8px 10px;
|
|
302
|
+
background: var(--md-sys-color-surface-container);
|
|
303
|
+
color: var(--md-sys-color-on-surface);
|
|
304
|
+
}
|
|
305
|
+
.hint {
|
|
306
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
307
|
+
line-height: 1.5;
|
|
308
|
+
}
|
|
309
|
+
`]; }
|
|
310
|
+
static storedView() {
|
|
311
|
+
try {
|
|
312
|
+
const stored = JSON.parse(localStorage.getItem('figure-view') ?? 'null');
|
|
313
|
+
return stored && typeof stored === 'object' ? { ...DEFAULT_VIEW, ...stored } : { ...DEFAULT_VIEW };
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
return { ...DEFAULT_VIEW };
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
setView(view) {
|
|
320
|
+
this.view = { ...DEFAULT_VIEW, ...view };
|
|
321
|
+
try {
|
|
322
|
+
localStorage.setItem('figure-view', JSON.stringify(this.view));
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
/* A browser that keeps nothing still shows the change for this visit. */
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Move, turn and size on the canvas, in the bar's tools: the gizmo the W · E · R keys give, found without knowing the
|
|
330
|
+
* keys (2026-09-26 -- a person dragging the part turned the camera). Each is offered only where the part's own
|
|
331
|
+
* numbers can take it (`gizmoReachOf`).
|
|
332
|
+
*/
|
|
333
|
+
renderGizmoTools(editing) {
|
|
334
|
+
const reach = editing && this.selected ? this.reachOf(this.selected) : undefined;
|
|
335
|
+
const tools = [
|
|
336
|
+
{ mode: 'translate', icon: 'open_with', key: 'W', can: !!reach?.translate },
|
|
337
|
+
{ mode: 'rotate', icon: '3d_rotation', key: 'E', can: !!reach?.rotate },
|
|
338
|
+
{ mode: 'scale', icon: 'open_in_full', key: 'R', can: !!reach?.scale }
|
|
339
|
+
];
|
|
340
|
+
return html `<span class="gizmo-tools" role="group" aria-label=${i18next.t('figure.label.gizmo-tools')}>
|
|
341
|
+
${tools.map(tool => html `<button
|
|
342
|
+
tool
|
|
343
|
+
aria-pressed=${String(this.gizmoMode === tool.mode)}
|
|
344
|
+
?disabled=${!tool.can}
|
|
345
|
+
aria-label=${i18next.t('figure.button.gizmo-' + tool.mode)}
|
|
346
|
+
title=${`${i18next.t('figure.button.gizmo-' + tool.mode)} (${tool.key})${tool.can || !this.selected ? '' : ' · ' + i18next.t('figure.text.gizmo-not-own')}`}
|
|
347
|
+
@click=${() => this.useGizmo(tool.mode)}
|
|
348
|
+
>
|
|
349
|
+
<md-icon>${tool.icon}</md-icon>
|
|
350
|
+
</button>`)}
|
|
351
|
+
</span>`;
|
|
352
|
+
}
|
|
353
|
+
connectedCallback() {
|
|
354
|
+
super.connectedCallback();
|
|
355
|
+
window.addEventListener('keydown', this.onKey, true);
|
|
356
|
+
}
|
|
357
|
+
disconnectedCallback() {
|
|
358
|
+
window.removeEventListener('keydown', this.onKey, true);
|
|
359
|
+
super.disconnectedCallback();
|
|
360
|
+
}
|
|
361
|
+
willUpdate(_changed) {
|
|
362
|
+
const view = this.session?.read();
|
|
363
|
+
if (view?.context !== this.lastContext) {
|
|
364
|
+
this.lastContext = view?.context ?? null;
|
|
365
|
+
this.selected = '';
|
|
366
|
+
this.error = '';
|
|
367
|
+
this.hiddenParts = new Set();
|
|
368
|
+
}
|
|
369
|
+
if (view && !view.geometry.some(g => ownerOf(g.id) === this.selected))
|
|
370
|
+
this.selected = '';
|
|
371
|
+
if (_changed.has('selected'))
|
|
372
|
+
this.gizmoMode = undefined;
|
|
373
|
+
}
|
|
374
|
+
/** The scene toggles: the mode already shown takes the gizmo away. */
|
|
375
|
+
useGizmo(mode) {
|
|
376
|
+
this.renderRoot.querySelector('figure-canvas')?.gizmo(mode);
|
|
377
|
+
this.gizmoMode = this.gizmoMode === mode ? undefined : mode;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* A refusal no particular sentence knows: figure-model's code said as a refusal, never its English; any other error
|
|
381
|
+
* (the network, the server) as it came.
|
|
382
|
+
*/
|
|
383
|
+
said(error) {
|
|
384
|
+
return error?.code ? editRefusalOf(error, (key, params) => i18next.t(key, params)) : error instanceof Error ? error.message : String(error);
|
|
385
|
+
}
|
|
386
|
+
run(action) {
|
|
387
|
+
try {
|
|
388
|
+
action();
|
|
389
|
+
this.error = '';
|
|
390
|
+
/* The next step stands on its own: what the last removal let go of is no longer the news. */
|
|
391
|
+
this.notice = '';
|
|
392
|
+
this.changed();
|
|
393
|
+
}
|
|
394
|
+
catch (error) {
|
|
395
|
+
const say = (key, params) => i18next.t(key, params);
|
|
396
|
+
this.error = sizeRangeRefusalOf(error, say) ?? inputRangeRefusalOf(error, say) ?? this.said(error);
|
|
397
|
+
}
|
|
398
|
+
finally {
|
|
399
|
+
/* Committed or refused, the value in hand is gone: the figure as it stands is drawn again. */
|
|
400
|
+
this.live = NOTHING_LIVE;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/** What the canvas draws: the figure with the value in hand when there is one, and without the parts hidden on the workbench. */
|
|
404
|
+
drawnParts(geometry, asset) {
|
|
405
|
+
const parts = (asset ? liveOverSession(asset, this.currentInputs(), this.live) : null) ?? drawableFigureParts(geometry ?? []);
|
|
406
|
+
return parts.filter(body => !this.hiddenParts.has(ownerOf(body.id)));
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Where the selected part turns and how far, with the pose as it is drawn now -- a value in hand included, so the
|
|
410
|
+
* fan follows the arm while a control is dragged. Its size comes from what the joint turns (`joint-fan`).
|
|
411
|
+
*/
|
|
412
|
+
fanOf(asset) {
|
|
413
|
+
if (!asset || !this.selected || this.hiddenParts.has(this.selected))
|
|
414
|
+
return null;
|
|
415
|
+
try {
|
|
416
|
+
return jointFanOf(asset, this.selected, { ...this.currentInputs(), ...this.live.values });
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Every input as the session holds it now -- the pose the author has set with the controls, and design values. The
|
|
424
|
+
* asset's source carries only the saved defaults, so drawing a value in hand over it put every other joint back to its
|
|
425
|
+
* saved angle while one slider moved, and the arm jumped when released (user, 2026-09-24).
|
|
426
|
+
*/
|
|
427
|
+
currentInputs() {
|
|
428
|
+
const view = this.session?.read();
|
|
429
|
+
return view ? Object.fromEntries(view.fields.map(field => [field.id, field.value])) : {};
|
|
430
|
+
}
|
|
431
|
+
/** A value in hand: an input's value (design or pose) or a part edit. Nothing is recorded. */
|
|
432
|
+
hold(values, edit) {
|
|
433
|
+
this.live = { values: { ...this.live.values, ...values }, ...(edit ? { edit } : this.live.edit ? { edit: this.live.edit } : {}) };
|
|
434
|
+
}
|
|
435
|
+
changed() {
|
|
436
|
+
this.requestUpdate();
|
|
437
|
+
this.dispatchEvent(new CustomEvent('changed', { bubbles: true, composed: true }));
|
|
438
|
+
}
|
|
439
|
+
async save() {
|
|
440
|
+
if (!this.session)
|
|
441
|
+
return;
|
|
442
|
+
try {
|
|
443
|
+
/*
|
|
444
|
+
The card's picture is taken before the save starts, from a canvas of its own at the card's size —
|
|
445
|
+
not from the one on screen, which stands wherever the author left it turned. A picture that cannot
|
|
446
|
+
be taken is not an error: the save goes on without it (see `thumbnail.ts`).
|
|
447
|
+
*/
|
|
448
|
+
let type;
|
|
449
|
+
if (!this.session.read().id && this.firstSave) {
|
|
450
|
+
const answer = await this.firstSave(this.session.read().name ?? '');
|
|
451
|
+
if (!answer)
|
|
452
|
+
return;
|
|
453
|
+
/* The name is the figure's own, in the asset: one step of the history, like typing it in the properties. */
|
|
454
|
+
if (answer.name !== this.session.read().name) {
|
|
455
|
+
this.session.command({ kind: 'rename', name: answer.name });
|
|
456
|
+
this.changed();
|
|
457
|
+
}
|
|
458
|
+
type = answer.type;
|
|
459
|
+
}
|
|
460
|
+
const view = this.session.read();
|
|
461
|
+
const thumbnail = await captureFigureThumbnail(drawableFigureParts(view.geometry ?? []), view.palette ?? {});
|
|
462
|
+
const promise = this.session.save({ thumbnail, type });
|
|
463
|
+
this.changed();
|
|
464
|
+
await promise;
|
|
465
|
+
this.error = '';
|
|
466
|
+
}
|
|
467
|
+
catch (error) {
|
|
468
|
+
this.error = this.said(error);
|
|
469
|
+
}
|
|
470
|
+
finally {
|
|
471
|
+
this.changed();
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
add(kind) {
|
|
475
|
+
if (!this.session)
|
|
476
|
+
return;
|
|
477
|
+
this.run(() => {
|
|
478
|
+
const ids = new Set(this.session.read().geometry.map(g => g.id));
|
|
479
|
+
let n = 1;
|
|
480
|
+
while (ids.has(`${kind}-${n}`))
|
|
481
|
+
n++;
|
|
482
|
+
const part = paletteRecipe(kind, `${kind}-${n}`);
|
|
483
|
+
this.session.add(part);
|
|
484
|
+
this.selected = part.id;
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* The list's own operations, as part edits — each one step of the session's history. The copy and the moved
|
|
489
|
+
* part stay selected.
|
|
490
|
+
*/
|
|
491
|
+
duplicatePart(id) {
|
|
492
|
+
this.run(() => {
|
|
493
|
+
const before = new Set(this.session.read().geometry.map(g => g.id));
|
|
494
|
+
this.session.edit({ kind: 'duplicate-part', target: id });
|
|
495
|
+
this.selected = this.session.read().geometry.find(g => !before.has(g.id))?.id ?? id;
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
movePart(id, to) {
|
|
499
|
+
this.run(() => this.session.edit({ kind: 'move-part', target: id, to }));
|
|
500
|
+
}
|
|
501
|
+
removePart(id, refitRoom = false) {
|
|
502
|
+
this.retry = undefined;
|
|
503
|
+
try {
|
|
504
|
+
const view = this.session.edit({ kind: 'remove-part', target: id, ...(refitRoom ? { refitRoom: true } : {}) });
|
|
505
|
+
this.error = '';
|
|
506
|
+
/* What else the removal let go of, named (chief architect, 2026-09-27); undo brings it back. */
|
|
507
|
+
this.notice = removalNoticeOf(view.removal, (key, params) => i18next.t(key, params)) ?? '';
|
|
508
|
+
if (this.selected === id)
|
|
509
|
+
this.selected = '';
|
|
510
|
+
this.changed();
|
|
511
|
+
}
|
|
512
|
+
catch (error) {
|
|
513
|
+
/* The refusal a person meets most: another part stands on this one or follows its size. Said in their words. */
|
|
514
|
+
this.error = partRefusalOf(error, id, (key, params) => i18next.t(key, params)) ?? this.said(error);
|
|
515
|
+
/* In the declared room only: the way on is to delete it and fit the room to the parts left, in one step. */
|
|
516
|
+
if (!refitRoom && inDeclaredRoom(error))
|
|
517
|
+
this.retry = { label: i18next.t('figure.button.remove-and-refit-room', { part: id }), run: () => this.removePart(id, true) };
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
toggleHiddenPart(id) {
|
|
521
|
+
const next = new Set(this.hiddenParts);
|
|
522
|
+
if (next.has(id))
|
|
523
|
+
next.delete(id);
|
|
524
|
+
else
|
|
525
|
+
next.add(id);
|
|
526
|
+
this.hiddenParts = next;
|
|
527
|
+
}
|
|
528
|
+
/** Whether the figure declares its size (the three size inputs). */
|
|
529
|
+
hasSize() {
|
|
530
|
+
const values = this.designValues();
|
|
531
|
+
return ['x', 'y', 'z'].every(axis => typeof values[`size.${axis}`] === 'number');
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* A recipe put in (ADR-0095): resolved on the figure as it stands -- its parts take the next free name, onto the part
|
|
535
|
+
* chosen -- and applied as one step. Refused, the kernel's sentence goes to the form as it is (condition 3).
|
|
536
|
+
*/
|
|
537
|
+
insertRecipe(recipe, values) {
|
|
538
|
+
try {
|
|
539
|
+
const asset = JSON.parse(this.session.source());
|
|
540
|
+
const checked = parseFigureRecipe(recipe);
|
|
541
|
+
const id = figureRecipeIdFor(asset, checked);
|
|
542
|
+
const steps = resolveFigureRecipe(checked, { id, ...(checked.target === 'part' ? { target: this.selected } : {}), values });
|
|
543
|
+
this.session.applyRecipe(steps);
|
|
544
|
+
this.recipeError = '';
|
|
545
|
+
this.catalogOpen = false;
|
|
546
|
+
this.error = '';
|
|
547
|
+
this.changed();
|
|
548
|
+
}
|
|
549
|
+
catch (error) {
|
|
550
|
+
this.recipeError = recipeRefusalOf(error, (key, params) => i18next.t(key, params)) ?? this.said(error);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
/** The design values of the asset being edited. */
|
|
554
|
+
designValues() {
|
|
555
|
+
try {
|
|
556
|
+
return this.session ? (JSON.parse(this.session.source()).designInputs ?? {}) : {};
|
|
557
|
+
}
|
|
558
|
+
catch {
|
|
559
|
+
return {};
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/** What the gizmo may write for the selected part — read off the asset being edited. */
|
|
563
|
+
reachOf(id) {
|
|
564
|
+
const none = { translate: false, rotate: false, scale: false };
|
|
565
|
+
/* A repeat is moved and sized through its row, not by a gizmo on one copy. */
|
|
566
|
+
if (!id || !this.session || !this.session.read().geometry.some(g => g.id === id))
|
|
567
|
+
return none;
|
|
568
|
+
try {
|
|
569
|
+
return gizmoReachOf(JSON.parse(this.session.source()), id);
|
|
570
|
+
}
|
|
571
|
+
catch {
|
|
572
|
+
return none;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
/** A drag, written back as the part's own inputs — one step of the history, like typing the numbers. */
|
|
576
|
+
transformed(id, result) {
|
|
577
|
+
const view = this.session.read();
|
|
578
|
+
/* A part hanging from a joint: the drag edits the joint -- its value, or where it sits (ADR-0093). */
|
|
579
|
+
const asset = JSON.parse(this.session.source());
|
|
580
|
+
const drawn = view.geometry.find(g => g.id === id);
|
|
581
|
+
const drag = drawn ? jointDragOf(asset, ownerOf(id), drawn, result, this.currentInputs()) : null;
|
|
582
|
+
if (drag) {
|
|
583
|
+
if (drag.kind === 'value')
|
|
584
|
+
this.run(() => this.session.apply([{ kind: 'set-state', input: drag.input, unit: drag.unit, value: drag.value }]));
|
|
585
|
+
else if (drag.kind === 'joint')
|
|
586
|
+
this.run(() => this.session.command({ kind: 'set-joint', joint: drag.joint }));
|
|
587
|
+
else {
|
|
588
|
+
this.error = i18next.t(`figure.text.gizmo-joint-${drag.reason}`, { joint: drag.joint, leader: drag.leader ?? '', axis: drag.axis ?? '' });
|
|
589
|
+
this.requestUpdate();
|
|
590
|
+
}
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const sizes = Object.fromEntries(view.fields.map(field => [field.id, field.value]));
|
|
594
|
+
/*
|
|
595
|
+
A part a joint places, scaled: only its measures change. The shift of its centre that an anchored scale makes is
|
|
596
|
+
the joint's to give -- the face on the joint stays there by itself (user, 2026-09-25: 「'R'모드에서 크기가 변하지 않는다」;
|
|
597
|
+
the shift had been taken for a move of the joint, and the size was dropped).
|
|
598
|
+
*/
|
|
599
|
+
const jointed = !!asset.joints?.some(j => j.body1.part === ownerOf(id));
|
|
600
|
+
const changes = gizmoChanges(id, this.reachOf(id), jointed && result.scale ? { scale: result.scale } : result, sizes);
|
|
601
|
+
if (changes.length) {
|
|
602
|
+
this.run(() => this.session.apply(changes));
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
if (jointed && result.scale) {
|
|
606
|
+
/* Only measures that follow another were pulled: the relation says their size, and it is not broken here. */
|
|
607
|
+
const axes = ['x', 'y', 'z'].filter((_, i) => Math.abs(result.scale[i] - 1) > 1e-4);
|
|
608
|
+
this.error = i18next.t('figure.text.gizmo-size-follows', { part: partLabelOf(id), axis: axes.join(', ').toUpperCase() });
|
|
609
|
+
return this.requestUpdate();
|
|
610
|
+
}
|
|
611
|
+
/*
|
|
612
|
+
A part whose place is worked out has no numbers for the gizmo to write: the drag is added beside
|
|
613
|
+
its rule (`nudge-part`). A part a joint or a fastening places, or a size that is worked out, is refused -- said in
|
|
614
|
+
words, not by the part silently springing back (user, 2026-09-24: 「기즈모 컨트롤도 전혀 작동이 안되는군」).
|
|
615
|
+
*/
|
|
616
|
+
const body = view.geometry.find(g => g.id === id);
|
|
617
|
+
if (!body)
|
|
618
|
+
return this.requestUpdate();
|
|
619
|
+
const { by, turn } = nudgeOf(body, result);
|
|
620
|
+
/* A size worked out from the figure's: the drag's factor beside its rule, so it still follows. */
|
|
621
|
+
const grow = {};
|
|
622
|
+
if (result.scale)
|
|
623
|
+
['x', 'y', 'z'].forEach((axis, i) => Math.abs(result.scale[i] - 1) > 1e-6 && (grow[axis] = Math.round(result.scale[i] * 1e6) / 1e6));
|
|
624
|
+
if (!Object.keys(by).length && !Object.keys(turn).length && !Object.keys(grow).length)
|
|
625
|
+
return this.requestUpdate();
|
|
626
|
+
try {
|
|
627
|
+
this.session.command({
|
|
628
|
+
kind: 'nudge-part',
|
|
629
|
+
part: id,
|
|
630
|
+
...(Object.keys(by).length ? { by } : {}),
|
|
631
|
+
...(Object.keys(turn).length ? { turn } : {}),
|
|
632
|
+
...(Object.keys(grow).length ? { grow } : {})
|
|
633
|
+
});
|
|
634
|
+
this.error = '';
|
|
635
|
+
this.changed();
|
|
636
|
+
}
|
|
637
|
+
catch (error) {
|
|
638
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
639
|
+
this.error = /carried by a joint/.test(message)
|
|
640
|
+
? i18next.t('figure.text.gizmo-joint-places', { part: partLabelOf(id) })
|
|
641
|
+
: /is fastened to/.test(message)
|
|
642
|
+
? i18next.t('figure.text.gizmo-fastening-places', { part: partLabelOf(id) })
|
|
643
|
+
: this.said(error);
|
|
644
|
+
this.requestUpdate();
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
/** 맞추기 — one tool, one step of the history, through the same inputs as the gizmo. */
|
|
648
|
+
align(tool) {
|
|
649
|
+
this.run(() => {
|
|
650
|
+
const asset = JSON.parse(this.session.source());
|
|
651
|
+
const changes = alignChanges(asset, this.selected, this.reachOf(this.selected), tool);
|
|
652
|
+
if (changes.length)
|
|
653
|
+
this.session.apply(changes);
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
/** A mirrored copy: duplicate, then place the copy on the other side — two steps. */
|
|
657
|
+
mirror(axis) {
|
|
658
|
+
this.run(() => {
|
|
659
|
+
const id = this.selected;
|
|
660
|
+
const before = new Set(this.session.read().geometry.map(g => g.id));
|
|
661
|
+
this.session.edit({ kind: 'duplicate-part', target: id });
|
|
662
|
+
const copy = this.session.read().geometry.find(g => !before.has(g.id))?.id;
|
|
663
|
+
if (!copy)
|
|
664
|
+
return;
|
|
665
|
+
this.session.apply(mirrorChanges(JSON.parse(this.session.source()), id, copy, axis));
|
|
666
|
+
this.selected = copy;
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
renderTools(unavailable) {
|
|
670
|
+
const reach = this.reachOf(this.selected);
|
|
671
|
+
if (!this.selected || !reach.translate)
|
|
672
|
+
return null;
|
|
673
|
+
let asset;
|
|
674
|
+
try {
|
|
675
|
+
asset = JSON.parse(this.session.source());
|
|
676
|
+
}
|
|
677
|
+
catch {
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
const tool = (name, icon, label, title) => html `<button ?disabled=${unavailable} aria-label=${i18next.t(label)} title=${i18next.t(title)} @click=${() => this.align(name)}>
|
|
681
|
+
<md-icon>${icon}</md-icon>
|
|
682
|
+
</button>`;
|
|
683
|
+
return html `<div tools title=${i18next.t('figure.text.tools-explained')}>
|
|
684
|
+
${tool('centre-x', 'horizontal_distribute', 'figure.button.center-x', 'figure.text.center-on-x')}
|
|
685
|
+
${tool('centre-z', 'vertical_align_center', 'figure.button.center-z', 'figure.text.center-on-z')}
|
|
686
|
+
${tool('floor', 'vertical_align_bottom', 'figure.button.to-floor', 'figure.text.put-on-floor')}
|
|
687
|
+
${['x', 'z'].map(axis => {
|
|
688
|
+
const able = canMirror(asset, this.selected, axis, reach);
|
|
689
|
+
return html `<button
|
|
690
|
+
?disabled=${unavailable || !able}
|
|
691
|
+
aria-label=${i18next.t('figure.button.mirror-' + axis)}
|
|
692
|
+
title=${i18next.t(able ? 'figure.text.mirror-explained' : 'figure.text.mirror-would-overlap')}
|
|
693
|
+
@click=${() => this.mirror(axis)}
|
|
694
|
+
>
|
|
695
|
+
<md-icon>${axis === 'x' ? 'flip' : 'flip_camera_android'}</md-icon>
|
|
696
|
+
</button>`;
|
|
697
|
+
})}
|
|
698
|
+
${tool('snap', 'grid_on', 'figure.button.snap', 'figure.text.snap-explained')}
|
|
699
|
+
</div>`;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* A part's name. It renames every value the part owns, and what refers to them follows
|
|
703
|
+
* (figure-model's rename-part), as one step of the history.
|
|
704
|
+
*/
|
|
705
|
+
/**
|
|
706
|
+
* A repeated body is one of its repeat's copies and is named after it -- the list and this field read `roller 15`, not
|
|
707
|
+
* its path through the repeat (user, 2026-09-24: 「부품 이름 ???」). A copy has no name of its own to change.
|
|
708
|
+
*/
|
|
709
|
+
renderRepeatNote(geometry) {
|
|
710
|
+
const repeat = repeatOf(this.selected, geometry);
|
|
711
|
+
return repeat?.index ? html `<p hint>${i18next.t('figure.text.repeat-member', { name: repeat.name, count: repeat.count, index: repeat.index })}</p>` : nothing;
|
|
712
|
+
}
|
|
713
|
+
renamePart(input) {
|
|
714
|
+
const name = input.value.trim();
|
|
715
|
+
const from = this.selected;
|
|
716
|
+
if (!name || name === from) {
|
|
717
|
+
input.value = from;
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
try {
|
|
721
|
+
this.session.edit({ kind: 'rename-part', target: from, name });
|
|
722
|
+
this.selected = name;
|
|
723
|
+
this.error = '';
|
|
724
|
+
this.changed();
|
|
725
|
+
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
input.value = from;
|
|
728
|
+
const code = error?.code;
|
|
729
|
+
this.error =
|
|
730
|
+
code === 'PART_ID'
|
|
731
|
+
? i18next.t(/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(name) ? 'figure.text.part-name-taken' : 'figure.text.part-name-invalid', { name })
|
|
732
|
+
: error instanceof Error
|
|
733
|
+
? error.message
|
|
734
|
+
: String(error);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
/** Size response, fastening and motion for the selected part, as authoring commands. */
|
|
738
|
+
renderLinks(unavailable, section) {
|
|
739
|
+
let asset;
|
|
740
|
+
try {
|
|
741
|
+
asset = JSON.parse(this.session.source());
|
|
742
|
+
}
|
|
743
|
+
catch {
|
|
744
|
+
return null;
|
|
745
|
+
}
|
|
746
|
+
let dims;
|
|
747
|
+
try {
|
|
748
|
+
dims = boxOf(asset, this.selected)?.dims;
|
|
749
|
+
}
|
|
750
|
+
catch {
|
|
751
|
+
dims = undefined;
|
|
752
|
+
}
|
|
753
|
+
return html `<figure-links
|
|
754
|
+
.asset=${asset}
|
|
755
|
+
.section=${section}
|
|
756
|
+
.partId=${this.selected}
|
|
757
|
+
.dims=${dims}
|
|
758
|
+
?locked=${unavailable}
|
|
759
|
+
@command=${(e) => this.linkCommand(e.detail.action)}
|
|
760
|
+
@part-edit=${(e) => this.run(() => this.session.edit(e.detail.edit))}
|
|
761
|
+
></figure-links>`;
|
|
762
|
+
}
|
|
763
|
+
/** The figure's controls: try a value, name it, set its range and travel time, keep the pose. */
|
|
764
|
+
renderControls(view, unavailable) {
|
|
765
|
+
let asset;
|
|
766
|
+
try {
|
|
767
|
+
asset = JSON.parse(this.session.source());
|
|
768
|
+
}
|
|
769
|
+
catch {
|
|
770
|
+
return null;
|
|
771
|
+
}
|
|
772
|
+
const values = Object.fromEntries(view.fields.filter(f => f.role === 'state').map(f => [f.id, f.value]));
|
|
773
|
+
return html `<figure-controls
|
|
774
|
+
.asset=${asset}
|
|
775
|
+
.values=${values}
|
|
776
|
+
?locked=${unavailable}
|
|
777
|
+
@state=${(e) => this.run(() => this.session.apply([{ kind: 'set-state', input: e.detail.input, unit: e.detail.unit, value: e.detail.value }]))}
|
|
778
|
+
@state-live=${(e) => this.hold({ [e.detail.input]: e.detail.value })}
|
|
779
|
+
@part-edit=${(e) => this.run(() => this.session.edit(e.detail.edit))}
|
|
780
|
+
></figure-controls>
|
|
781
|
+
<figure-clips
|
|
782
|
+
.asset=${asset}
|
|
783
|
+
.values=${values}
|
|
784
|
+
?locked=${unavailable}
|
|
785
|
+
@states=${(e) => this.run(() => this.session.apply(e.detail.changes))}
|
|
786
|
+
@states-live=${(e) => this.hold(e.detail.values)}
|
|
787
|
+
@part-edit=${(e) => this.run(() => this.session.edit(e.detail.edit))}
|
|
788
|
+
></figure-clips>`;
|
|
789
|
+
}
|
|
790
|
+
/** One command, one step of the history. A refusal a person can meet here is said in their words. */
|
|
791
|
+
linkCommand(action) {
|
|
792
|
+
this.retry = undefined;
|
|
793
|
+
this.notice = '';
|
|
794
|
+
const hadSize = this.hasSize();
|
|
795
|
+
try {
|
|
796
|
+
this.session.command(action);
|
|
797
|
+
this.error = '';
|
|
798
|
+
/* What the command did besides what was asked, in one line: the figure's size declared to follow (ADR ruling Q1). */
|
|
799
|
+
if (action.kind === 'follow-size' && !hadSize) {
|
|
800
|
+
const size = this.designValues();
|
|
801
|
+
this.notice = i18next.t('figure.text.size-declared-to-follow', {
|
|
802
|
+
x: Math.round(size['size.x'] ?? 0).toLocaleString(),
|
|
803
|
+
y: Math.round(size['size.y'] ?? 0).toLocaleString(),
|
|
804
|
+
z: Math.round(size['size.z'] ?? 0).toLocaleString()
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
this.changed();
|
|
808
|
+
}
|
|
809
|
+
catch (error) {
|
|
810
|
+
const code = error?.code;
|
|
811
|
+
const narrowing = narrowingRetryOf(action, error, (key, params) => i18next.t(key, params));
|
|
812
|
+
if (narrowing) {
|
|
813
|
+
this.error = narrowing.message;
|
|
814
|
+
this.retry = { label: narrowing.label, action: narrowing.retry };
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
this.error =
|
|
818
|
+
code === 'DIMENSION_CYCLE'
|
|
819
|
+
? i18next.t('figure.text.follow-would-loop')
|
|
820
|
+
: code === 'FASTEN_CYCLE' || code === 'ATTACH_CYCLE'
|
|
821
|
+
? i18next.t('figure.text.fasten-would-loop')
|
|
822
|
+
: sizeRangeRefusalOf(error, (key, params) => i18next.t(key, params)) ??
|
|
823
|
+
placementRefusalOf(error, (key, params) => i18next.t(key, params)) ??
|
|
824
|
+
this.said(error);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
changeField(field, event) {
|
|
828
|
+
const input = event.target, value = input.valueAsNumber;
|
|
829
|
+
/* A height typed in keeps the part's bottom where it is, as the scale gizmo does. */
|
|
830
|
+
const part = this.selected;
|
|
831
|
+
const kept = field.role !== 'state' && part ? keepBottomChanges(part, this.reachOf(part), field.id, value, this.designValues()) : [];
|
|
832
|
+
this.run(() => this.session.apply([
|
|
833
|
+
{ kind: field.role === 'state' ? 'set-state' : 'set-design', input: field.id, unit: field.unit, value },
|
|
834
|
+
...kept
|
|
835
|
+
]));
|
|
836
|
+
// Rejected edits must also restore the displayed numeric value.
|
|
837
|
+
input.value = String(this.session.read().fields.find(i => i.id === field.id).value);
|
|
838
|
+
}
|
|
839
|
+
/** Typing or a held spinner: each number on the way is drawn; the field's change records it. */
|
|
840
|
+
typing(field, event) {
|
|
841
|
+
const value = event.target.valueAsNumber;
|
|
842
|
+
if (Number.isFinite(value))
|
|
843
|
+
this.hold({ [field.id]: value });
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Drag a field's label (or an axis letter) sideways to scrub its value, as vector tools do: the figure follows the
|
|
847
|
+
* pointer, and the release records one step. The field's number follows too, so the value in hand is always read.
|
|
848
|
+
*/
|
|
849
|
+
scrub(field, down, unavailable) {
|
|
850
|
+
if (unavailable || down.button !== 0)
|
|
851
|
+
return;
|
|
852
|
+
const label = down.currentTarget;
|
|
853
|
+
const input = (label.closest('div[cell]')?.querySelector('input') ?? label.nextElementSibling);
|
|
854
|
+
if (!input)
|
|
855
|
+
return;
|
|
856
|
+
down.preventDefault();
|
|
857
|
+
label.setPointerCapture(down.pointerId);
|
|
858
|
+
const start = field.value;
|
|
859
|
+
let value = start;
|
|
860
|
+
const move = (e) => {
|
|
861
|
+
value = scrubbed(start, e.clientX - down.clientX, scrubStep(field.unit, start, e.shiftKey));
|
|
862
|
+
input.value = String(value);
|
|
863
|
+
this.hold({ [field.id]: value });
|
|
864
|
+
};
|
|
865
|
+
const up = (e) => {
|
|
866
|
+
label.removeEventListener('pointermove', move);
|
|
867
|
+
label.removeEventListener('pointerup', up);
|
|
868
|
+
label.removeEventListener('pointercancel', up);
|
|
869
|
+
/* A drag the system took away is not the author's value: the field goes back to where it was. */
|
|
870
|
+
if (e.type === 'pointercancel')
|
|
871
|
+
value = start;
|
|
872
|
+
if (value === start) {
|
|
873
|
+
input.value = String(start);
|
|
874
|
+
this.live = NOTHING_LIVE;
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
input.value = String(value);
|
|
878
|
+
this.changeField(field, { target: input });
|
|
879
|
+
};
|
|
880
|
+
label.addEventListener('pointermove', move);
|
|
881
|
+
label.addEventListener('pointerup', up);
|
|
882
|
+
label.addEventListener('pointercancel', up);
|
|
883
|
+
}
|
|
884
|
+
/** The sizes a board may give the figure, and the way to measure them again after its parts changed. */
|
|
885
|
+
renderInstanceRange(asset, unavailable) {
|
|
886
|
+
if (!asset)
|
|
887
|
+
return nothing;
|
|
888
|
+
/* Another figure, or another step of this one, is measured again. */
|
|
889
|
+
const at = `${this.session?.read().context ?? ''}:${this.revision}`;
|
|
890
|
+
if (this.range?.at !== at) {
|
|
891
|
+
let of;
|
|
892
|
+
let toDeclare;
|
|
893
|
+
try {
|
|
894
|
+
of = instanceRangeOf(asset);
|
|
895
|
+
}
|
|
896
|
+
catch {
|
|
897
|
+
of = undefined;
|
|
898
|
+
}
|
|
899
|
+
try {
|
|
900
|
+
toDeclare = of ? undefined : instanceRangeToDeclare(asset);
|
|
901
|
+
}
|
|
902
|
+
catch {
|
|
903
|
+
toDeclare = undefined;
|
|
904
|
+
}
|
|
905
|
+
this.range = { at, of, toDeclare };
|
|
906
|
+
}
|
|
907
|
+
const range = this.range.of;
|
|
908
|
+
/* No size yet: the figure is declared its size from its parts, so a board can resize it and parts can follow it. */
|
|
909
|
+
const toDeclare = this.range.toDeclare;
|
|
910
|
+
if (!range && toDeclare)
|
|
911
|
+
return html `<section>
|
|
912
|
+
<h3>${i18next.t('figure.label.instance-range')}</h3>
|
|
913
|
+
<p hint>${i18next.t('figure.text.instance-size-undeclared')}</p>
|
|
914
|
+
<button act ?disabled=${unavailable} @click=${() => this.linkCommand({ kind: 'declare-instance-size', range: toDeclare.range, at: toDeclare.at })}>
|
|
915
|
+
<md-icon>straighten</md-icon>${i18next.t('figure.button.declare-instance-size')}
|
|
916
|
+
</button>
|
|
917
|
+
</section>`;
|
|
918
|
+
if (!range)
|
|
919
|
+
return nothing;
|
|
920
|
+
const mm = (v) => Math.round(v).toLocaleString();
|
|
921
|
+
const differs = rangeDiffers(range.declared, range.measured);
|
|
922
|
+
return html `<section>
|
|
923
|
+
<h3>${i18next.t('figure.label.instance-range')}</h3>
|
|
924
|
+
${['x', 'y', 'z'].map(axis => html `<div inline-field>
|
|
925
|
+
<label>${axis.toUpperCase()} <span unit>mm</span></label>
|
|
926
|
+
<div pair>
|
|
927
|
+
${['min', 'max'].map(bound => html `<input
|
|
928
|
+
aria-label=${`size.${axis}.${bound}`}
|
|
929
|
+
type="number"
|
|
930
|
+
step="any"
|
|
931
|
+
.value=${live(String(Math.round(range.declared[axis][bound])))}
|
|
932
|
+
?disabled=${unavailable}
|
|
933
|
+
@change=${(e) => {
|
|
934
|
+
const next = rangeWith(range.declared, axis, bound, e.target.valueAsNumber);
|
|
935
|
+
if (next)
|
|
936
|
+
this.linkCommand({ kind: 'declare-instance-size', range: next, replace: true });
|
|
937
|
+
}}
|
|
938
|
+
/>`)}
|
|
939
|
+
</div>
|
|
940
|
+
</div>`)}
|
|
941
|
+
${differs
|
|
942
|
+
? html `<p hint>
|
|
943
|
+
${i18next.t('figure.text.instance-range-can-widen', {
|
|
944
|
+
ranges: ['x', 'y', 'z']
|
|
945
|
+
.filter(axis => rangeDiffers(range.declared, { ...range.declared, [axis]: range.measured[axis] }))
|
|
946
|
+
.map(axis => `${axis.toUpperCase()} ${mm(range.measured[axis].min)} – ${mm(range.measured[axis].max)}`)
|
|
947
|
+
.join(' · ')
|
|
948
|
+
})}
|
|
949
|
+
</p>
|
|
950
|
+
<button act ?disabled=${unavailable} @click=${() => this.linkCommand({ kind: 'declare-instance-size', range: range.measured, replace: true })}>
|
|
951
|
+
<md-icon>straighten</md-icon>${i18next.t('figure.button.remeasure-range')}
|
|
952
|
+
</button>`
|
|
953
|
+
: nothing}
|
|
954
|
+
${this.renderSizingRule(asset, unavailable)}
|
|
955
|
+
</section>`;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* How the figure grows. One ratio (`sizing: 'uniform'`) is said as it is; a figure with joints that has not declared
|
|
959
|
+
* it is offered it -- a mechanism does not shear -- and the author decides (chief architect's ruling 2026-09-24).
|
|
960
|
+
*/
|
|
961
|
+
renderSizingRule(asset, unavailable) {
|
|
962
|
+
if (asset.sizing === 'uniform') {
|
|
963
|
+
/* One ratio reaches only what reads the size: every other length is offered to follow it, in one step. */
|
|
964
|
+
const follow = proportionToFollow(asset);
|
|
965
|
+
return html `<div inline-field><label>${i18next.t('figure.label.sizing-rule')}</label><span>${i18next.t('figure.label.sizing-uniform')}</span></div>
|
|
966
|
+
${follow?.count
|
|
967
|
+
? html `<p hint>${i18next.t('figure.text.proportion-to-follow', { count: follow.count })}</p>
|
|
968
|
+
<button act ?disabled=${unavailable} @click=${() => this.linkCommand({ kind: 'follow-size-in-proportion' })}>
|
|
969
|
+
<md-icon>open_in_full</md-icon>${i18next.t('figure.button.follow-size-in-proportion')}
|
|
970
|
+
</button>`
|
|
971
|
+
: nothing}
|
|
972
|
+
${follow?.kept.length ? html `<p hint>${i18next.t('figure.text.proportion-kept', { what: follow.kept.join(', ') })}</p>` : nothing}`;
|
|
973
|
+
}
|
|
974
|
+
return html `${turnsAboutAJoint(asset) ? html `<p hint>${i18next.t('figure.text.sizing-uniform-proposed')}</p>` : nothing}
|
|
975
|
+
<button act ?disabled=${unavailable} title=${i18next.t('figure.text.sizing-uniform-explained')} @click=${() => this.linkCommand({ kind: 'scale-uniformly' })}>
|
|
976
|
+
<md-icon>aspect_ratio</md-icon>${i18next.t('figure.button.scale-uniformly')}
|
|
977
|
+
</button>`;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* The parts list, one row per part the author made: a repeat is one row with how many copies it makes now
|
|
981
|
+
* (user, 2026-09-24: the conveyor's sixteen rollers were sixteen rows).
|
|
982
|
+
*/
|
|
983
|
+
partRows(geometry) {
|
|
984
|
+
const rows = new Map();
|
|
985
|
+
for (const g of geometry) {
|
|
986
|
+
const id = ownerOf(g.id);
|
|
987
|
+
const row = rows.get(id);
|
|
988
|
+
if (row) {
|
|
989
|
+
row.copies = (row.copies ?? 1) + 1;
|
|
990
|
+
continue;
|
|
991
|
+
}
|
|
992
|
+
rows.set(id, {
|
|
993
|
+
id,
|
|
994
|
+
provider: g.shape?.provider ?? '',
|
|
995
|
+
hidden: this.hiddenParts.has(id),
|
|
996
|
+
invisible: g.visible === false,
|
|
997
|
+
...(id !== g.id ? { copies: 1 } : {})
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
return [...rows.values()];
|
|
1001
|
+
}
|
|
1002
|
+
/** The detail level's part budget for the list's head, from figure-model's count (a repeat once). */
|
|
1003
|
+
partBudgetOf(asset) {
|
|
1004
|
+
if (!asset)
|
|
1005
|
+
return undefined;
|
|
1006
|
+
try {
|
|
1007
|
+
return { level: asset.detailLevel ?? null, used: figurePartCountOf(asset), limit: asset.detailLevel ? PART_LIMIT[asset.detailLevel] : null };
|
|
1008
|
+
}
|
|
1009
|
+
catch {
|
|
1010
|
+
return undefined;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* A repeat: which way its copies run, how many there are now, and how far apart.
|
|
1015
|
+
* The pitch of a row that fills its length is edited as a number (`set-repeat` makes it the part's own the first
|
|
1016
|
+
* time); a row of a fixed count says its pitch cannot be set yet (figure-model refuses it the same way).
|
|
1017
|
+
*/
|
|
1018
|
+
renderRepeat(asset, geometry, unavailable) {
|
|
1019
|
+
const repeat = repeatOf(this.selected, geometry);
|
|
1020
|
+
if (!asset || !repeat || repeat.index)
|
|
1021
|
+
return nothing;
|
|
1022
|
+
/* The row is set on its part; what hangs from that part is copied with it and has no row of its own. */
|
|
1023
|
+
if (!asset.document.model.nodes.some(n => n.id === `${this.selected}.repeat`))
|
|
1024
|
+
return nothing;
|
|
1025
|
+
const model = asset.document.model;
|
|
1026
|
+
const layout = model.nodes.find(n => n.id === `${this.selected}.layout`);
|
|
1027
|
+
const axis = model.nodes.find(n => n.id === `${this.selected}.repeat`)?.params?.axis ?? '?';
|
|
1028
|
+
const own = `${this.selected}.repeat.pitch`;
|
|
1029
|
+
/* The pitch as it stands: the part's own number, a constant, or what a pitch that follows a length comes to. */
|
|
1030
|
+
const pitch = asset.designInputs[own] ?? model.constants.find(c => c.id === layout?.args[4])?.value ?? valueNow(asset, layout?.args[4]);
|
|
1031
|
+
const fits = layout?.op === 'fit-pitch@1';
|
|
1032
|
+
/* What the pitch gives, in numbers: this many copies at the length it is authored, and how long it may be placed. */
|
|
1033
|
+
const lengthRef = layout?.args[0] ?? '';
|
|
1034
|
+
const length = asset.designInputs[lengthRef];
|
|
1035
|
+
const longest = model.inputs.find(i => i.id === lengthRef)?.max;
|
|
1036
|
+
const limit = model.constants.find(c => c.id === layout?.args[6])?.value;
|
|
1037
|
+
const field = { id: own, unit: 'mm', role: 'design', value: pitch ?? 0 };
|
|
1038
|
+
return html `<section>
|
|
1039
|
+
<h3>${i18next.t('figure.label.repeat')}</h3>
|
|
1040
|
+
<div inline-field><label>${i18next.t('figure.label.repeat-axis')}</label><span value>${axis.toUpperCase()}</span></div>
|
|
1041
|
+
<div inline-field><label>${i18next.t('figure.label.repeat-count')}</label><span value>${repeat.count}</span></div>
|
|
1042
|
+
<div inline-field>
|
|
1043
|
+
<label>${i18next.t('figure.label.repeat-gap')} <span unit>mm</span></label>
|
|
1044
|
+
<input
|
|
1045
|
+
type="number"
|
|
1046
|
+
step="any"
|
|
1047
|
+
aria-label=${own}
|
|
1048
|
+
.value=${String(pitch ?? '')}
|
|
1049
|
+
?disabled=${unavailable || !fits}
|
|
1050
|
+
@change=${(e) => this.setPitch(field, e)}
|
|
1051
|
+
/>
|
|
1052
|
+
</div>
|
|
1053
|
+
<p hint>
|
|
1054
|
+
${fits && length !== undefined && longest !== undefined && limit !== undefined
|
|
1055
|
+
? i18next.t('figure.text.repeat-what-pitch-gives', {
|
|
1056
|
+
length: length.toLocaleString(),
|
|
1057
|
+
count: repeat.count,
|
|
1058
|
+
longest: longest.toLocaleString(),
|
|
1059
|
+
limit
|
|
1060
|
+
})
|
|
1061
|
+
: i18next.t(fits ? 'figure.text.repeat-fits-length' : 'figure.text.repeat-fixed-count')}
|
|
1062
|
+
</p>
|
|
1063
|
+
${this.renderPublicPitch(asset, pitch ?? 0, unavailable)}
|
|
1064
|
+
${asset.joints?.some(j => j.body1.part === this.selected && j.repeat)
|
|
1065
|
+
? html `<button act ?disabled=${unavailable} @click=${() => this.run(() => this.session.command({ kind: 'remove-repeat', part: this.selected }))}>
|
|
1066
|
+
<md-icon>close</md-icon>${i18next.t('figure.button.remove-repeat')}
|
|
1067
|
+
</button>`
|
|
1068
|
+
: nothing}
|
|
1069
|
+
</section>`;
|
|
1070
|
+
}
|
|
1071
|
+
/** The design input a row's pitch is read from, when it is read from one (ADR-0096). */
|
|
1072
|
+
pitchInputOf(asset, part) {
|
|
1073
|
+
const pitch = asset.joints?.find(j => j.body1.part === part && j.repeat)?.repeat?.pitch;
|
|
1074
|
+
return typeof pitch === 'object' && pitch?.from?.of === 'input' ? pitch.from.input : undefined;
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* 「보드에서 바꿀 수 있음」 (ADR-0096): the row's pitch made a design input the figure publishes -- a name on the board and
|
|
1078
|
+
* a range the board's value is held to -- in one step; changed or withdrawn the same way. Only a row with a record.
|
|
1079
|
+
*/
|
|
1080
|
+
renderPublicPitch(asset, pitch, unavailable) {
|
|
1081
|
+
const part = this.selected;
|
|
1082
|
+
if (!asset.joints?.some(j => j.body1.part === part && j.repeat))
|
|
1083
|
+
return nothing;
|
|
1084
|
+
const from = this.pitchInputOf(asset, part);
|
|
1085
|
+
const listed = from ? asset.publicInputs?.find(p => p.input === from) : undefined;
|
|
1086
|
+
const input = from ? asset.document.model.inputs.find(i => i.id === from) : undefined;
|
|
1087
|
+
const form = this.publishing?.part === part
|
|
1088
|
+
? this.publishing
|
|
1089
|
+
: listed && input
|
|
1090
|
+
? { part, label: listed.label, min: input.min, max: input.max }
|
|
1091
|
+
: undefined;
|
|
1092
|
+
const open = !!form;
|
|
1093
|
+
const edit = (key) => (e) => {
|
|
1094
|
+
const target = e.target;
|
|
1095
|
+
const base = form ?? { part, label: '', min: 0, max: 0 };
|
|
1096
|
+
this.publishing = { ...base, [key]: key === 'label' ? target.value : target.valueAsNumber };
|
|
1097
|
+
};
|
|
1098
|
+
const steps = () => {
|
|
1099
|
+
const f = form;
|
|
1100
|
+
const id = from ?? `${part}.pitch`;
|
|
1101
|
+
if (listed)
|
|
1102
|
+
return [{ kind: 'set-input-range', input: id, min: f.min, max: f.max }, { kind: 'publish-input', input: id, label: f.label }];
|
|
1103
|
+
const exists = asset.document.model.inputs.some(i => i.id === id);
|
|
1104
|
+
return [
|
|
1105
|
+
...(exists ? [{ kind: 'set-input-range', input: id, min: f.min, max: f.max }] : [{ kind: 'add-design-input', id, unit: 'mm', min: f.min, max: f.max, value: pitch }]),
|
|
1106
|
+
...(from ? [] : [{ kind: 'set-repeat', part, pitch: { from: { of: 'input', input: id } } }]),
|
|
1107
|
+
{ kind: 'publish-input', input: id, label: f.label }
|
|
1108
|
+
];
|
|
1109
|
+
};
|
|
1110
|
+
const run = (list) => {
|
|
1111
|
+
try {
|
|
1112
|
+
this.session.applyRecipe(list);
|
|
1113
|
+
this.publishing = undefined;
|
|
1114
|
+
this.error = '';
|
|
1115
|
+
this.changed();
|
|
1116
|
+
}
|
|
1117
|
+
catch (error) {
|
|
1118
|
+
this.error = this.said(error);
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
return html `<div public-pitch>
|
|
1122
|
+
<label toggle>
|
|
1123
|
+
<input
|
|
1124
|
+
type="checkbox"
|
|
1125
|
+
aria-label="figure.label.board-sets"
|
|
1126
|
+
.checked=${open}
|
|
1127
|
+
?disabled=${unavailable}
|
|
1128
|
+
@change=${(e) => e.target.checked
|
|
1129
|
+
? (this.publishing = { part, label: i18next.t('figure.label.repeat-gap'), min: Math.max(1, Math.round(pitch / 2)), max: Math.round(pitch * 2) })
|
|
1130
|
+
: listed
|
|
1131
|
+
? run([{ kind: 'unpublish-input', input: from }, { kind: 'set-repeat', part, pitch }])
|
|
1132
|
+
: (this.publishing = undefined)}
|
|
1133
|
+
/>
|
|
1134
|
+
${i18next.t('figure.label.board-sets')}
|
|
1135
|
+
</label>
|
|
1136
|
+
${open
|
|
1137
|
+
? html `<div inline-field><label>${i18next.t('figure.label.board-name')}</label><input aria-label="figure.label.board-name" .value=${form.label} @change=${edit('label')} /></div>
|
|
1138
|
+
<div inline-field><label>${i18next.t('figure.label.least')} <span unit>mm</span></label><input type="number" step="any" aria-label="figure.label.least" .value=${String(form.min)} @change=${edit('min')} /></div>
|
|
1139
|
+
<div inline-field><label>${i18next.t('figure.label.most')} <span unit>mm</span></label><input type="number" step="any" aria-label="figure.label.most" .value=${String(form.max)} @change=${edit('max')} /></div>
|
|
1140
|
+
<button act publish-pitch ?disabled=${unavailable || !form.label.trim()} @click=${() => run(steps())}>
|
|
1141
|
+
<md-icon>${listed ? 'check' : 'ios_share'}</md-icon>${i18next.t(listed ? 'figure.button.apply' : 'figure.button.publish-input')}
|
|
1142
|
+
</button>`
|
|
1143
|
+
: nothing}
|
|
1144
|
+
</div>`;
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* A pitch always goes through `set-repeat`: the command moves the longest length with it (at most `limit` copies),
|
|
1148
|
+
* which a plain input edit would not. Refused only when the authored length would already hold more copies than
|
|
1149
|
+
* that -- said with the numbers.
|
|
1150
|
+
*/
|
|
1151
|
+
setPitch(field, event) {
|
|
1152
|
+
const input = event.target;
|
|
1153
|
+
const pitch = input.valueAsNumber;
|
|
1154
|
+
if (!Number.isFinite(pitch) || pitch === field.value)
|
|
1155
|
+
return;
|
|
1156
|
+
/* Read from a design input the board may set: the input's value changes, the row keeps reading it (ADR-0096). */
|
|
1157
|
+
const from = this.pitchInputOf(JSON.parse(this.session.source()), this.selected);
|
|
1158
|
+
if (from) {
|
|
1159
|
+
this.run(() => this.session.apply([{ kind: 'set-design', input: from, unit: 'mm', value: pitch }]));
|
|
1160
|
+
input.value = String(this.session.read().fields.find(i => i.id === from)?.value ?? field.value);
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
try {
|
|
1164
|
+
this.session.command({ kind: 'set-repeat', part: this.selected, pitch });
|
|
1165
|
+
this.error = '';
|
|
1166
|
+
this.changed();
|
|
1167
|
+
}
|
|
1168
|
+
catch (error) {
|
|
1169
|
+
input.value = String(field.value);
|
|
1170
|
+
const code = error?.code;
|
|
1171
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1172
|
+
const found = /\((\d[\d.]*) mm\) a pitch under ([\d.]+) mm makes more than (\d+)/.exec(message);
|
|
1173
|
+
this.error =
|
|
1174
|
+
code === 'INPUT_RANGE' && found
|
|
1175
|
+
? i18next.t('figure.text.repeat-pitch-too-small', { length: Number(found[1]).toLocaleString(), min: found[2], limit: found[3] })
|
|
1176
|
+
: this.said(error);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
/** Choose a part, from the list, the canvas or a place row. A figure-level tab gives way to the part's properties. */
|
|
1180
|
+
choose(id) {
|
|
1181
|
+
/* A copy on the canvas selects its repeat: the part the author made. */
|
|
1182
|
+
this.selected = id ? ownerOf(id) : id;
|
|
1183
|
+
if (id && (this.tab === 'verdict' || this.tab === 'view' || this.tab === 'history'))
|
|
1184
|
+
this.tab = 'properties';
|
|
1185
|
+
}
|
|
1186
|
+
asset() {
|
|
1187
|
+
try {
|
|
1188
|
+
return JSON.parse(this.session.source());
|
|
1189
|
+
}
|
|
1190
|
+
catch {
|
|
1191
|
+
return undefined;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
renderTab(tab, icon, label, badge) {
|
|
1195
|
+
return html `<button tab ?on=${this.tab === tab} title=${label} aria-label=${label} @click=${() => (this.tab = tab)}>
|
|
1196
|
+
<md-icon>${icon}</md-icon>${badge == null ? '' : html `<span badge>${badge.toLocaleString()}</span>`}
|
|
1197
|
+
</button>`;
|
|
1198
|
+
}
|
|
1199
|
+
updated(changed) {
|
|
1200
|
+
super.updated?.(changed);
|
|
1201
|
+
const panes = this.renderRoot.querySelector('ox-three-pane') ?? undefined;
|
|
1202
|
+
if (panes !== this.panes)
|
|
1203
|
+
this.panes = panes;
|
|
1204
|
+
}
|
|
1205
|
+
/** Which part the panel speaks of, with the way back to the whole figure. */
|
|
1206
|
+
renderSubject() {
|
|
1207
|
+
if (!this.selected)
|
|
1208
|
+
return null;
|
|
1209
|
+
return html `<div subject>
|
|
1210
|
+
<button chip title=${i18next.t('figure.button.whole-figure')} @click=${() => (this.selected = '')}>
|
|
1211
|
+
<md-icon>arrow_back</md-icon>${i18next.t('figure.button.whole-figure')}
|
|
1212
|
+
</button>
|
|
1213
|
+
</div>`;
|
|
1214
|
+
}
|
|
1215
|
+
render() {
|
|
1216
|
+
const view = this.session?.read();
|
|
1217
|
+
if (!view)
|
|
1218
|
+
return html `<p>${i18next.t('figure.text.opening-model')}</p>`;
|
|
1219
|
+
const unavailable = view.loading || !!view.error || view.saving || !view.context;
|
|
1220
|
+
const part = view.geometry.find(g => ownerOf(g.id) === this.selected);
|
|
1221
|
+
/* The controls (state inputs) have their own place in the motion tab; these are the design values. */
|
|
1222
|
+
const design = view.fields.filter(i => i.role !== 'state');
|
|
1223
|
+
/* A repeat's own row values (its pitch) have their own section, not the shape's. */
|
|
1224
|
+
const own = design.filter(i => this.selected && i.id.startsWith(this.selected + '.') && !i.id.startsWith(this.selected + '.repeat.'));
|
|
1225
|
+
const common = design.filter(i => !view.geometry.some(g => i.id.startsWith(ownerOf(g.id) + '.')));
|
|
1226
|
+
const status = view.loading
|
|
1227
|
+
? 'figure.text.loading-figure'
|
|
1228
|
+
: view.saving
|
|
1229
|
+
? 'figure.text.saving-figure'
|
|
1230
|
+
: view.dirty || !view.id
|
|
1231
|
+
? 'figure.text.unsaved-changes'
|
|
1232
|
+
: 'figure.text.saved';
|
|
1233
|
+
const asset = this.asset();
|
|
1234
|
+
const tab = this.tab;
|
|
1235
|
+
return html `<ox-canvas-bar
|
|
1236
|
+
history
|
|
1237
|
+
fit
|
|
1238
|
+
undo-shortcut="Ctrl+Z"
|
|
1239
|
+
redo-shortcut="Ctrl+Y"
|
|
1240
|
+
?can-undo=${!unavailable && view.canUndo}
|
|
1241
|
+
?can-redo=${!unavailable && view.canRedo}
|
|
1242
|
+
.pane=${this.panes}
|
|
1243
|
+
@canvas-undo=${() => this.run(() => this.session.undo())}
|
|
1244
|
+
@canvas-redo=${() => this.run(() => this.session.redo())}
|
|
1245
|
+
@canvas-fit=${() => this.renderRoot.querySelector('figure-canvas')?.fit()}
|
|
1246
|
+
>
|
|
1247
|
+
${this.renderGizmoTools(!unavailable && this.middle === 'edit')}
|
|
1248
|
+
${['edit', 'preview'].map(mode => html `<button slot="mode" mode aria-pressed=${String(this.middle === mode)} title=${i18next.t('figure.text.mode-' + mode + '-explained')} @click=${() => (this.middle = mode)}>
|
|
1249
|
+
${i18next.t('figure.label.mode-' + mode)}
|
|
1250
|
+
</button>`)}
|
|
1251
|
+
<span slot="status" class="status" role="status" ?dirty=${status === 'figure.text.unsaved-changes'}>${i18next.t(status)}</span>
|
|
1252
|
+
<button slot="commit" save ?disabled=${unavailable || (!view.dirty && !!view.id)} @click=${this.save}>${i18next.t('figure.button.save')}</button>
|
|
1253
|
+
</ox-canvas-bar>
|
|
1254
|
+
${this.error || view.error
|
|
1255
|
+
? html `<div role="alert" class="error">
|
|
1256
|
+
${this.error || view.error}
|
|
1257
|
+
${this.retry && this.error
|
|
1258
|
+
? html `<button act @click=${() => (this.retry.run ? this.retry.run() : this.linkCommand(this.retry.action))}><md-icon>straighten</md-icon>${this.retry.label}</button>`
|
|
1259
|
+
: null}
|
|
1260
|
+
</div>`
|
|
1261
|
+
: null}
|
|
1262
|
+
${this.notice ? html `<div role="status" class="notice">${this.notice}</div>` : null}
|
|
1263
|
+
${this.catalogOpen
|
|
1264
|
+
? html `<figure-recipe-catalog
|
|
1265
|
+
.templates=${this.templates}
|
|
1266
|
+
.selected=${this.selected}
|
|
1267
|
+
.error=${this.recipeError}
|
|
1268
|
+
.guideOf=${this.guideOf}
|
|
1269
|
+
.thumbnailOf=${this.thumbnailOf}
|
|
1270
|
+
?locked=${unavailable}
|
|
1271
|
+
@insert-recipe=${(e) => this.insertRecipe(e.detail.recipe, e.detail.values)}
|
|
1272
|
+
@close-catalog=${() => (this.catalogOpen = false)}
|
|
1273
|
+
></figure-recipe-catalog>`
|
|
1274
|
+
: null}
|
|
1275
|
+
<ox-three-pane>
|
|
1276
|
+
<figure-parts
|
|
1277
|
+
slot="start"
|
|
1278
|
+
.budget=${this.budget}
|
|
1279
|
+
@show-maturity=${() => (this.tab = 'verdict')}
|
|
1280
|
+
.parts=${this.partRows(view.geometry)}
|
|
1281
|
+
.partBudget=${this.partBudgetOf(asset)}
|
|
1282
|
+
@set-detail-level=${(e) => this.linkCommand({ kind: 'set-detail-level', level: e.detail.level })}
|
|
1283
|
+
.selected=${this.selected}
|
|
1284
|
+
?locked=${unavailable}
|
|
1285
|
+
@add-part=${(e) => this.add(e.detail.kind)}
|
|
1286
|
+
.recipeCount=${this.templates.length}
|
|
1287
|
+
@open-recipe-catalog=${() => ((this.catalogOpen = true), (this.recipeError = ''))}
|
|
1288
|
+
@select-part=${(e) => this.choose(e.detail.id)}
|
|
1289
|
+
@toggle-part-hidden=${(e) => this.toggleHiddenPart(e.detail.id)}
|
|
1290
|
+
@set-all-parts-hidden=${(e) => (this.hiddenParts = e.detail.hidden ? new Set(view.geometry.map(g => ownerOf(g.id))) : new Set())}
|
|
1291
|
+
@move-part-up=${(e) => this.movePart(e.detail.id, e.detail.to)}
|
|
1292
|
+
@move-part-down=${(e) => this.movePart(e.detail.id, e.detail.to)}
|
|
1293
|
+
@duplicate-part=${(e) => this.duplicatePart(e.detail.id)}
|
|
1294
|
+
@remove-part=${(e) => this.removePart(e.detail.id)}
|
|
1295
|
+
></figure-parts>
|
|
1296
|
+
${this.middle === 'preview'
|
|
1297
|
+
? html `<figure-preview
|
|
1298
|
+
.asset=${asset}
|
|
1299
|
+
.context=${view.context ?? ''}
|
|
1300
|
+
.view=${this.view}
|
|
1301
|
+
@part-edit=${(e) => this.run(() => this.session.edit(e.detail.edit))}
|
|
1302
|
+
></figure-preview>`
|
|
1303
|
+
: html `<figure-canvas
|
|
1304
|
+
.view=${this.view}
|
|
1305
|
+
.parts=${this.drawnParts(view.geometry, asset)}
|
|
1306
|
+
.fan=${this.fanOf(asset)}
|
|
1307
|
+
.palette=${view.palette ?? {}}
|
|
1308
|
+
.context=${view.context ?? ''}
|
|
1309
|
+
.selected=${this.selected}
|
|
1310
|
+
.reach=${unavailable ? { translate: false, rotate: false, scale: false } : this.reachOf(this.selected)}
|
|
1311
|
+
@part-transformed=${(e) => this.transformed(e.detail.id, e.detail.result)}
|
|
1312
|
+
@part-selected=${(e) => this.choose(e.detail)}
|
|
1313
|
+
@render-error=${(e) => {
|
|
1314
|
+
this.error = e.detail.message;
|
|
1315
|
+
}}
|
|
1316
|
+
></figure-canvas>`}
|
|
1317
|
+
<aside slot="end">
|
|
1318
|
+
<div tabs>
|
|
1319
|
+
${this.renderTab('properties', 'tune', i18next.t('figure.label.properties'))}
|
|
1320
|
+
${this.renderTab('capability', 'conveyor_belt', i18next.t('figure.label.tab-capability'))}
|
|
1321
|
+
${this.renderTab('motion', 'animation', i18next.t('figure.label.motion'))}
|
|
1322
|
+
${this.renderTab('verdict', 'insights', i18next.t('figure.label.maturity'), this.instances)}
|
|
1323
|
+
${this.renderTab('view', 'wb_sunny', i18next.t('figure.label.tab-environment'))}
|
|
1324
|
+
${this.renderTab('history', 'history', i18next.t('figure.label.history'))}
|
|
1325
|
+
</div>
|
|
1326
|
+
<slot name="notice"></slot>
|
|
1327
|
+
<div panel ?off=${tab !== 'properties'}>
|
|
1328
|
+
${this.selected && part
|
|
1329
|
+
? html `${this.renderSubject()}
|
|
1330
|
+
<section>
|
|
1331
|
+
<h3>${i18next.t('figure.label.group-part')}</h3>
|
|
1332
|
+
<div inline-field>
|
|
1333
|
+
<label>${i18next.t('figure.label.name')}</label>
|
|
1334
|
+
<input
|
|
1335
|
+
name-field
|
|
1336
|
+
aria-label=${i18next.t('figure.label.name')}
|
|
1337
|
+
.value=${partLabelOf(this.selected)}
|
|
1338
|
+
?disabled=${unavailable || !!repeatOf(this.selected, view.geometry)?.index}
|
|
1339
|
+
@change=${(e) => this.renamePart(e.target)}
|
|
1340
|
+
/>
|
|
1341
|
+
</div>
|
|
1342
|
+
${this.renderRepeatNote(view.geometry)}
|
|
1343
|
+
</section>
|
|
1344
|
+
${this.renderRepeat(asset, view.geometry, unavailable)}
|
|
1345
|
+
${this.renderGroups(groupFields(own, this.selected), 'figure.label.group-placement-size', 'figure.label.group-shape', unavailable, this.renderTools(unavailable))}
|
|
1346
|
+
${this.renderLinks(unavailable, 'shape')}
|
|
1347
|
+
<figure-material-panel
|
|
1348
|
+
.body=${{ ...part, id: this.selected }}
|
|
1349
|
+
.palette=${view.palette ?? {}}
|
|
1350
|
+
?locked=${unavailable}
|
|
1351
|
+
@part-edit=${(e) => this.run(() => this.session.edit(e.detail.edit))}
|
|
1352
|
+
@part-live=${(e) => this.hold({}, e.detail.edit)}
|
|
1353
|
+
></figure-material-panel>`
|
|
1354
|
+
: html `<slot name="figure"></slot>
|
|
1355
|
+
${this.renderGroups(groupFields(common), 'figure.label.group-figure-size', 'figure.label.design-inputs', unavailable)}
|
|
1356
|
+
${this.renderInstanceRange(asset, unavailable)}`}
|
|
1357
|
+
</div>
|
|
1358
|
+
<div panel ?off=${tab !== 'capability'}>
|
|
1359
|
+
${this.renderSubject()}
|
|
1360
|
+
${this.selected && part ? this.renderLinks(unavailable, 'places') : null}
|
|
1361
|
+
<figure-capability-panel
|
|
1362
|
+
.asset=${asset}
|
|
1363
|
+
.selected=${this.selected}
|
|
1364
|
+
?locked=${unavailable}
|
|
1365
|
+
@select-part=${(e) => this.choose(e.detail.id)}
|
|
1366
|
+
@part-edit=${(e) => this.run(() => this.session.edit(e.detail.edit))}
|
|
1367
|
+
></figure-capability-panel>
|
|
1368
|
+
</div>
|
|
1369
|
+
<div panel ?off=${tab !== 'motion'}>
|
|
1370
|
+
${this.renderSubject()}
|
|
1371
|
+
${this.selected && part ? this.renderLinks(unavailable, 'motion') : html `<section><p hint>${i18next.t('figure.text.choose-a-part-to-move')}</p></section>`}
|
|
1372
|
+
${this.renderControls(view, unavailable)}
|
|
1373
|
+
</div>
|
|
1374
|
+
<div panel flush ?off=${tab !== 'verdict'}><slot name="verdict"></slot></div>
|
|
1375
|
+
<div panel flush ?off=${tab !== 'view'}>
|
|
1376
|
+
<figure-settings .view=${this.view} @update-view=${(e) => this.setView(e.detail.view)}></figure-settings>
|
|
1377
|
+
</div>
|
|
1378
|
+
<div panel flush ?off=${tab !== 'history'}><slot name="history"></slot></div>
|
|
1379
|
+
</aside>
|
|
1380
|
+
</ox-three-pane>`;
|
|
1381
|
+
}
|
|
1382
|
+
/** Position, rotation and size as rows of three cells; the shape's own measures one to a line, under their title. */
|
|
1383
|
+
renderGroups(groups, vectorTitle, singleTitle, unavailable, tools = null) {
|
|
1384
|
+
return html `${groups.vectors.length || tools
|
|
1385
|
+
? html `<section>
|
|
1386
|
+
<h3>${i18next.t(vectorTitle)}</h3>
|
|
1387
|
+
${groups.vectors.map(g => this.renderVector(g, unavailable))}
|
|
1388
|
+
${tools ? html `<div vector-row><label>${i18next.t('figure.label.tools')}</label>${tools}</div>` : nothing}
|
|
1389
|
+
</section>`
|
|
1390
|
+
: nothing}
|
|
1391
|
+
${groups.singles.length
|
|
1392
|
+
? html `<section>
|
|
1393
|
+
<h3>${i18next.t(singleTitle)}</h3>
|
|
1394
|
+
<div form>${groups.singles.map(g => (g.kind === 'single' ? this.renderSingle(g.name, g.field, unavailable) : nothing))}</div>
|
|
1395
|
+
</section>`
|
|
1396
|
+
: nothing}`;
|
|
1397
|
+
}
|
|
1398
|
+
renderVector(group, unavailable) {
|
|
1399
|
+
if (group.kind !== 'vector')
|
|
1400
|
+
return nothing;
|
|
1401
|
+
const unit = group.cells.x.unit === 'deg' ? '°' : group.cells.x.unit;
|
|
1402
|
+
return html `<div vector-row>
|
|
1403
|
+
<label>${i18next.t('figure.label.group-' + group.name)}${group.name === 'rotation' ? '' : html ` <span unit>${unit}</span>`}</label>
|
|
1404
|
+
<div triple>
|
|
1405
|
+
${['x', 'y', 'z'].map(axis => html `<div cell>
|
|
1406
|
+
<span axis ?scrub=${!unavailable} @pointerdown=${(e) => this.scrub(group.cells[axis], e, unavailable)}>${axis.toUpperCase()}</span>
|
|
1407
|
+
<input
|
|
1408
|
+
aria-label=${group.cells[axis].id}
|
|
1409
|
+
type="number"
|
|
1410
|
+
step="any"
|
|
1411
|
+
.value=${String(group.cells[axis].value)}
|
|
1412
|
+
?disabled=${unavailable}
|
|
1413
|
+
@input=${(e) => this.typing(group.cells[axis], e)}
|
|
1414
|
+
@change=${(e) => this.changeField(group.cells[axis], e)}
|
|
1415
|
+
/>
|
|
1416
|
+
</div>`)}
|
|
1417
|
+
</div>
|
|
1418
|
+
</div>`;
|
|
1419
|
+
}
|
|
1420
|
+
renderSingle(name, field, unavailable) {
|
|
1421
|
+
const words = name.split('.').map(part => i18next.t('figure.label.field-' + part, { defaultValue: part }));
|
|
1422
|
+
return html `<span ?scrub=${!unavailable} @pointerdown=${(e) => this.scrub(field, e, unavailable)}>${words.join(' · ')} (${field.unit})</span
|
|
1423
|
+
><input
|
|
1424
|
+
aria-label=${field.id}
|
|
1425
|
+
type="number"
|
|
1426
|
+
step="any"
|
|
1427
|
+
.value=${String(field.value)}
|
|
1428
|
+
?disabled=${unavailable}
|
|
1429
|
+
@input=${(e) => this.typing(field, e)}
|
|
1430
|
+
@change=${(e) => this.changeField(field, e)}
|
|
1431
|
+
/>`;
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
__decorate([
|
|
1435
|
+
property({ attribute: false }),
|
|
1436
|
+
__metadata("design:type", Object)
|
|
1437
|
+
], FigureEditor.prototype, "session", void 0);
|
|
1438
|
+
__decorate([
|
|
1439
|
+
property({ attribute: false }),
|
|
1440
|
+
__metadata("design:type", Array)
|
|
1441
|
+
], FigureEditor.prototype, "templates", void 0);
|
|
1442
|
+
__decorate([
|
|
1443
|
+
property({ attribute: false }),
|
|
1444
|
+
__metadata("design:type", Function)
|
|
1445
|
+
], FigureEditor.prototype, "guideOf", void 0);
|
|
1446
|
+
__decorate([
|
|
1447
|
+
property({ attribute: false }),
|
|
1448
|
+
__metadata("design:type", Function)
|
|
1449
|
+
], FigureEditor.prototype, "thumbnailOf", void 0);
|
|
1450
|
+
__decorate([
|
|
1451
|
+
state(),
|
|
1452
|
+
__metadata("design:type", Object)
|
|
1453
|
+
], FigureEditor.prototype, "publishing", void 0);
|
|
1454
|
+
__decorate([
|
|
1455
|
+
state(),
|
|
1456
|
+
__metadata("design:type", Object)
|
|
1457
|
+
], FigureEditor.prototype, "catalogOpen", void 0);
|
|
1458
|
+
__decorate([
|
|
1459
|
+
state(),
|
|
1460
|
+
__metadata("design:type", Object)
|
|
1461
|
+
], FigureEditor.prototype, "recipeError", void 0);
|
|
1462
|
+
__decorate([
|
|
1463
|
+
property({ type: Number }),
|
|
1464
|
+
__metadata("design:type", Object)
|
|
1465
|
+
], FigureEditor.prototype, "revision", void 0);
|
|
1466
|
+
__decorate([
|
|
1467
|
+
property({ type: Number }),
|
|
1468
|
+
__metadata("design:type", Number)
|
|
1469
|
+
], FigureEditor.prototype, "instances", void 0);
|
|
1470
|
+
__decorate([
|
|
1471
|
+
property({ attribute: false }),
|
|
1472
|
+
__metadata("design:type", Object)
|
|
1473
|
+
], FigureEditor.prototype, "budget", void 0);
|
|
1474
|
+
__decorate([
|
|
1475
|
+
property({ attribute: false }),
|
|
1476
|
+
__metadata("design:type", Function)
|
|
1477
|
+
], FigureEditor.prototype, "firstSave", void 0);
|
|
1478
|
+
__decorate([
|
|
1479
|
+
state(),
|
|
1480
|
+
__metadata("design:type", Object)
|
|
1481
|
+
], FigureEditor.prototype, "selected", void 0);
|
|
1482
|
+
__decorate([
|
|
1483
|
+
state(),
|
|
1484
|
+
__metadata("design:type", Object)
|
|
1485
|
+
], FigureEditor.prototype, "error", void 0);
|
|
1486
|
+
__decorate([
|
|
1487
|
+
state(),
|
|
1488
|
+
__metadata("design:type", Object)
|
|
1489
|
+
], FigureEditor.prototype, "retry", void 0);
|
|
1490
|
+
__decorate([
|
|
1491
|
+
state(),
|
|
1492
|
+
__metadata("design:type", String)
|
|
1493
|
+
], FigureEditor.prototype, "tab", void 0);
|
|
1494
|
+
__decorate([
|
|
1495
|
+
state(),
|
|
1496
|
+
__metadata("design:type", Function)
|
|
1497
|
+
], FigureEditor.prototype, "panes", void 0);
|
|
1498
|
+
__decorate([
|
|
1499
|
+
state(),
|
|
1500
|
+
__metadata("design:type", String)
|
|
1501
|
+
], FigureEditor.prototype, "middle", void 0);
|
|
1502
|
+
__decorate([
|
|
1503
|
+
state(),
|
|
1504
|
+
__metadata("design:type", String)
|
|
1505
|
+
], FigureEditor.prototype, "gizmoMode", void 0);
|
|
1506
|
+
__decorate([
|
|
1507
|
+
state(),
|
|
1508
|
+
__metadata("design:type", Object)
|
|
1509
|
+
], FigureEditor.prototype, "notice", void 0);
|
|
1510
|
+
__decorate([
|
|
1511
|
+
state(),
|
|
1512
|
+
__metadata("design:type", Object)
|
|
1513
|
+
], FigureEditor.prototype, "view", void 0);
|
|
1514
|
+
__decorate([
|
|
1515
|
+
state(),
|
|
1516
|
+
__metadata("design:type", Object)
|
|
1517
|
+
], FigureEditor.prototype, "hiddenParts", void 0);
|
|
1518
|
+
__decorate([
|
|
1519
|
+
state(),
|
|
1520
|
+
__metadata("design:type", Object)
|
|
1521
|
+
], FigureEditor.prototype, "live", void 0);
|
|
1522
|
+
FigureEditor = FigureEditor_1 = __decorate([
|
|
1523
|
+
customElement('figure-editor')
|
|
1524
|
+
], FigureEditor);
|
|
1525
|
+
export { FigureEditor };
|
|
1526
|
+
//# sourceMappingURL=editor.js.map
|