@rig-c/review 1.6.0 → 1.7.0
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/docs/DESIGN.md +58 -4
- package/docs/PANELS.md +31 -0
- package/docs/PARTS_VIEW.md +133 -3
- package/docs/REVIEW_PACKAGE.md +9 -0
- package/docs/WORKFLOWS.md +4 -0
- package/package.json +1 -1
- package/src/cli.ts +6 -5
- package/src/comment-crops.ts +19 -6
- package/src/compare-html.ts +3 -1
- package/src/compare-server.ts +5 -1
- package/src/front.ts +25 -3
- package/src/parts-comment-crops.ts +31 -0
- package/src/parts-comment.ts +33 -0
- package/src/parts-comparison.ts +20 -0
- package/src/parts-server.ts +9 -4
- package/src/parts-view.ts +49 -12
- package/src/server.ts +5 -1
- package/src/stage-parts.ts +37 -0
- package/web/camera-view.ts +9 -8
- package/web/catalog-en.ts +47 -0
- package/web/catalog-ko.ts +47 -0
- package/web/compare.css +16 -0
- package/web/compare.html +2 -2
- package/web/compare.ts +3 -0
- package/web/index.html +2 -2
- package/web/main.ts +35 -104
- package/web/parts-flags.ts +11 -2
- package/web/parts-render.ts +19 -3
- package/web/parts-viewport-provider.ts +14 -0
- package/web/parts.css +40 -6
- package/web/parts.html +11 -3
- package/web/parts.ts +131 -26
- package/web/rig-viewport-provider.ts +44 -0
- package/web/stage-comments.ts +38 -25
- package/web/stage-nav.ts +45 -0
- package/web/styles.css +16 -0
- package/web/view-controls.ts +6 -4
- package/web/viewport-capture.ts +2 -1
- package/web/viewport-controller.ts +93 -0
- package/web/viewport-pair.ts +5 -0
package/web/parts.ts
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
|
+
import {defaultPartsComparison,paintingRectangle} from '../src/parts-comparison.ts';
|
|
2
|
+
import {mountViewportPair} from './viewport-pair.ts';
|
|
3
|
+
import {createPartsViewport} from './parts-viewport-provider.ts';
|
|
4
|
+
import {bindStageComments,type CommentUiPose,type CommentCodec} from './stage-comments.ts';
|
|
5
|
+
import {parsePartsComment,snapImageRegion,type PartsComment} from '../src/parts-comment.ts';
|
|
6
|
+
import {projectMark,unprojectMark,region} from '../src/stage-comment.ts';
|
|
7
|
+
import {bindStageNav} from './stage-nav.ts';
|
|
1
8
|
/**
|
|
2
|
-
* The parts and atlas view (#348). Every part on its own, on a sentinel background,
|
|
3
|
-
*
|
|
4
|
-
* per-part verdict saved as `rig-review-parts-verdict/
|
|
9
|
+
* The parts and atlas view (#348). Every part on its own, on a sentinel background, through the shared native-scale
|
|
10
|
+
* viewport controller; the footprints of the parts drawn in front of it; the producer's flags on it; and a
|
|
11
|
+
* per-part verdict saved as `rig-review-parts-verdict/2`. In atlas mode, the pages as packed with every region's box
|
|
5
12
|
* and name, and a click from a region to its own view.
|
|
6
13
|
*
|
|
7
14
|
* Nothing here measures the art: flags come from the producer's files, and the footprint is the front parts' own
|
|
8
15
|
* alpha drawn over the selected part (the parts.json draw order, back first, says which parts are in front).
|
|
9
16
|
*/
|
|
10
|
-
import { bindDomI18n, onLanguageChange, t } from './i18n.ts';
|
|
17
|
+
import { bindDomI18n, onLanguageChange, setLinkLanguage, setLanguagePreference, t } from './i18n.ts';
|
|
11
18
|
import { pageInstanceAccess } from './instance-access.ts';
|
|
12
19
|
import { connectLiveWindow } from './live-connection.ts';
|
|
13
20
|
import { flagLabel } from './parts-flags.ts';
|
|
14
|
-
import { frontParts, paintAlphaOnly, paintBackground, paintPart, paintMesh } from './parts-render.ts';
|
|
21
|
+
import { frontParts, paintAlphaOnly, paintBackground, paintPart, paintMesh, paintOverlay, paintPaintingCrop, paintFootprints } from './parts-render.ts';
|
|
15
22
|
|
|
16
23
|
type Outcome = 'pending' | 'clean' | 'flagged';
|
|
17
24
|
interface Mesh { vertices: number[]; triangles: number[]; figures: Record<string, unknown> }
|
|
18
25
|
interface Entry { outcome: Outcome; note: string; mesh?: { outcome: Outcome; note: string } }
|
|
19
|
-
interface Item { mesh?: Mesh; name: string; index: number; x: number; y: number; w: number; h: number; page?: string; degrees?: number; image?: boolean }
|
|
26
|
+
interface Item { mesh?: Mesh; name: string; index: number; x: number; y: number; w: number; h: number; page?: string; degrees?: number; image?: boolean;imageHash?:string }
|
|
20
27
|
interface Page { name: string; width: number; height: number; index: number }
|
|
21
28
|
type Flag =
|
|
22
29
|
| { id: string; item: string; source: 'mesh_report'; kind: 'faint'; art: number; maxAlpha: number; box: [number, number, number, number] }
|
|
23
30
|
| { id: string; item: string; source: 'check'; kind: 'check'; path: string; line: string; root: string; status: string | null; entry: Record<string, unknown> };
|
|
24
31
|
interface ViewData {
|
|
25
|
-
mode: 'parts' | 'atlas'; title: string; rigSize: [number, number] | null; items: Item[]; pages: Page[]; flags: Flag[];
|
|
32
|
+
painting:{sha256:string;width:number;height:number}|null;sourceHash:string;mode: 'parts' | 'atlas'; title: string; rigSize: [number, number] | null; items: Item[]; pages: Page[]; flags: Flag[];
|
|
26
33
|
flagSources: string[]; flagMissing: string[]; verdictFile: string;
|
|
27
|
-
verdict: { status: string; parts: Record<string, Entry> } | null; verdictStale: 'files' | 'flags' | null;
|
|
34
|
+
verdict: { comments?:PartsComment[];status: string; parts: Record<string, Entry> } | null; verdictStale: 'files' | 'flags' | null;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
/** Page pixels shown around a region in its own view, so the packer's bleed and padding are visible. */
|
|
@@ -32,7 +39,12 @@ export const REGION_MARGIN = 4;
|
|
|
32
39
|
|
|
33
40
|
const $ = <T extends HTMLElement>(id: string) => document.getElementById(id) as T;
|
|
34
41
|
const access = pageInstanceAccess();
|
|
35
|
-
const
|
|
42
|
+
const stageEmbedded=new URL(location.href).searchParams.get('stageEmbed')==='1';
|
|
43
|
+
const stageSide=new URL(location.href).searchParams.get('side');
|
|
44
|
+
const partsApi=stageEmbedded?(stageSide==='a'||stageSide==='b'?`/api/compare/${stageSide}/stage-parts`:'/api/stage-parts'):'/api/parts';
|
|
45
|
+
|
|
46
|
+
const state = { data: null as ViewData | null, selected: 0, zoom: 1, bg: 'green', alpha: false, footprints: false, comparison:defaultPartsComparison(), view: 'item' as 'item' | 'page', page: 0, meshShown: new Set<string>(), verdict: new Map<string, Entry>() };
|
|
47
|
+
const comments:PartsComment[]=[];let commentUi:ReturnType<typeof bindStageComments>|null=null;let viewport:ReturnType<typeof createPartsViewport>|null=null;let painting=false;
|
|
36
48
|
const images = new Map<string, HTMLImageElement>();
|
|
37
49
|
|
|
38
50
|
function load(src: string): Promise<HTMLImageElement> {
|
|
@@ -45,8 +57,8 @@ function load(src: string): Promise<HTMLImageElement> {
|
|
|
45
57
|
img.src = access.route(src);
|
|
46
58
|
});
|
|
47
59
|
}
|
|
48
|
-
const itemImage = (item: Item) => load(
|
|
49
|
-
const pageImage = (name: string) => { const page = state.data!.pages.find(p => p.name === name)!; return load(
|
|
60
|
+
const itemImage = (item: Item) => load(`${partsApi}/image/${item.index}`);
|
|
61
|
+
const pageImage = (name: string) => { const page = state.data!.pages.find(p => p.name === name)!; return load(`${partsApi}/page/${page.index}`); };
|
|
50
62
|
|
|
51
63
|
function setCanvas(canvas: HTMLCanvasElement, w: number, h: number): CanvasRenderingContext2D {
|
|
52
64
|
canvas.width = w; canvas.height = h;
|
|
@@ -65,10 +77,24 @@ function overlayBox(x: number, y: number, w: number, h: number): HTMLDivElement
|
|
|
65
77
|
}
|
|
66
78
|
|
|
67
79
|
let paintToken = 0;
|
|
68
|
-
|
|
80
|
+
let paintFailure:string|null=null;
|
|
81
|
+
async function paint():Promise<void>{
|
|
82
|
+
const token=++paintToken;painting=true;
|
|
83
|
+
try{
|
|
84
|
+
await paintRaster(token);if(token!==paintToken)return;
|
|
85
|
+
await paintReference(token);if(token!==paintToken)return;
|
|
86
|
+
viewport?.fitCamera();if(paintFailure)$('pv-save-status').textContent='';paintFailure=null;commentUi?.refresh();
|
|
87
|
+
}catch{
|
|
88
|
+
if(token!==paintToken)return;
|
|
89
|
+
paintFailure='PARTS_PAINT_FAILED: view could not be rendered; select the part to retry';
|
|
90
|
+
const canvas=$<HTMLCanvasElement>('pv-canvas');canvas.getContext('2d')?.clearRect(0,0,canvas.width,canvas.height);$('pv-overlay').replaceChildren();
|
|
91
|
+
$('pv-caption').textContent=t(paintFailure);$('pv-save-status').textContent=t(paintFailure);commentUi?.refresh();
|
|
92
|
+
}finally{if(token===paintToken)painting=false;}
|
|
93
|
+
}
|
|
94
|
+
async function paintRaster(token:number): Promise<void> {
|
|
69
95
|
const data = state.data;
|
|
70
96
|
if (!data || !data.items.length) return;
|
|
71
|
-
const
|
|
97
|
+
const canvas = $<HTMLCanvasElement>('pv-canvas'), overlay = $('pv-overlay'), caption = $('pv-caption');
|
|
72
98
|
const item = data.items[state.selected]!;
|
|
73
99
|
if (data.mode === 'atlas' && state.view === 'page') {
|
|
74
100
|
const page = data.pages[state.page]!, img = await pageImage(page.name);
|
|
@@ -78,6 +104,7 @@ async function paint(): Promise<void> {
|
|
|
78
104
|
else { paintBackground(ctx, page.width, page.height, state.bg); ctx.drawImage(img, 0, 0); }
|
|
79
105
|
overlay.replaceChildren(...data.items.filter(r => r.page === page.name).map(r => {
|
|
80
106
|
const box = overlayBox(r.x, r.y, r.w, r.h);
|
|
107
|
+
box.dataset.viewportAction = 'select-region';
|
|
81
108
|
box.dataset.region = r.name; box.dataset.x = String(r.x); box.dataset.y = String(r.y); box.dataset.w = String(r.w); box.dataset.h = String(r.h);
|
|
82
109
|
if (r.index === item.index) box.setAttribute('aria-current', 'true');
|
|
83
110
|
const label = document.createElement('span'); label.textContent = r.name; box.append(label);
|
|
@@ -107,10 +134,13 @@ async function paint(): Promise<void> {
|
|
|
107
134
|
}
|
|
108
135
|
const img = await itemImage(item), front = state.footprints ? frontParts(data.items, item) : [];
|
|
109
136
|
const fronts = await Promise.all(front.map(async o => ({ o, img: await itemImage(o) })));
|
|
137
|
+
const original=state.comparison.mode==='overlay'&&data.painting?await load('/api/parts/painting'):null;
|
|
110
138
|
if (token !== paintToken) return;
|
|
111
139
|
const ctx = setCanvas(canvas, item.w, item.h);
|
|
112
|
-
|
|
113
|
-
if
|
|
140
|
+
const makeCanvas=(w:number,h:number)=>Object.assign(document.createElement('canvas'),{width:w,height:h});
|
|
141
|
+
if(original){paintOverlay(ctx,item,img,original,paintingRectangle(item,data.rigSize!,data.painting!),state.comparison.opacity,state.bg);paintFootprints(ctx,item,fronts.map(f=>({box:f.o,image:f.img})),makeCanvas);}
|
|
142
|
+
else paintPart(ctx, item, img, { bg: state.bg, alpha: state.alpha, fronts: fronts.map(f => ({ box: f.o, image: f.img })), makeCanvas: (w, h) => Object.assign(document.createElement('canvas'), { width: w, height: h }) });
|
|
143
|
+
if (!original && item.mesh && state.meshShown.has(item.name)) paintMesh(ctx, img, item.w, item.h, item.mesh, (w, h) => Object.assign(document.createElement('canvas'), { width: w, height: h }));
|
|
114
144
|
overlay.replaceChildren(...data.flags.filter((f): f is Extract<Flag, { kind: 'faint' }> => f.item === item.name && f.kind === 'faint').map(f => {
|
|
115
145
|
const box = overlayBox(f.box[0], f.box[1], f.box[2], f.box[3]);
|
|
116
146
|
box.dataset.flag = f.id;
|
|
@@ -120,11 +150,21 @@ async function paint(): Promise<void> {
|
|
|
120
150
|
+ (state.footprints ? ' ' + (front.length === 1 ? t('Tinted: the footprint of the part drawn in front ({names}).', { names: front[0]!.name }) : front.length ? t('Tinted: the footprints of {count} parts drawn in front ({names}).', { count: front.length, names: front.map(o => o.name).join(', ') }) : t('No part is drawn in front of it.')) : '');
|
|
121
151
|
}
|
|
122
152
|
|
|
153
|
+
async function paintReference(token:number):Promise<void>{const data=state.data,item=data?.items[state.selected];if(!data?.painting||!item)return;const img=await load('/api/parts/painting');if(token!==paintToken||data!==state.data||item!==state.data?.items[state.selected])return;const canvas=$<HTMLCanvasElement>('pv-reference');canvas.width=item.w;canvas.height=item.h;const ctx=canvas.getContext('2d')!;paintPaintingCrop(ctx,img,paintingRectangle(item,data.rigSize!,data.painting),item.w,item.h,state.bg);}
|
|
154
|
+
|
|
155
|
+
function renderComparison():void {
|
|
156
|
+
const active=state.data?.mode==='parts'&&!!state.data.painting,overlay=active&&state.comparison.mode==='overlay';
|
|
157
|
+
$('pv-comparison').hidden=!active;for(const b of document.querySelectorAll<HTMLElement>('[data-pv-comparison]'))b.setAttribute('aria-pressed',String(b.dataset.pvComparison===state.comparison.mode));
|
|
158
|
+
$('pv-opacity-control').hidden=!overlay;$<HTMLInputElement>('pv-opacity').value=String(state.comparison.opacity);$('pv-opacity-value').textContent=(state.comparison.opacity*100).toFixed(1)+'%';
|
|
159
|
+
$<HTMLInputElement>('pv-alpha').disabled=overlay;
|
|
160
|
+
const mesh=document.querySelector<HTMLInputElement>('#pv-mesh-control input');if(mesh)mesh.disabled=overlay;
|
|
161
|
+
}
|
|
162
|
+
|
|
123
163
|
function renderFlags(): void {
|
|
124
164
|
const data = state.data!, item = data.items[state.selected];
|
|
125
165
|
const list = $('pv-flags');
|
|
126
166
|
const flags = item ? data.flags.filter(f => f.item === item.name) : [];
|
|
127
|
-
|
|
167
|
+
const row = (f: Flag): HTMLLIElement => {
|
|
128
168
|
const li = document.createElement('li');
|
|
129
169
|
li.dataset.flagId = f.id; li.dataset.flagSource = f.source;
|
|
130
170
|
const label = document.createElement('span'); label.className = 'pv-flag-label'; label.textContent = flagLabel(f, t);
|
|
@@ -136,12 +176,35 @@ function renderFlags(): void {
|
|
|
136
176
|
raw.append(summary, code); li.append(raw);
|
|
137
177
|
}
|
|
138
178
|
return li;
|
|
179
|
+
};
|
|
180
|
+
// Source and producer-root groups are presentation only. Every original row and verdict flag id is retained.
|
|
181
|
+
list.replaceChildren(...(['mesh_report', 'check'] as const).flatMap(source => {
|
|
182
|
+
const fromSource = flags.filter(f => f.source === source);
|
|
183
|
+
if (!fromSource.length) return [];
|
|
184
|
+
const sourceItem = document.createElement('li'), heading = document.createElement('h3');
|
|
185
|
+
sourceItem.dataset.pvSource = source;
|
|
186
|
+
heading.textContent = source === 'mesh_report' ? 'mesh_report.json' : 'check.json';
|
|
187
|
+
sourceItem.append(heading);
|
|
188
|
+
const roots = new Map<string, Flag[]>();
|
|
189
|
+
for (const f of fromSource) {
|
|
190
|
+
const root = f.kind === 'check' ? f.root : 'contour.bridges.faint';
|
|
191
|
+
const group = roots.get(root) ?? [];
|
|
192
|
+
group.push(f); roots.set(root, group);
|
|
193
|
+
}
|
|
194
|
+
for (const [root, group] of roots) {
|
|
195
|
+
const details = document.createElement('details'), summary = document.createElement('summary'), rows = document.createElement('ul');
|
|
196
|
+
details.dataset.pvRoot = root; details.dataset.flagSource = source;
|
|
197
|
+
summary.textContent = group.length === 1 ? t('{root} · 1 row', { root }) : t('{root} · {count} rows', { root, count: group.length });
|
|
198
|
+
rows.append(...group.map(row)); details.append(summary, rows); sourceItem.append(details);
|
|
199
|
+
}
|
|
200
|
+
return [sourceItem];
|
|
139
201
|
}));
|
|
140
202
|
if (!flags.length) { const li = document.createElement('li'); li.className = 'pv-none'; li.textContent = t('No producer flag names this part.'); list.replaceChildren(li); }
|
|
141
203
|
$('pv-flag-sources').textContent = [
|
|
142
204
|
data.flagSources.length ? t('Read from: {files}.', { files: data.flagSources.join(', ') }) : '',
|
|
143
205
|
data.flagMissing.length ? t('Not found: {files}.', { files: data.flagMissing.join(', ') }) : '',
|
|
144
206
|
t('Occlusion coverage is not read yet: the producer does not write it.'),
|
|
207
|
+
t('Grouped by source and producer root; counts are rows, not a classification of defects.'),
|
|
145
208
|
].filter(Boolean).join(' ');
|
|
146
209
|
}
|
|
147
210
|
|
|
@@ -153,8 +216,16 @@ function renderList(): void {
|
|
|
153
216
|
button.type = 'button'; button.dataset.pvItem = item.name; button.title = item.name;
|
|
154
217
|
if (data.items[state.selected]?.name === item.name) button.setAttribute('aria-current', 'true');
|
|
155
218
|
const name = document.createElement('span'); name.className = 'pv-name'; name.textContent = item.name;
|
|
156
|
-
const
|
|
157
|
-
const flags = document.createElement('span'); flags.className = 'pv-count';
|
|
219
|
+
const onItem = data.flags.filter(f => f.item === item.name);
|
|
220
|
+
const flags = document.createElement('span'); flags.className = 'pv-count';
|
|
221
|
+
// flagSources holds actual basenames (including custom.json); flagMissing canonically names unread kinds.
|
|
222
|
+
const meshRead = !data.flagMissing.includes('mesh_report.json'), checkRead = !data.flagMissing.includes('check.json');
|
|
223
|
+
const mesh = onItem.filter(f => f.source === 'mesh_report').length, check = onItem.filter(f => f.source === 'check').length;
|
|
224
|
+
if (onItem.length) {
|
|
225
|
+
if (meshRead && checkRead) flags.textContent = t('mesh {mesh} · check {check}', { mesh, check });
|
|
226
|
+
else if (meshRead) flags.textContent = t('mesh {mesh}', { mesh });
|
|
227
|
+
else if (checkRead) flags.textContent = t('check {check}', { check });
|
|
228
|
+
}
|
|
158
229
|
const outcome = state.verdict.get(item.name)?.outcome ?? 'pending';
|
|
159
230
|
const badge = document.createElement('span'); badge.className = 'pv-badge'; badge.dataset.outcome = outcome; badge.textContent = t(outcome === 'clean' ? 'Clean' : outcome === 'flagged' ? 'Flagged' : 'Pending');
|
|
160
231
|
button.append(name, flags, badge);
|
|
@@ -170,6 +241,7 @@ function renderVerdict(): void {
|
|
|
170
241
|
const entry = state.verdict.get(item.name) ?? { outcome: 'pending' as Outcome, note: '' };
|
|
171
242
|
for (const radio of document.querySelectorAll<HTMLInputElement>('input[data-pv-outcome]')) radio.checked = radio.value === entry.outcome;
|
|
172
243
|
$<HTMLTextAreaElement>('pv-note').value = entry.note;
|
|
244
|
+
$('pv-comment-count').textContent=t('Comments on this part: {count}',{count:comments.filter(c=>c.part===item.name).length});
|
|
173
245
|
}
|
|
174
246
|
|
|
175
247
|
function renderMesh(): void {
|
|
@@ -178,7 +250,7 @@ function renderMesh(): void {
|
|
|
178
250
|
const item = state.data!.items[state.selected]!;
|
|
179
251
|
if (!item.mesh) return;
|
|
180
252
|
const control = document.createElement('label'); control.id = 'pv-mesh-control'; control.className = 'pv-field';
|
|
181
|
-
const toggle = document.createElement('input'); toggle.type = 'checkbox'; toggle.checked = state.meshShown.has(item.name);
|
|
253
|
+
const toggle = document.createElement('input'); toggle.type = 'checkbox'; toggle.checked = state.meshShown.has(item.name); toggle.disabled=state.comparison.mode==='overlay';
|
|
182
254
|
toggle.onchange = () => { if (toggle.checked) state.meshShown.add(item.name); else state.meshShown.delete(item.name); void paint(); };
|
|
183
255
|
control.append(toggle, t('mesh from rig.json UVs')); document.querySelector('.pv-toolbar')!.append(control);
|
|
184
256
|
const panel = document.createElement('section'); panel.id = 'pv-mesh-panel';
|
|
@@ -205,10 +277,11 @@ function renderMesh(): void {
|
|
|
205
277
|
|
|
206
278
|
function select(index: number): void {
|
|
207
279
|
const data = state.data!;
|
|
208
|
-
state.selected = index;
|
|
280
|
+
const changed=state.selected!==index;state.selected = index;if(changed&&viewport){viewport.writeCamera('rig',{zoom:1,center:null});viewport.writeCamera('reference',{zoom:1,center:null});}
|
|
281
|
+
commentUi?.refresh();
|
|
209
282
|
const item = data.items[index]!;
|
|
210
283
|
if (item.page !== undefined) state.page = data.pages.findIndex(p => p.name === item.page);
|
|
211
|
-
renderList(); renderFlags(); renderVerdict(); renderMesh(); void paint();
|
|
284
|
+
renderList(); renderFlags(); renderVerdict(); renderMesh(); renderComparison(); void paint();
|
|
212
285
|
}
|
|
213
286
|
|
|
214
287
|
function setView(view: 'item' | 'page'): void {
|
|
@@ -225,8 +298,9 @@ function updateEntry(change: Partial<{ outcome: Outcome; note: string }>): void
|
|
|
225
298
|
}
|
|
226
299
|
|
|
227
300
|
async function save(): Promise<void> {
|
|
301
|
+
if(stageEmbedded)return;
|
|
228
302
|
const status = $('pv-save-status');
|
|
229
|
-
const body = { status: $<HTMLSelectElement>('pv-overall').value, parts: Object.fromEntries(state.verdict) };
|
|
303
|
+
const body = { status: $<HTMLSelectElement>('pv-overall').value, parts: Object.fromEntries(state.verdict),comments };
|
|
230
304
|
const res = await fetch(access.route('/api/parts/verdict'), { method: 'POST', headers: access.headers({ 'Content-Type': 'application/json' }), body: JSON.stringify(body) });
|
|
231
305
|
const out = await res.json() as { error?: string; verdict?: { source: { sha256: string } } };
|
|
232
306
|
status.textContent = res.ok ? t('Saved {file}: source {hash}.', { file: state.data!.verdictFile, hash: out.verdict!.source.sha256.slice(0, 12) }) : out.error ?? t('Save failed.');
|
|
@@ -234,12 +308,24 @@ async function save(): Promise<void> {
|
|
|
234
308
|
}
|
|
235
309
|
|
|
236
310
|
async function boot(): Promise<void> {
|
|
311
|
+
const box=$('pv-canvas-box'),layout=$('stage-layout');mountViewportPair(layout);$('rig-root').append(box);const reference=document.createElement('canvas');reference.id='pv-reference';$('reference-content').append(reference);$('rig-empty').hidden=true;$('rig-overlay').hidden=true;$('rig-label').textContent=t('Selected part');$('rig-viewport').tabIndex=0;
|
|
312
|
+
viewport=createPartsViewport({el:$,canvas:$<HTMLCanvasElement>('pv-canvas'),message:(msg)=>{$('pv-save-status').textContent=t(msg);},reference:()=>state.data?.painting?$<HTMLCanvasElement>('pv-reference'):null});viewport.bindControls();
|
|
313
|
+
$('native-one').onclick=()=>viewport!.cameraAction(()=>viewport!.updateCamera(viewport!.availableCamera()??'rig',{zoom:1,pan:{x:0,y:0}}));
|
|
237
314
|
bindDomI18n(document);
|
|
315
|
+
bindStageNav({partsOnly:true,model:false});
|
|
316
|
+
if(stageEmbedded){
|
|
317
|
+
const header=document.querySelector<HTMLElement>('.pv-top')!,status=$('pv-load');
|
|
318
|
+
header.hidden=true;status.classList.add('pv-embedded-status');header.after(status);
|
|
319
|
+
document.querySelector<HTMLElement>('.pv-layout')!.hidden=true;
|
|
320
|
+
document.querySelector<HTMLElement>('.pv-verdict')!.hidden=true;
|
|
321
|
+
const saveButton=$<HTMLButtonElement>('pv-save');saveButton.disabled=true;saveButton.title=t('Embedded atlas inspection is read-only. Use the parts command for a separate sign-off.');
|
|
322
|
+
}
|
|
323
|
+
window.addEventListener('message',event=>{if(event.source!==parent||event.origin!==location.origin||event.data?.type!=='review-stage-language'||!['en','ko'].includes(event.data.language))return;setLinkLanguage(null);setLanguagePreference(event.data.language);});
|
|
238
324
|
connectLiveWindow(access);
|
|
239
|
-
const res = await fetch(access.route(
|
|
325
|
+
const res = await fetch(access.route(partsApi), { headers: access.headers() });
|
|
240
326
|
const data = await res.json() as ViewData & { error?: string };
|
|
241
|
-
if (!res.ok) {
|
|
242
|
-
state.data = data;
|
|
327
|
+
if (!res.ok) { const status=$('pv-load');status.textContent=t(data.error??'Load failed.');status.dataset.result='refused';return; }
|
|
328
|
+
state.data = data;$('reference-empty').textContent=data.painting?'':t('PARTS_REFERENCE_UNAVAILABLE: supply --painting to compare the original painting');$('reference-empty').hidden=!!data.painting;if(data.painting)viewport.state.cameraSync=true;comments.push(...data.verdict?.comments??[]);setupPartsComments();viewport.bindNavigation(undefined,()=>!commentUi?.active());viewport.observeResize();
|
|
243
329
|
for (const item of data.items) state.verdict.set(item.name, { outcome: 'pending', note: '', ...(item.mesh ? { mesh: { outcome: 'pending' as Outcome, note: '' } } : {}) });
|
|
244
330
|
if (data.verdict) { for (const [name, v] of Object.entries(data.verdict.parts)) if (state.verdict.has(name)) state.verdict.set(name, { outcome: v.outcome, note: v.note ?? '', ...(v.mesh ? { mesh: v.mesh } : {}) }); $<HTMLSelectElement>('pv-overall').value = data.verdict.status; }
|
|
245
331
|
document.title = data.title;
|
|
@@ -247,20 +333,39 @@ async function boot(): Promise<void> {
|
|
|
247
333
|
$('pv-mode').textContent = data.mode === 'parts' ? t('Parts package, before rigging') : t('Atlas of a built rig');
|
|
248
334
|
$('pv-list-title').textContent = data.mode === 'parts' ? t('PARTS') : t('REGIONS');
|
|
249
335
|
$('pv-load').textContent = data.verdictStale === 'files' ? t('A saved sign-off was made on other files; this review starts fresh.') : data.verdictStale === 'flags' ? t('The saved sign-off is for different producer flags; this review starts fresh.') : data.verdict ? t('Saved sign-off loaded.') : '';
|
|
336
|
+
if(stageEmbedded){$('pv-load').hidden=$('pv-load').textContent==='';document.querySelector<HTMLElement>('.pv-layout')!.hidden=false;}
|
|
250
337
|
$('pv-atlas-switch').hidden = data.mode !== 'atlas';
|
|
338
|
+
for(const button of document.querySelectorAll<HTMLElement>('[data-pv-comparison]'))button.onclick=()=>{state.comparison.mode=button.dataset.pvComparison as 'part'|'overlay';if(state.comparison.mode==='overlay'){state.alpha=false;$<HTMLInputElement>('pv-alpha').checked=false;state.meshShown.delete(state.data!.items[state.selected]!.name);renderMesh();}renderComparison();void paint();};
|
|
339
|
+
$<HTMLInputElement>('pv-opacity').oninput=e=>{state.comparison.opacity=Number((e.target as HTMLInputElement).value);renderComparison();void paint();};
|
|
251
340
|
const footprints = $<HTMLInputElement>('pv-footprints');
|
|
252
341
|
if (data.mode === 'atlas') { footprints.disabled = true; $('pv-footprint-control').title = t('Footprints need a parts package: atlas regions carry no rig placement.'); }
|
|
253
342
|
$<HTMLSelectElement>('pv-bg').onchange = e => { state.bg = (e.target as HTMLSelectElement).value; void paint(); };
|
|
254
343
|
$<HTMLInputElement>('pv-alpha').onchange = e => { state.alpha = (e.target as HTMLInputElement).checked; void paint(); };
|
|
255
344
|
footprints.onchange = e => { state.footprints = (e.target as HTMLInputElement).checked; void paint(); };
|
|
256
|
-
|
|
345
|
+
|
|
257
346
|
for (const b of document.querySelectorAll<HTMLButtonElement>('[data-pv-view]')) b.onclick = () => setView(b.dataset.pvView as 'item' | 'page');
|
|
258
347
|
for (const r of document.querySelectorAll<HTMLInputElement>('input[data-pv-outcome]')) r.onchange = () => { if (r.checked) updateEntry({ outcome: r.value as Outcome }); };
|
|
259
348
|
$<HTMLTextAreaElement>('pv-note').oninput = e => updateEntry({ note: (e.target as HTMLTextAreaElement).value });
|
|
260
349
|
$('pv-save').onclick = () => { void save(); };
|
|
350
|
+
for(const format of ['json','issue'])$('pv-export-'+format).onclick=async()=>{const res=await fetch(access.route('/api/parts/export?format='+format),{headers:access.headers()});const value=await res.text();if(!res.ok){$('pv-save-status').textContent=value;return;}const url=URL.createObjectURL(new Blob([value],{type:format==='json'?'application/json':'text/markdown'})),a=document.createElement('a');a.href=url;a.download=format==='json'?'parts-review-export.json':'parts-review-export.md';a.click();setTimeout(()=>URL.revokeObjectURL(url),1000);};
|
|
261
351
|
onLanguageChange(() => { if (state.data) select(state.selected); });
|
|
262
352
|
if (data.items.length) select(0);
|
|
263
353
|
document.body.dataset.ready = 'true';
|
|
264
354
|
}
|
|
265
355
|
|
|
356
|
+
interface PartsPose extends CommentUiPose {item:Item;sourceHash:string;view:PartsComment['view']}
|
|
357
|
+
function setupPartsComments():void {
|
|
358
|
+
const codec:CommentCodec<PartsComment,PartsPose>={
|
|
359
|
+
read:c=>{try{parsePartsComment(c);const camera={space:'image' as const,center:c.view.camera.center,zoom:c.view.camera.zoom,viewport:c.view.camera.viewport,visible:{x:c.view.camera.center.x-c.view.camera.viewport.width/c.view.camera.zoom/2,y:c.view.camera.center.y-c.view.camera.viewport.height/c.view.camera.zoom/2,width:c.view.camera.viewport.width/c.view.camera.zoom,height:c.view.camera.viewport.height/c.view.camera.zoom}};const r=c.imageRegion;return {mode:'parts',viewport:'rig',screen:region(projectMark(r,camera),projectMark({x:r.x+r.width,y:r.y+r.height},camera)),world:r,camera,crop:c.crop,bookmark:{part:c.part,imageHash:c.imageHash,sourceHash:c.sourceHash,view:c.view}};}catch{return null;}},
|
|
360
|
+
signature:p=>[p.item.name,p.item.imageHash,p.sourceHash,p.camera,p.view],
|
|
361
|
+
matches:(_mark,p,c)=>p.item.name===c.part&&p.item.imageHash===c.imageHash&&p.sourceHash===c.sourceHash,
|
|
362
|
+
label:c=>`${c.part} · ${c.summary}`,
|
|
363
|
+
create:async(p,_view,screen,crop,_bookmark,summary)=>{const r=snapImageRegion(region(unprojectMark(screen,p.camera),unprojectMark({x:screen.x+screen.width,y:screen.y+screen.height},p.camera)));const c:PartsComment={schema:'rig-review-parts-comment/1',id:crypto.randomUUID(),summary,part:p.item.name,imageHash:p.item.imageHash!,sourceHash:p.sourceHash,imageRegion:r,rigRegion:{...r,x:p.item.x+r.x,y:p.item.y+r.y},view:p.view,crop,nativeCrop:null};const res=await fetch(access.route('/api/parts/comment'),{method:'POST',headers:access.headers({'Content-Type':'application/json'}),body:JSON.stringify(c)}),out=await res.json() as {comment:PartsComment;error?:string};if(!res.ok)throw new Error(out.error);return parsePartsComment(out.comment);}
|
|
364
|
+
};
|
|
365
|
+
const pose=():PartsPose|null=>{const data=state.data,item=data?.items[state.selected],camera=viewport?.numericView().cameras.rig;if(!data||!item||!camera||data.mode!=='parts'||state.view!=='item')return null;return {mode:'parts',camera,item:{...item},sourceHash:data.sourceHash,view:{camera:{zoom:camera.zoom,center:{...camera.center},viewport:{...camera.viewport}},cameraSync:viewport!.state.cameraSync,referenceCamera:(()=>{const c=viewport!.numericView().cameras.reference;return c?{zoom:c.zoom,center:{...c.center},viewport:{...c.viewport}}:null;})(),background:state.bg,alpha:state.alpha,footprints:state.footprints,mesh:state.meshShown.has(item.name),comparison:{...state.comparison}},capture:{pane:$('rig-viewport'),root:$('rig-root'),images:true,canvas:$<HTMLCanvasElement>('pv-canvas'),backend:'canvas2d',nearest:true}};};
|
|
366
|
+
commentUi=bindStageComments({toolbar:document.querySelector<HTMLElement>('.pv-toolbar')!,viewports:{rig:$('rig-viewport')},pose,pause:async()=>{},bookmark:()=>null,
|
|
367
|
+
restore:async(raw)=>{const b=raw as {part:string;imageHash:string;sourceHash:string;view:PartsComment['view']},item=state.data!.items.find(i=>i.name===b.part);if(!item||item.imageHash!==b.imageHash||state.data!.sourceHash!==b.sourceHash)throw new Error('PARTS_COMMENT_STALE_SOURCE: reopen the bound source');select(item.index);state.bg=b.view.background;state.alpha=b.view.alpha;state.footprints=b.view.footprints;state.comparison={...(b.view.comparison??defaultPartsComparison())};renderComparison();if(b.view.mesh)state.meshShown.add(item.name);else state.meshShown.delete(item.name);$<HTMLSelectElement>('pv-bg').value=state.bg;$<HTMLInputElement>('pv-alpha').checked=state.alpha;$<HTMLInputElement>('pv-footprints').checked=state.footprints;renderMesh();viewport!.state.cameraRestoring=true;try{await paint();viewport!.writeCamera('rig',{zoom:b.view.camera.zoom,center:{...b.view.camera.center}});if(b.view.referenceCamera)viewport!.writeCamera('reference',{zoom:b.view.referenceCamera.zoom,center:{...b.view.referenceCamera.center}});viewport!.state.cameraSync=b.view.cameraSync;viewport!.fitCamera();}finally{viewport!.state.cameraRestoring=false;}},
|
|
368
|
+
feedback:()=>comments,locked:()=>false,add:c=>comments.push(c),changed:()=>renderVerdict(),error:m=>{$('pv-save-status').textContent=t(m);},blocked:()=>painting,refusal:()=>paintFailure??(state.data?.mode!=='parts'||stageEmbedded?'PARTS_COMMENT_UNAVAILABLE: original part image required':null),codec});
|
|
369
|
+
}
|
|
370
|
+
|
|
266
371
|
if (typeof document !== 'undefined' && document.getElementById('parts-app')) void boot();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Existing compiled rig/reference rendering for the shared inspection viewport. */
|
|
2
|
+
import type {ModelAssets,RigPlayer,PoseBounds} from '@rig-c/play';
|
|
3
|
+
import type {ViewportProvider,ViewportState,ViewportController} from './viewport-controller.ts';
|
|
4
|
+
import {dragImpulse} from '../src/environment.ts';
|
|
5
|
+
import {CLICK_SLOP_PX} from './stage-pick.ts';
|
|
6
|
+
export interface RigViewportHost {
|
|
7
|
+
el:ViewportProvider['el'];player:()=>RigPlayer|null;assets:()=>ModelAssets|null;
|
|
8
|
+
referenceSize:()=>{width:number;height:number}|null;view:()=>string;referenceGeneration:()=>number;
|
|
9
|
+
parts:()=>{value:()=>unknown;bounds:()=>PoseBounds|null}|null;
|
|
10
|
+
text:(id:string,value:string)=>void;message:ViewportProvider['message'];redrawOverlay:(fresh:boolean)=>void;
|
|
11
|
+
}
|
|
12
|
+
export function createRigViewportProvider(host:RigViewportHost,state:ViewportState):ViewportProvider {
|
|
13
|
+
const {el,text,message,redrawOverlay}=host;const input=(id:string)=>el<HTMLInputElement>(id),button=(id:string)=>el<HTMLButtonElement>(id);
|
|
14
|
+
function referenceFit(controller:ViewportController): void {
|
|
15
|
+
const referenceSize=host.referenceSize();const {paneFrame}=controller;
|
|
16
|
+
if (!referenceSize || !paneFrame('reference')) return;
|
|
17
|
+
const viewport = el('reference-viewport'), content = el('reference-content');
|
|
18
|
+
const scale = state.referenceScale = Math.max(.001,Math.min((viewport.clientWidth - 24) / referenceSize.width, (viewport.clientHeight - 56) / referenceSize.height) * state.referenceZoom);
|
|
19
|
+
const center=state.referenceCenter??{x:referenceSize.width/2,y:referenceSize.height/2};
|
|
20
|
+
content.style.left = `${viewport.clientWidth/2-center.x*scale}px`;
|
|
21
|
+
content.style.top = `${viewport.clientHeight/2-center.y*scale}px`;
|
|
22
|
+
content.style.transform = `scale(${scale})`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function render(controller:ViewportController): void {
|
|
26
|
+
const player=host.player(),assets=host.assets();const {paneFrame,renderNumericView,renderCameraControls}=controller;
|
|
27
|
+
referenceFit(controller);renderNumericView();renderCameraControls();
|
|
28
|
+
if (!player || !assets) return;
|
|
29
|
+
const box: PoseBounds | null = assets.stage ?? player.bounds(); if (!box || box.width <= 0 || box.height <= 0) return;
|
|
30
|
+
const viewport = el('rig-viewport');if(!paneFrame('rig'))return;
|
|
31
|
+
const scale = state.rigScale = Math.max(.001,Math.min((viewport.clientWidth - 28) / box.width, (viewport.clientHeight - 58) / box.height) * state.zoom);
|
|
32
|
+
const center = state.cameraCenter ?? { x: box.x + box.width / 2, y: box.y + box.height / 2 };state.displayedCenter={...center};
|
|
33
|
+
const root = el('rig-root'); root.style.left = `${viewport.clientWidth / 2 - center.x * scale}px`; root.style.top = `${viewport.clientHeight / 2 + center.y * scale}px`; root.style.transform = `scale(${scale})`;
|
|
34
|
+
player.renderer.syncPixelRatio();redrawOverlay(false);renderNumericView();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function renderControls(controller:ViewportController):void {const {availableCamera,paneCamera}=controller;input('camera-sync').checked=state.cameraSync;const target=availableCamera();text('zoom-value',`${Math.round((target?paneCamera(target).zoom:1)*100)}% · ${target==='reference'?'Reference':'Rig'}`);button('fit').textContent=state.cameraSync?'Fit views':'Fit active';text('coordinates',state.cameraSync?'Cameras synchronized · drag to pan · scroll to zoom':'Independent cameras · drag to pan · scroll to zoom');}
|
|
38
|
+
return {el,message,render,renderControls,
|
|
39
|
+
geometry:target=>{const assets=host.assets(),player=host.player(),referenceSize=host.referenceSize();const box=target==='rig'?assets?.stage??player?.bounds():referenceSize?{x:0,y:0,...referenceSize}:null;if(!box||target==='rig'&&!player)return null;return {space:target==='rig'?'world':'image',box,marginX:target==='rig'?28:24,marginY:target==='rig'?58:56};},
|
|
40
|
+
layoutKey:()=>{const assets=host.assets(),player=host.player(),referenceSize=host.referenceSize(),view=host.view(),referenceGeneration=host.referenceGeneration();const boxKey=assets?.stage??player?.bounds();return ['rig','reference'].map(target=>{const v=el(target+'-viewport');return `${v.clientWidth}:${v.clientHeight}`;}).join('|')+view+referenceGeneration+!!player+JSON.stringify(referenceSize)+JSON.stringify(boxKey);},
|
|
41
|
+
selection:target=>{const parts=host.parts(),part=parts?.value();return {selected:!!part,bounds:target==='rig'&&part?parts?.bounds()??null:null};}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function rigPanCarry(host:Pick<RigViewportHost,'player'>,state:ViewportState){return {threshold:CLICK_SLOP_PX,move:(dx:number,dy:number)=>{const player=host.player(),rigScale=state.rigScale;const impulse=dragImpulse(dx,dy,rigScale);if(impulse&&player)player.moved(impulse);}};}
|
package/web/stage-comments.ts
CHANGED
|
@@ -11,13 +11,22 @@ export interface CommentPose {
|
|
|
11
11
|
turn:unknown;sourceHash:string;modelHash:string|null;referenceHash:string|null;referenceId:string|null;frameReason?:string;
|
|
12
12
|
capture?:ViewportCapture;rig:string;side?:'a'|'b';posed?:PosedFrame;assets?:ModelAssets;media?:HTMLVideoElement|HTMLImageElement;
|
|
13
13
|
}
|
|
14
|
-
interface
|
|
14
|
+
export interface CommentRow {id:string;summary:string;context?:unknown}
|
|
15
|
+
export interface CommentUiPose extends Partial<Omit<CommentPose,'mode'>> {mode:string;camera:ControlNumericCamera}
|
|
16
|
+
export interface CommentUiMark extends Partial<Omit<StageComment,'mode'>> {mode:string;viewport:StageComment['viewport'];screen:MarkRegion;world:MarkRegion;crop:StageComment['crop'];bookmark:unknown}
|
|
17
|
+
/** A codec supplies only source-specific evidence; gesture, composer, pins and pixel capture stay here. */
|
|
18
|
+
export interface CommentCodec<Row extends CommentRow,Pose extends CommentUiPose> {
|
|
19
|
+
read:(row:Row)=>CommentUiMark|null;signature:(pose:Pose)=>unknown;matches:(mark:CommentUiMark,pose:Pose,row:Row)=>boolean;
|
|
20
|
+
label:(row:Row,mark:CommentUiMark)=>string;
|
|
21
|
+
create:(pose:Pose,view:StageComment['viewport'],screen:MarkRegion,crop:StageComment['crop'],bookmark:unknown,summary:string)=>Promise<Row>;
|
|
22
|
+
}
|
|
23
|
+
interface Host<Row extends CommentRow=Feedback,Pose extends CommentUiPose=CommentPose> {
|
|
15
24
|
toolbar:HTMLElement;viewports:Partial<Record<StageComment['viewport'],HTMLElement>>;
|
|
16
|
-
pose:(view:StageComment['viewport'])=>
|
|
25
|
+
pose:(view:StageComment['viewport'])=>Pose|null;pause:()=>Promise<void>;
|
|
17
26
|
bookmark:()=>unknown;restore:(bookmark:unknown,timeOnly?:boolean)=>Promise<void>;
|
|
18
|
-
feedback:()=>
|
|
19
|
-
add:(feedback:
|
|
20
|
-
refusal?:()=>string|null;blocked:()=>boolean;shortcutBlocked?:()=>boolean;
|
|
27
|
+
feedback:()=>Row[];locked:(id:string)=>boolean;
|
|
28
|
+
add:(feedback:Row,side?:'a'|'b')=>void;changed:()=>void;error:(message:string)=>void;
|
|
29
|
+
refusal?:()=>string|null;blocked:()=>boolean;shortcutBlocked?:()=>boolean;codec?:CommentCodec<Row,Pose>;
|
|
21
30
|
}
|
|
22
31
|
const markOf=(f:Feedback):StageComment|null=>{try{const c=f.context as Record<string,unknown>|undefined;return c?.comment?parseStageComment(c.comment):null;}catch{return null;}};
|
|
23
32
|
const copy=<T>(v:T):T=>JSON.parse(JSON.stringify(v));
|
|
@@ -26,7 +35,7 @@ const toEn=(s:string)=>typeof i18nTr==='function'?i18nTr(s,'en'):s;
|
|
|
26
35
|
const onLang=(fn:()=>void)=>typeof i18nOnChange==='function'?i18nOnChange(fn):()=>{};
|
|
27
36
|
const curLang=()=>typeof i18nLang==='function'?i18nLang():'en';
|
|
28
37
|
function rectElement(r:MarkRegion):HTMLDivElement{const node=document.createElement('div');node.className='stage-comment-region';Object.assign(node.style,{left:r.x+'px',top:r.y+'px',width:Math.max(2,r.width)+'px',height:Math.max(2,r.height)+'px'});return node;}
|
|
29
|
-
async function crop(pose:
|
|
38
|
+
async function crop(pose:CommentUiPose,r:MarkRegion):Promise<StageComment['crop']>{
|
|
30
39
|
if(!pose.capture)throw new Error(t('COMMENT_CROP_UNAVAILABLE: viewport pixel source unavailable'));
|
|
31
40
|
const camera=pose.camera,padding=24,rawLeft=Math.max(0,Math.floor(r.x-padding)),rawTop=Math.max(0,Math.floor(r.y-padding)),pane=pose.capture.pane,bounds=pane.getBoundingClientRect(),ratio=globalThis.devicePixelRatio||1;
|
|
32
41
|
const {x:left,y:top,width,height}=pixelAlignedCrop({x:rawLeft,y:rawTop,width:Math.min(camera.viewport.width-rawLeft,Math.ceil(r.width+2*padding)),height:Math.min(camera.viewport.height-rawTop,Math.ceil(r.height+2*padding))},{x:bounds.left+pane.clientLeft,y:bounds.top+pane.clientTop},ratio);
|
|
@@ -50,7 +59,8 @@ async function crop(pose:CommentPose,r:MarkRegion):Promise<StageComment['crop']>
|
|
|
50
59
|
const bytes=Uint8Array.from(atob(png.split(',')[1]!),c=>c.charCodeAt(0)),sha256=[...new Uint8Array(await crypto.subtle.digest('SHA-256',bytes))].map(n=>n.toString(16).padStart(2,'0')).join('');
|
|
51
60
|
return {path:`comment-crops/${sha256}.png`,sha256,png,width:out.width,height:out.height};
|
|
52
61
|
}
|
|
53
|
-
export function bindStageComments(host:Host):{refresh:()=>void;dispose:()=>void;active:()=>boolean;draft:()=>boolean}{
|
|
62
|
+
export function bindStageComments<Row extends CommentRow=Feedback,Pose extends CommentUiPose=CommentPose>(host:Host<Row,Pose>):{refresh:()=>void;dispose:()=>void;active:()=>boolean;draft:()=>boolean}{
|
|
63
|
+
const readMark=(row:Row):CommentUiMark|null=>host.codec?host.codec.read(row):markOf(row as unknown as Feedback);
|
|
54
64
|
const toggle=document.getElementById('stage-comment') as HTMLButtonElement;Object.assign(toggle.style,{whiteSpace:'nowrap',flex:'none'});
|
|
55
65
|
const list=document.createElement('section');list.id='stage-comment-list';list.className='stage-comment-list stage-comment-ui';list.setAttribute('aria-label',t('Stage comments'));list.hidden=true;
|
|
56
66
|
// An absolute overlay is not stage chrome: workspace measures stack children
|
|
@@ -61,12 +71,12 @@ export function bindStageComments(host:Host):{refresh:()=>void;dispose:()=>void;
|
|
|
61
71
|
const refusalNote=document.createElement('small');refusalNote.id='stage-comment-refusal';refusalNote.setAttribute('role','status');refusalNote.hidden=true;Object.assign(refusalNote.style,{position:'absolute',width:'1px',height:'1px',overflow:'hidden',clipPath:'inset(50%)',whiteSpace:'nowrap'});toggle.after(refusalNote);toggle.setAttribute('aria-describedby',refusalNote.id);toggle.setAttribute('aria-controls',list.id);toggle.setAttribute('aria-expanded','false');const originalTitle=toEn(toggle.title);
|
|
62
72
|
const updateRefusal=()=>{const raw=host.refusal?.()??null,reason=raw?t(raw):null,prev=refusalNote.textContent||'',nextTitle=reason??t(originalTitle);toggle.disabled=false;if(toggle.title!==nextTitle)toggle.title=nextTitle;if(refusalNote.title!==(reason??''))refusalNote.title=reason??'';if(refusalNote.textContent!==(reason??''))refusalNote.textContent=reason??'';refusalNote.hidden=!reason;if(!list.hidden&&(reason??'')!==prev)renderList();return reason;};
|
|
63
73
|
const layers=new Map<StageComment['viewport'],HTMLDivElement>();for(const [key,pane]of Object.entries(host.viewports)){const layer=document.createElement('div');layer.className='stage-comment-layer';pane!.append(layer);layers.set(key as StageComment['viewport'],layer);}
|
|
64
|
-
let enabled=false,disposed=false,pending:{view:StageComment['viewport'];start:MarkPoint;end:MarkPoint;mode:
|
|
74
|
+
let enabled=false,disposed=false,pending:{view:StageComment['viewport'];start:MarkPoint;end:MarkPoint;mode:string;id:number;interaction:number;settled:Promise<void>}|null=null,composer:HTMLFormElement|null=null,composerReadOnly=false,syncComposerLang:(()=>void)|null=null,draftMark:{view:StageComment['viewport'];mode:string;screen:MarkRegion}|null=null,busy=false,last='',raf=0,interaction=0;
|
|
65
75
|
const setCapture=(value:boolean)=>{enabled=value;toggle.setAttribute('aria-pressed',String(value||!list.hidden));for(const pane of Object.values(host.viewports))pane!.classList.toggle('stage-comment-mode',value);};
|
|
66
76
|
const cancel=()=>{++interaction;const previous=pending;pending=null;if(previous){const pane=host.viewports[previous.view];if(pane?.hasPointerCapture(previous.id))pane.releasePointerCapture(previous.id);}composer?.remove();composer=null;composerReadOnly=false;syncComposerLang=null;draftMark=null;last='';};
|
|
67
77
|
const assertCapture=()=>{const reason=updateRefusal();if(reason){cancel();setCapture(false);host.error(reason);throw new Error(reason);}if(host.blocked())throw new Error(t('COMMENT_BUSY: wait for inspection'));};
|
|
68
78
|
const assertEdit=()=>{const reason=updateRefusal();if(reason){setCapture(false);host.error(reason);throw new Error(reason);}if(host.blocked())throw new Error(t('COMMENT_BUSY: wait for inspection'));};
|
|
69
|
-
const jump=async(f:
|
|
79
|
+
const jump=async(f:Row):Promise<boolean>=>{const mark=readMark(f);if(!mark)return false;const panes=Object.values(host.viewports).map(p=>({pane:p!,visibility:p!.style.visibility}));try{cancel();for(const {pane}of panes)pane.style.visibility='hidden';await host.restore(mark.bookmark,mark.frame===null);last='';return true;}catch(error){host.error(String(error));return false;}finally{for(const {pane,visibility}of panes)pane.style.visibility=visibility;}};
|
|
70
80
|
const setOpen=(value:boolean)=>{
|
|
71
81
|
if(!value){cancel();list.hidden=true;toggle.setAttribute('aria-expanded','false');setCapture(false);return;}
|
|
72
82
|
if(host.shortcutBlocked?.()){host.error(t('COMMENT_BUSY: close the active editor or wait for the inspection to settle'));return;}
|
|
@@ -76,15 +86,15 @@ export function bindStageComments(host:Host):{refresh:()=>void;dispose:()=>void;
|
|
|
76
86
|
if(reason){setCapture(false);host.error(reason);return;}
|
|
77
87
|
setCapture(true);
|
|
78
88
|
};
|
|
79
|
-
const openComment=async(f:
|
|
80
|
-
const renderList=()=>{placeList();list.setAttribute('aria-label',t('Stage comments'));list.replaceChildren();const title=document.createElement('strong');title.textContent=t('Comments');list.append(title);const rawReason=host.refusal?.()??null,reason=rawReason?t(rawReason):null;if(reason){const note=document.createElement('small');note.className='stage-comment-refusal-note';note.title=reason;note.textContent=reason;Object.assign(note.style,{display:'block',marginTop:'4px',maxWidth:'100%',whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis'});list.append(note);}const all=host.feedback().filter(f=>
|
|
81
|
-
const mark=
|
|
82
|
-
const go=document.createElement('button');go.type='button';go.className='stage-comment-summary';go.textContent
|
|
89
|
+
const openComment=async(f:Row)=>{const mark=readMark(f);if(!mark)return;if(list.hidden)setOpen(true);if(list.hidden)return;if(await jump(f)){const reason=updateRefusal();setCapture(!reason&&!host.blocked());openComposer(mark.viewport,mark.screen,f,host.pose(mark.viewport)?.mode??mark.mode);}};
|
|
90
|
+
const renderList=()=>{placeList();list.setAttribute('aria-label',t('Stage comments'));list.replaceChildren();const title=document.createElement('strong');title.textContent=t('Comments');list.append(title);const rawReason=host.refusal?.()??null,reason=rawReason?t(rawReason):null;if(reason){const note=document.createElement('small');note.className='stage-comment-refusal-note';note.title=reason;note.textContent=reason;Object.assign(note.style,{display:'block',marginTop:'4px',maxWidth:'100%',whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis'});list.append(note);}const all=host.feedback().filter(f=>readMark(f));toggle.textContent=t(`Comment · C (${all.length})`);if(!all.length){const empty=document.createElement('p');empty.textContent=t(reason?'Read only · Escape closes':'Mark a point or region, then type. Enter saves · Escape cancels.');list.append(empty);}for(const [i,f]of all.entries()){
|
|
91
|
+
const mark=readMark(f)!,row=document.createElement('div');row.className='stage-comment-item';row.dataset.commentId=f.id;
|
|
92
|
+
const go=document.createElement('button');go.type='button';go.className='stage-comment-summary';go.textContent=host.codec?`${i+1} · ${host.codec.label(f,mark)}`:`${i+1} · ${mark.mode.toUpperCase()} · ${mark.viewport.toUpperCase()} · ${mark.frame?`F${mark.frame.index} (${mark.frame.basis})`:t(feedbackTimingLabel(f as unknown as Feedback))} · ${f.summary}`;go.onclick=()=>openComment(f);row.append(go);
|
|
83
93
|
if(host.locked(f.id)){const submitted=document.createElement('span');submitted.textContent=t('Submitted');row.append(submitted);}
|
|
84
94
|
list.append(row);
|
|
85
95
|
}};
|
|
86
96
|
const refresh=()=>{last='';renderList();};
|
|
87
|
-
const openComposer=(view:StageComment['viewport'],screen:MarkRegion,existing?:
|
|
97
|
+
const openComposer=(view:StageComment['viewport'],screen:MarkRegion,existing?:Row,placementMode=host.pose(view)?.mode)=>{
|
|
88
98
|
if(!existing){try{assertCapture();}catch{return;}}
|
|
89
99
|
const currentMode=host.pose(view)?.mode;
|
|
90
100
|
if(!placementMode||currentMode&¤tMode!==placementMode){cancel();return;}
|
|
@@ -109,12 +119,12 @@ export function bindStageComments(host:Host):{refresh:()=>void;dispose:()=>void;
|
|
|
109
119
|
form.append(remove);
|
|
110
120
|
}
|
|
111
121
|
// Capture all view context now; camera or dial changes while typing cannot rebind the mark.
|
|
112
|
-
const pose=host.pose(view),bookmark=copy(host.bookmark()),turn=pose?copy(pose.turn)
|
|
122
|
+
const pose=host.pose(view),bookmark=copy(host.bookmark()),turn=pose?.turn===undefined?null:copy(pose.turn);
|
|
113
123
|
if(initialRefusal){errorSource=toEn(host.refusal?.()??initialRefusal);error.textContent=t(errorSource);host.error(t(errorSource));}
|
|
114
|
-
else if(!existing&&pose&&!pose.frame&&!pose.timeBasis){errorSource=toEn(pose.frameReason??'COMMENT_FRAME_UNAVAILABLE: no explicit frame index');error.textContent=t(errorSource);}
|
|
124
|
+
else if(!host.codec&&!existing&&pose&&!pose.frame&&!pose.timeBasis){errorSource=toEn(pose.frameReason??'COMMENT_FRAME_UNAVAILABLE: no explicit frame index');error.textContent=t(errorSource);}
|
|
115
125
|
syncComposerLang=()=>{if(composer!==form)return;form.setAttribute('aria-label',t('Comment composer'));field.setAttribute('aria-label',t('Comment text'));field.placeholder=t('Describe this spot…');hint.textContent=t(composerReadOnly?'Read only · Escape closes':'Enter saves · Escape cancels');if(removeBtn)removeBtn.textContent=t('Delete');if(errorSource)error.textContent=t(errorSource);};
|
|
116
126
|
pane.append(form);place();
|
|
117
|
-
const previous=existing?
|
|
127
|
+
const previous=existing?readMark(existing):null;
|
|
118
128
|
const prepared=previous?Promise.resolve(previous.crop):pose?crop(pose,screen):Promise.reject(new Error('COMMENT_VIEW_UNAVAILABLE'));
|
|
119
129
|
prepared.catch(()=>{});
|
|
120
130
|
form.onkeydown=e=>{if(e.key==='Escape'){e.preventDefault();e.stopPropagation();setOpen(false);pane.focus();}};
|
|
@@ -124,14 +134,17 @@ export function bindStageComments(host:Host):{refresh:()=>void;dispose:()=>void;
|
|
|
124
134
|
busy=true;field.disabled=true;
|
|
125
135
|
existing.summary=summary;
|
|
126
136
|
}else{
|
|
127
|
-
assertCapture();if(!pose||!pose.frame&&!pose.timeBasis)throw new Error(t(pose?.frameReason??'COMMENT_FRAME_UNAVAILABLE: provide an explicit producer clock or a decoded reference frame index'));
|
|
137
|
+
assertCapture();if(!pose||!host.codec&&!pose.frame&&!pose.timeBasis)throw new Error(t(pose?.frameReason??'COMMENT_FRAME_UNAVAILABLE: provide an explicit producer clock or a decoded reference frame index'));
|
|
128
138
|
busy=true;field.disabled=true;
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
139
|
+
if(host.codec){const row=await host.codec.create(pose,view,screen,await prepared,bookmark,summary);assertCapture();if(disposed||generation!==interaction||host.pose(view)?.mode!==placementMode)return;host.add(row);}
|
|
140
|
+
else {const rigPose=pose as unknown as CommentPose;
|
|
141
|
+
const world=region(unprojectMark(screen,rigPose.camera),unprojectMark({x:screen.x+screen.width,y:screen.y+screen.height},rigPose.camera));
|
|
142
|
+
const slots=rigPose.posed?drawnSlots(rigPose.posed,world):[];
|
|
143
|
+
const comment:StageComment={schema:'rig-review-comment/1',mode:placementMode as StageComment['mode'],viewport:view,frame:rigPose.frame,...(rigPose.timeBasis?{timeBasis:rigPose.timeBasis}:{}),time:rigPose.time,animation:rigPose.animation,sourceHash:rigPose.sourceHash,modelHash:rigPose.modelHash,referenceHash:rigPose.referenceHash,referenceId:rigPose.referenceId,camera:copy(rigPose.camera),screen,world,slots,crop:await prepared,bookmark};
|
|
132
144
|
assertCapture();
|
|
133
145
|
if(disposed||generation!==interaction||host.pose(view)?.mode!==placementMode)return;
|
|
134
|
-
const n=
|
|
146
|
+
const n=rigPose.frame?.index??null;host.add({id:crypto.randomUUID(),frameStart:n,frameEnd:n,target:slots[0]?{kind:'slot',name:slots[0].slot}:{kind:'rig',name:rigPose.rig},category:'defect',summary,context:{animation:rigPose.animation,time:rigPose.time,frame:rigPose.frame?.basis==='producer'?n:null,...(turn?{turn:turn as any}:{}),interval:n===null?null:{frameStart:n,frameEnd:n,inclusive:true},comment:comment as any} } as unknown as Row,rigPose.side);
|
|
147
|
+
}
|
|
135
148
|
}
|
|
136
149
|
cancel();host.changed();refresh();
|
|
137
150
|
}catch(e){const msg=e instanceof Error?e.message:String(e);errorSource=toEn(msg);error.textContent=t(errorSource);place();if(locked)host.error(t(errorSource));field.disabled=false;field.focus();}finally{busy=false;}};
|
|
@@ -150,14 +163,14 @@ export function bindStageComments(host:Host):{refresh:()=>void;dispose:()=>void;
|
|
|
150
163
|
const key=(e:KeyboardEvent)=>{if(e.key==='Escape'&&(pending||composer||(enabled||!list.hidden)&&!host.shortcutBlocked?.()&&!textEntryFocused(e.target))){e.preventDefault();setOpen(false);return;}if(e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||textEntryFocused(e.target)||host.shortcutBlocked?.())return;if(e.key.toLowerCase()==='c'){e.preventDefault();setOpen(list.hidden);}};
|
|
151
164
|
window.addEventListener('blur',cancel);window.addEventListener('resize',placeList);document.addEventListener('keydown',key);toggle.onclick=()=>setOpen(list.hidden);
|
|
152
165
|
const ro=typeof ResizeObserver==='function'?new ResizeObserver(()=>{if(!disposed&&!list.hidden)placeList();}):null;if(ro){try{ro.observe(host.toolbar);if(workspace)ro.observe(workspace);}catch{}}
|
|
153
|
-
const renderPins=()=>{if(disposed)return;if(!list.hidden)placeList();const refusal=updateRefusal();if(refusal&&(enabled||pending||composer&&!composerReadOnly)){cancel();setCapture(false);host.error(refusal);}const all=host.feedback().map(f=>({f,mark:
|
|
166
|
+
const renderPins=()=>{if(disposed)return;if(!list.hidden)placeList();const refusal=updateRefusal();if(refusal&&(enabled||pending||composer&&!composerReadOnly)){cancel();setCapture(false);host.error(refusal);}const all=host.feedback().map(f=>({f,mark:readMark(f)})).filter(x=>x.mark);
|
|
154
167
|
// #356: a pose reads the pane's size (a forced layout after the played frame's writes); with no mark, draft or pending
|
|
155
168
|
// capture there is nothing to place, so this per-frame loop skips it.
|
|
156
169
|
const poses=new Map(all.length||draftMark||pending?[...layers.keys()].map(view=>[view,host.pose(view)]):[]);
|
|
157
170
|
if(draftMark&&poses.get(draftMark.view)?.mode!==draftMark.mode||pending&&poses.get(pending.view)?.mode!==pending.mode)cancel();
|
|
158
|
-
const signature=JSON.stringify([curLang(),refusal,all.map(({f,mark})=>[f.id,f.summary,mark!.mode,mark!.world]),[...poses].map(([view,p])=>[view,p?.mode,p?.animation,p?.frame,p?.timeBasis,p?.time,p?.turn,p?.camera,p?.referenceId,p?.referenceHash]),draftMark]);
|
|
171
|
+
const signature=JSON.stringify([curLang(),refusal,all.map(({f,mark})=>[f.id,f.summary,mark!.mode,mark!.world]),[...poses].map(([view,p])=>[view,host.codec&&p?host.codec.signature(p):[p?.mode,p?.animation,p?.frame,p?.timeBasis,p?.time,p?.turn,p?.camera,p?.referenceId,p?.referenceHash]]),draftMark]);
|
|
159
172
|
if(signature!==last){last=signature;for(const layer of layers.values())layer.replaceChildren();for(const [i,{f,mark:m}]of all.entries()){
|
|
160
|
-
const mark=m!,pose=poses.get(mark.viewport),layer=layers.get(mark.viewport);if(refusal||!pose||!layer||pose.mode!==mark.mode||pose.animation!==mark.animation||pose.sourceHash!==mark.sourceHash||pose.modelHash!==mark.modelHash||pose.referenceId!==mark.referenceId||pose.referenceHash!==mark.referenceHash||JSON.stringify(pose.frame)!==JSON.stringify(mark.frame)||JSON.stringify(pose.timeBasis??null)!==JSON.stringify(mark.timeBasis??null)||Math.abs(pose.time-mark.time)>1e-7||JSON.stringify(pose.turn)!==JSON.stringify((f.context as any)?.turn??null))continue;
|
|
173
|
+
const mark=m!,pose=poses.get(mark.viewport),layer=layers.get(mark.viewport);if(refusal||!pose||!layer||(host.codec?!host.codec.matches(mark,pose,f):pose.mode!==mark.mode||pose.animation!==mark.animation||pose.sourceHash!==mark.sourceHash||pose.modelHash!==mark.modelHash||pose.referenceId!==mark.referenceId||pose.referenceHash!==mark.referenceHash||JSON.stringify(pose.frame)!==JSON.stringify(mark.frame)||JSON.stringify(pose.timeBasis??null)!==JSON.stringify(mark.timeBasis??null)||Math.abs((pose.time??0)-(mark.time??0))>1e-7||JSON.stringify(pose.turn)!==JSON.stringify((f.context as any)?.turn??null)))continue;
|
|
161
174
|
const a=projectMark(mark.world,pose.camera),b=projectMark({x:mark.world.x+mark.world.width,y:mark.world.y+mark.world.height},pose.camera),r=region(a,b),box=rectElement(r),pin=document.createElement('button');pin.type='button';pin.className='stage-comment-pin stage-comment-ui';pin.textContent=String(i+1);pin.setAttribute('aria-label',`${t('Comment {0}:').replace('{0}',String(i+1))} ${f.summary}`);pin.title=f.summary;Object.assign(pin.style,{left:r.x+'px',top:r.y+'px'});pin.onclick=()=>openComment(f);layer.append(box,pin);
|
|
162
175
|
}if(draftMark)layers.get(draftMark.view)?.append(rectElement(draftMark.screen));}};
|
|
163
176
|
const paint=()=>{if(disposed)return;renderPins();raf=requestAnimationFrame(paint);};
|
package/web/stage-nav.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Four inspection stages. Existing tools remain mounted; navigation never submits or applies. */
|
|
2
|
+
import {getLanguage,onLanguageChange,t} from './i18n.ts';
|
|
3
|
+
import {pageInstanceAccess} from './instance-access.ts';
|
|
4
|
+
export const reviewStages = ['1 Parts + mesh','2 Interview','3 Rig + animation','4 Direction'] as const;
|
|
5
|
+
export type ReviewStage = 1|2|3|4;
|
|
6
|
+
export function stageReason(stage:ReviewStage,model:boolean):string|null {
|
|
7
|
+
if(stage===2)return 'INTERVIEW_UNAVAILABLE: no interview consumer contract is installed.';
|
|
8
|
+
if(stage===4)return 'DIRECTION_UNAVAILABLE: no direction inspection contract is installed.';
|
|
9
|
+
if(stage===3&&!model)return 'MODEL_UNAVAILABLE: no compiled model is supplied in this inspection.';
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
export function bindStageNav(options:{partsOnly?:boolean;model:boolean;side?:()=> 'a'|'b';setup?:()=>void}):()=>void {
|
|
13
|
+
const host=document.querySelector<HTMLElement>('[data-stage-nav]');if(!host)return ()=>{};
|
|
14
|
+
const embedded=new URL(location.href).searchParams.get('stageEmbed')==='1';
|
|
15
|
+
if(embedded){host.hidden=true;return ()=>{};}
|
|
16
|
+
const access=pageInstanceAccess(),panel=document.createElement('section');panel.className='review-stage-panel';panel.hidden=true;panel.setAttribute('aria-live','polite');document.body.append(panel);
|
|
17
|
+
const status=document.createElement('p');status.setAttribute('role','status');panel.append(status);
|
|
18
|
+
const sourcePicker=document.getElementById('mode-build-picker');
|
|
19
|
+
const frames=new Map<string,HTMLIFrameElement>();let current:ReviewStage=options.partsOnly?1:3;
|
|
20
|
+
const workspace=document.querySelector<HTMLElement>(options.partsOnly?'.pv-layout':'.layout');const wasInert=workspace?.inert??false;
|
|
21
|
+
const buttons=reviewStages.map((label,index)=>{const button=document.createElement('button');button.type='button';button.dataset.reviewStage=String(index+1);button.onclick=()=>show(index+1 as ReviewStage);host.append(button);return button;});
|
|
22
|
+
const mesh=document.createElement('button');mesh.type='button';mesh.onclick=()=>{show(3);options.setup?.();};panel.append(mesh);
|
|
23
|
+
const render=()=>{buttons.forEach((b,i)=>{b.textContent=t(reviewStages[i]!);b.setAttribute('aria-current',current===i+1?'step':'false');});host.setAttribute('aria-label',t('Inspection stages'));if(sourcePicker)sourcePicker.setAttribute('aria-label',t(current===1?'Atlas source build':'Picked build for Setup and Animate'));mesh.textContent=t('Open setup mesh instruments');};
|
|
24
|
+
const place=()=>{panel.style.top=`${(host.closest('header')??host).getBoundingClientRect().bottom}px`;};
|
|
25
|
+
function show(stage:ReviewStage):void {
|
|
26
|
+
current=stage;document.documentElement.dataset.inspectionStage=String(stage);render();place();const reason=stageReason(stage,options.model);
|
|
27
|
+
panel.hidden=stage===(options.partsOnly?1:3)&&!reason;
|
|
28
|
+
if(workspace)workspace.inert=!panel.hidden||wasInert;
|
|
29
|
+
status.textContent=reason?t(reason):stage===1&&!options.partsOnly?t('Atlas inspection, read only — inspected package. Applied scratch atlas, pre-rig parts, mesh sign-off and draft corrections are unavailable here.'):'';mesh.hidden=stage!==1||!options.model||!!options.partsOnly;
|
|
30
|
+
for(const frame of frames.values())frame.hidden=true;
|
|
31
|
+
if(stage===1&&!options.partsOnly){const side=options.side?.(),key=side??'single';let frame=frames.get(key);if(!frame){frame=document.createElement('iframe');frame.title=t('Parts and atlas inspection');frame.src=access.route('/stage-parts.html')+'?stageEmbed=1&lang='+getLanguage()+(side?'&side='+side:'');frame.addEventListener('load',()=>frame!.contentWindow?.postMessage({type:'review-stage-language',language:getLanguage()},location.origin));frames.set(key,frame);panel.append(frame);}frame.hidden=false;}
|
|
32
|
+
}
|
|
33
|
+
// Legacy Setup/Animate/Compare selectors keep their IDs, payloads and behavior.
|
|
34
|
+
const legacy=()=>show(3);document.querySelectorAll('[data-mode],[data-inspector]').forEach(b=>b.addEventListener('click',legacy));
|
|
35
|
+
// A side choice reuses the canonical closed A/B picker, then reveals that side's retained atlas.
|
|
36
|
+
let pickingSource=false;
|
|
37
|
+
const sourceChanged=()=>{if(current!==1)return;pickingSource=true;show(1);queueMicrotask(()=>{pickingSource=false;});};
|
|
38
|
+
sourcePicker?.querySelectorAll('[data-build-side]').forEach(button=>button.addEventListener('click',sourceChanged));
|
|
39
|
+
// Legacy bookmark/control restoration writes these canonical attributes even when a mode is unchanged.
|
|
40
|
+
const canonical=new MutationObserver(()=>{if(current!==3&&!options.partsOnly&&!pickingSource)show(3);});
|
|
41
|
+
document.querySelectorAll('[data-inspector]').forEach(button=>canonical.observe(button,{attributes:true,attributeFilter:['aria-selected','aria-pressed']}));
|
|
42
|
+
const language=onLanguageChange(()=>{render();if(!panel.hidden)status.textContent=t(stageReason(current,options.model)??(current===1?'Atlas inspection, read only — inspected package. Applied scratch atlas, pre-rig parts, mesh sign-off and draft corrections are unavailable here.':''));for(const f of frames.values()){f.title=t('Parts and atlas inspection');f.contentWindow?.postMessage({type:'review-stage-language',language:getLanguage()},location.origin);}});
|
|
43
|
+
window.addEventListener('resize',place);show(current);
|
|
44
|
+
return ()=>{language();canonical.disconnect();sourcePicker?.querySelectorAll('[data-build-side]').forEach(button=>button.removeEventListener('click',sourceChanged));delete document.documentElement.dataset.inspectionStage;if(workspace)workspace.inert=wasInert;panel.remove();window.removeEventListener('resize',place);document.querySelectorAll('[data-mode],[data-inspector]').forEach(b=>b.removeEventListener('click',legacy));};
|
|
45
|
+
}
|