@rig-c/review 1.7.0 → 1.8.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/PARTS_VIEW.md +23 -0
- package/package.json +1 -1
- package/web/catalog-en.ts +7 -0
- package/web/catalog-ko.ts +7 -0
- package/web/parts-render.ts +22 -0
- package/web/parts.css +2 -0
- package/web/parts.html +1 -0
- package/web/parts.ts +58 -10
package/docs/PARTS_VIEW.md
CHANGED
|
@@ -278,3 +278,26 @@ separate stale warning. `PARTS_PAINTING_OUTSIDE` and `PARTS_PAINTING_PNG` refuse
|
|
|
278
278
|
painting inputs. `tests/parts-comments.test.ts` covers these read and cross-encoding boundaries;
|
|
279
279
|
`tests/parts-async-navigation.test.ts` guards reordered painting loads and actionable atlas clicks.
|
|
280
280
|
A downstream create consumer must support verdict/2 before a review release can ship.
|
|
281
|
+
|
|
282
|
+
### Assembled package
|
|
283
|
+
|
|
284
|
+
**Assembled** toggles the existing rig/reference pair from the selected part to the declared
|
|
285
|
+
`rig_size` canvas. Parts draw back to front in package order at their exact fractional rig-pixel
|
|
286
|
+
placements. **Visible** beside each part controls assembly visibility only; the verdict remains
|
|
287
|
+
per part. A tap selects the frontmost visible part with nonzero native source alpha, including
|
|
288
|
+
through transparent holes; drags remain camera gestures. The selected part's alpha edge is a
|
|
289
|
+
separate outline, outside the comparison raster. Background, alpha-only, Fit, 1:1 and the shared
|
|
290
|
+
camera controls remain available. `tests/parts-assembly.test.ts` guards fractional placement,
|
|
291
|
+
order controls, picking, hidden layers, separate outline pixels and per-part verdict invariance.
|
|
292
|
+
|
|
293
|
+
With `--painting`, the reference pane and optional Overlay use the same whole-canvas visual
|
|
294
|
+
mapping described above. No producer resampler, Difference or assembled verdict is added.
|
|
295
|
+
Without painting the reference keeps `PARTS_REFERENCE_UNAVAILABLE`; atlas assembly is disabled
|
|
296
|
+
because atlas regions carry no rig placement, and missing `rig_size` is named separately.
|
|
297
|
+
Comments remain bound to individual original PNGs: switch out of assembly to capture one;
|
|
298
|
+
restoring a saved comment returns to its individual part view. Assembly visibility is temporary
|
|
299
|
+
inspection state and is never saved into a verdict or comment. `tests/parts-assembly-browser.ts`
|
|
300
|
+
checks real EN/KO assembly/reference pixels against an independent browser draw after a
|
|
301
|
+
base-vs-base control, tap/hole/hide selection, pan, camera preservation, background, alpha,
|
|
302
|
+
verdict save and missing-input refusals. Existing `tests/parts-comparison.test.ts` and
|
|
303
|
+
`tests/parts-comments.test.ts` retain the painting-size and protected-input guards.
|
package/package.json
CHANGED
package/web/catalog-en.ts
CHANGED
|
@@ -3138,4 +3138,11 @@ export const enCatalog: Readonly<Record<string, string>> = {
|
|
|
3138
3138
|
"PARTS_COMPARISON_UNAVAILABLE: original painting required": "PARTS_COMPARISON_UNAVAILABLE: original painting required",
|
|
3139
3139
|
"PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required": "PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required",
|
|
3140
3140
|
"PARTS_PAINT_FAILED: view could not be rendered; select the part to retry": "PARTS_PAINT_FAILED: view could not be rendered; select the part to retry",
|
|
3141
|
+
"Assembled": "Assembled",
|
|
3142
|
+
"Visible": "Visible",
|
|
3143
|
+
"Show {name} in assembly": "Show {name} in assembly",
|
|
3144
|
+
"Assembly unavailable: atlas regions carry no rig placement.": "Assembly unavailable: atlas regions carry no rig placement.",
|
|
3145
|
+
"Assembly unavailable: rig_size is not declared.": "Assembly unavailable: rig_size is not declared.",
|
|
3146
|
+
"Assembled package \u00b7 {count} visible parts. Selection and verdict remain per part.": "Assembled package · {count} visible parts. Selection and verdict remain per part.",
|
|
3147
|
+
"PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment": "PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment",
|
|
3141
3148
|
};
|
package/web/catalog-ko.ts
CHANGED
|
@@ -3138,4 +3138,11 @@ export const koCatalog: Readonly<Record<string, string>> = {
|
|
|
3138
3138
|
"PARTS_COMPARISON_UNAVAILABLE: original painting required": "PARTS_COMPARISON_UNAVAILABLE: 원본 원화가 필요해요",
|
|
3139
3139
|
"PARTS_COMPARISON_INVALID: part/overlay mode and opacity 0..1 required": "PARTS_COMPARISON_INVALID: 파트/오버레이 모드와 0..1 불투명도가 필요해요",
|
|
3140
3140
|
"PARTS_PAINT_FAILED: view could not be rendered; select the part to retry": "PARTS_PAINT_FAILED: 화면을 그리지 못했어요. 파츠를 선택해 다시 시도해 주세요",
|
|
3141
|
+
"Assembled": "조립 보기",
|
|
3142
|
+
"Visible": "표시",
|
|
3143
|
+
"Show {name} in assembly": "조립 보기에서 {name} 표시",
|
|
3144
|
+
"Assembly unavailable: atlas regions carry no rig placement.": "조립 불가: 아틀라스 영역에는 리그 배치 정보가 없어요.",
|
|
3145
|
+
"Assembly unavailable: rig_size is not declared.": "조립 불가: rig_size가 선언되지 않았어요.",
|
|
3146
|
+
"Assembled package \u00b7 {count} visible parts. Selection and verdict remain per part.": "조립 패키지 · 파트 {count}개 표시. 선택과 판정은 파트별로 유지돼요.",
|
|
3147
|
+
"PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment": "PARTS_COMMENT_UNAVAILABLE: 댓글을 쓰려면 개별 파트 보기로 전환해 주세요",
|
|
3141
3148
|
};
|
package/web/parts-render.ts
CHANGED
|
@@ -109,3 +109,25 @@ export function paintMesh(ctx: Ctx, source: Source, w: number, h: number, mesh:
|
|
|
109
109
|
ctx.stroke();
|
|
110
110
|
for (let i = 0; i < v.length; i += 2) { ctx.beginPath(); ctx.arc(v[i]!, v[i + 1]!, .8, 0, Math.PI * 2); ctx.fill(); }
|
|
111
111
|
}
|
|
112
|
+
|
|
113
|
+
/** Package order is back to front. Placements remain continuous rig pixels. */
|
|
114
|
+
export function paintAssembly(ctx:Ctx,w:number,h:number,layers:readonly {box:Box;image:Source}[],options:{bg:string;alpha:boolean}):void {
|
|
115
|
+
ctx.imageSmoothingEnabled=false;
|
|
116
|
+
if(!options.alpha)paintBackground(ctx,w,h,options.bg);else ctx.clearRect(0,0,w,h);
|
|
117
|
+
for(const {box,image} of layers)ctx.drawImage(image,box.x,box.y);
|
|
118
|
+
if(options.alpha){const data=ctx.getImageData(0,0,w,h),px=data.data;for(let i=0;i<px.length;i+=4){px[i]=px[i+1]=px[i+2]=px[i+3]!;px[i+3]=255;}ctx.putImageData(data,0,0);}
|
|
119
|
+
}
|
|
120
|
+
/** Native source alpha, independent of the sentinel, overlay opacity and selection decoration. */
|
|
121
|
+
export function pickAssembly<T extends Box>(layers:readonly {box:T;alpha:Uint8ClampedArray}[],x:number,y:number,hidden:ReadonlySet<string>=new Set()):T|null {
|
|
122
|
+
for(let i=layers.length-1;i>=0;i--){const {box,alpha}=layers[i]!;if(hidden.has(box.name))continue;const px=Math.floor(x-box.x),py=Math.floor(y-box.y);if(px>=0&&py>=0&&px<box.w&&py<box.h&&alpha[py*box.w+px]!>0)return box;}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
/** Exposed native-alpha cell edges; decoration is separate from comparison pixels. */
|
|
126
|
+
export function paintAssemblyOutline(ctx:Ctx,box:Box,alpha:Uint8ClampedArray):void {
|
|
127
|
+
const at=(x:number,y:number)=>x>=0&&y>=0&&x<box.w&&y<box.h&&alpha[y*box.w+x]!>0;
|
|
128
|
+
ctx.strokeStyle='#00bfff';ctx.lineWidth=1;ctx.beginPath();
|
|
129
|
+
for(let y=0;y<box.h;y++)for(let x=0;x<box.w;x++)if(at(x,y)){
|
|
130
|
+
const edge=(ax:number,ay:number,bx:number,by:number)=>{ctx.moveTo(box.x+ax,box.y+ay);ctx.lineTo(box.x+bx,box.y+by);};
|
|
131
|
+
if(!at(x,y-1))edge(x,y,x+1,y);if(!at(x,y+1))edge(x,y+1,x+1,y+1);if(!at(x-1,y))edge(x,y,x,y+1);if(!at(x+1,y))edge(x+1,y,x+1,y+1);
|
|
132
|
+
}ctx.stroke();
|
|
133
|
+
}
|
package/web/parts.css
CHANGED
|
@@ -90,3 +90,5 @@ main{position:relative}.toolbar{anchor-name:--stage-comment-bar}#stage-comment{w
|
|
|
90
90
|
#pv-reference{image-rendering:pixelated;image-rendering:crisp-edges;display:block}
|
|
91
91
|
|
|
92
92
|
.pv-comparison{display:flex;flex-wrap:wrap;align-items:center;gap:12px}#pv-opacity{width:100px}
|
|
93
|
+
|
|
94
|
+
.pv-overlay canvas{position:absolute;left:0;top:0;pointer-events:none}
|
package/web/parts.html
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
<aside class="pv-list" aria-label="Parts"><h2 id="pv-list-title">PARTS</h2><ul id="pv-items" data-pv-items></ul></aside>
|
|
9
9
|
<main class="pv-stage">
|
|
10
10
|
<div class="pv-toolbar" role="toolbar" aria-label="View">
|
|
11
|
+
<button type="button" id="pv-assemble" aria-pressed="false">Assembled</button>
|
|
11
12
|
<label class="pv-field">Background <select id="pv-bg" data-pv-bg><option value="green">Green</option><option value="magenta">Magenta</option><option value="black">Black</option><option value="white">White</option><option value="checker">Checker</option></select></label>
|
|
12
13
|
<span class="pv-group" role="group" aria-label="Zoom"><button type="button" id="zoom-out">−</button><span id="zoom-value">1:1</span><button type="button" id="zoom-in">+</button><button type="button" id="fit">Fit</button><button type="button" id="native-one" aria-pressed="true">1:1</button></span>
|
|
13
14
|
<label class="pv-field"><input id="camera-sync" type="checkbox">Sync cameras</label>
|
package/web/parts.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { bindDomI18n, onLanguageChange, setLinkLanguage, setLanguagePreference,
|
|
|
18
18
|
import { pageInstanceAccess } from './instance-access.ts';
|
|
19
19
|
import { connectLiveWindow } from './live-connection.ts';
|
|
20
20
|
import { flagLabel } from './parts-flags.ts';
|
|
21
|
-
import { frontParts, paintAlphaOnly, paintBackground, paintPart, paintMesh, paintOverlay, paintPaintingCrop, paintFootprints } from './parts-render.ts';
|
|
21
|
+
import { paintAssembly, pickAssembly, paintAssemblyOutline, frontParts, paintAlphaOnly, paintBackground, paintPart, paintMesh, paintOverlay, paintPaintingCrop, paintFootprints } from './parts-render.ts';
|
|
22
22
|
|
|
23
23
|
type Outcome = 'pending' | 'clean' | 'flagged';
|
|
24
24
|
interface Mesh { vertices: number[]; triangles: number[]; figures: Record<string, unknown> }
|
|
@@ -43,7 +43,7 @@ const stageEmbedded=new URL(location.href).searchParams.get('stageEmbed')==='1';
|
|
|
43
43
|
const stageSide=new URL(location.href).searchParams.get('side');
|
|
44
44
|
const partsApi=stageEmbedded?(stageSide==='a'||stageSide==='b'?`/api/compare/${stageSide}/stage-parts`:'/api/stage-parts'):'/api/parts';
|
|
45
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>() };
|
|
46
|
+
const state = { data: null as ViewData | null, selected: 0, zoom: 1, bg: 'green', alpha: false, footprints: false, comparison:defaultPartsComparison(), hidden: new Set<string>(), view: 'item' as 'item' | 'page' | 'assembled', page: 0, meshShown: new Set<string>(), verdict: new Map<string, Entry>() };
|
|
47
47
|
const comments:PartsComment[]=[];let commentUi:ReturnType<typeof bindStageComments>|null=null;let viewport:ReturnType<typeof createPartsViewport>|null=null;let painting=false;
|
|
48
48
|
const images = new Map<string, HTMLImageElement>();
|
|
49
49
|
|
|
@@ -91,11 +91,34 @@ async function paint():Promise<void>{
|
|
|
91
91
|
$('pv-caption').textContent=t(paintFailure);$('pv-save-status').textContent=t(paintFailure);commentUi?.refresh();
|
|
92
92
|
}finally{if(token===paintToken)painting=false;}
|
|
93
93
|
}
|
|
94
|
+
const assemblyAlpha=new Map<string,Uint8ClampedArray>();
|
|
95
|
+
function sourceAlpha(item:Item,img:HTMLImageElement):Uint8ClampedArray {
|
|
96
|
+
const cached=assemblyAlpha.get(item.name);if(cached)return cached;
|
|
97
|
+
const c=document.createElement('canvas');c.width=item.w;c.height=item.h;const ctx=c.getContext('2d')!;ctx.drawImage(img,0,0);
|
|
98
|
+
const rgba=ctx.getImageData(0,0,item.w,item.h).data,alpha=new Uint8ClampedArray(item.w*item.h);for(let i=0;i<alpha.length;i++)alpha[i]=rgba[i*4+3]!;assemblyAlpha.set(item.name,alpha);return alpha;
|
|
99
|
+
}
|
|
100
|
+
|
|
94
101
|
async function paintRaster(token:number): Promise<void> {
|
|
95
102
|
const data = state.data;
|
|
96
103
|
if (!data || !data.items.length) return;
|
|
97
104
|
const canvas = $<HTMLCanvasElement>('pv-canvas'), overlay = $('pv-overlay'), caption = $('pv-caption');
|
|
98
105
|
const item = data.items[state.selected]!;
|
|
106
|
+
if(state.view==='assembled'&&data.mode==='parts'&&data.rigSize){
|
|
107
|
+
const [w,h]=data.rigSize,shown=data.items.filter(i=>!state.hidden.has(i.name));
|
|
108
|
+
const layers=await Promise.all(shown.map(async box=>({box,image:await itemImage(box)})));
|
|
109
|
+
const original=state.comparison.mode==='overlay'&&data.painting?await load('/api/parts/painting'):null;
|
|
110
|
+
if(token!==paintToken)return;
|
|
111
|
+
const ctx=setCanvas(canvas,w,h);
|
|
112
|
+
if(original){
|
|
113
|
+
paintPaintingCrop(ctx,original,paintingRectangle({x:0,y:0,w,h},data.rigSize,data.painting!),w,h,state.bg);
|
|
114
|
+
const assembled=document.createElement('canvas');assembled.width=w;assembled.height=h;const a=assembled.getContext('2d')!;a.imageSmoothingEnabled=false;for(const l of layers)a.drawImage(l.image,l.box.x,l.box.y);ctx.globalAlpha=state.comparison.opacity;ctx.drawImage(assembled,0,0);ctx.globalAlpha=1;
|
|
115
|
+
}else paintAssembly(ctx,w,h,layers,{bg:state.bg,alpha:state.alpha});
|
|
116
|
+
overlay.replaceChildren();
|
|
117
|
+
const selected=layers.find(l=>l.box.name===item.name);
|
|
118
|
+
if(selected){const outline=document.createElement('canvas');outline.width=w;outline.height=h;outline.dataset.assemblyOutline=item.name;paintAssemblyOutline(outline.getContext('2d')!,item,sourceAlpha(item,selected.image));overlay.append(outline);}
|
|
119
|
+
caption.textContent=t('Assembled package · {count} visible parts. Selection and verdict remain per part.',{count:shown.length});
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
99
122
|
if (data.mode === 'atlas' && state.view === 'page') {
|
|
100
123
|
const page = data.pages[state.page]!, img = await pageImage(page.name);
|
|
101
124
|
if (token !== paintToken) return;
|
|
@@ -150,14 +173,15 @@ async function paintRaster(token:number): Promise<void> {
|
|
|
150
173
|
+ (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.')) : '');
|
|
151
174
|
}
|
|
152
175
|
|
|
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=
|
|
176
|
+
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 box=state.view==='assembled'?{x:0,y:0,w:data.rigSize![0],h:data.rigSize![1]}:item;const canvas=$<HTMLCanvasElement>('pv-reference');canvas.width=box.w;canvas.height=box.h;const ctx=canvas.getContext('2d')!;paintPaintingCrop(ctx,img,paintingRectangle(box,data.rigSize!,data.painting),box.w,box.h,state.bg);}
|
|
154
177
|
|
|
155
178
|
function renderComparison():void {
|
|
156
179
|
const active=state.data?.mode==='parts'&&!!state.data.painting,overlay=active&&state.comparison.mode==='overlay';
|
|
157
180
|
$('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
181
|
$('pv-opacity-control').hidden=!overlay;$<HTMLInputElement>('pv-opacity').value=String(state.comparison.opacity);$('pv-opacity-value').textContent=(state.comparison.opacity*100).toFixed(1)+'%';
|
|
159
182
|
$<HTMLInputElement>('pv-alpha').disabled=overlay;
|
|
160
|
-
const mesh=document.querySelector<HTMLInputElement>('#pv-mesh-control input');if(mesh)mesh.disabled=overlay;
|
|
183
|
+
const mesh=document.querySelector<HTMLInputElement>('#pv-mesh-control input');if(mesh)mesh.disabled=overlay||state.view==='assembled';
|
|
184
|
+
$<HTMLInputElement>('pv-footprints').disabled=state.data?.mode==='atlas'||state.view==='assembled';
|
|
161
185
|
}
|
|
162
186
|
|
|
163
187
|
function renderFlags(): void {
|
|
@@ -231,6 +255,10 @@ function renderList(): void {
|
|
|
231
255
|
button.append(name, flags, badge);
|
|
232
256
|
button.onclick = () => { select(item.index); if (data.mode === 'atlas') setView('item'); };
|
|
233
257
|
li.append(button);
|
|
258
|
+
if(data.mode==='parts'){
|
|
259
|
+
const label=document.createElement('label'),visible=document.createElement('input');visible.type='checkbox';visible.checked=!state.hidden.has(item.name);visible.dataset.pvVisible=item.name;visible.setAttribute('aria-label',t('Show {name} in assembly',{name:item.name}));
|
|
260
|
+
visible.onchange=()=>{if(visible.checked)state.hidden.delete(item.name);else state.hidden.add(item.name);void paint();};label.append(visible,t('Visible'));li.append(label);
|
|
261
|
+
}
|
|
234
262
|
return li;
|
|
235
263
|
}));
|
|
236
264
|
}
|
|
@@ -250,7 +278,7 @@ function renderMesh(): void {
|
|
|
250
278
|
const item = state.data!.items[state.selected]!;
|
|
251
279
|
if (!item.mesh) return;
|
|
252
280
|
const control = document.createElement('label'); control.id = 'pv-mesh-control'; control.className = 'pv-field';
|
|
253
|
-
const toggle = document.createElement('input'); toggle.type = 'checkbox'; toggle.checked = state.meshShown.has(item.name); toggle.disabled=state.comparison.mode==='overlay';
|
|
281
|
+
const toggle = document.createElement('input'); toggle.type = 'checkbox'; toggle.checked = state.meshShown.has(item.name); toggle.disabled=state.comparison.mode==='overlay'||state.view==='assembled';
|
|
254
282
|
toggle.onchange = () => { if (toggle.checked) state.meshShown.add(item.name); else state.meshShown.delete(item.name); void paint(); };
|
|
255
283
|
control.append(toggle, t('mesh from rig.json UVs')); document.querySelector('.pv-toolbar')!.append(control);
|
|
256
284
|
const panel = document.createElement('section'); panel.id = 'pv-mesh-panel';
|
|
@@ -277,15 +305,17 @@ function renderMesh(): void {
|
|
|
277
305
|
|
|
278
306
|
function select(index: number): void {
|
|
279
307
|
const data = state.data!;
|
|
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});}
|
|
308
|
+
const changed=state.selected!==index;state.selected = index;if(changed&&viewport&&state.view!=='assembled'){viewport.writeCamera('rig',{zoom:1,center:null});viewport.writeCamera('reference',{zoom:1,center:null});}
|
|
281
309
|
commentUi?.refresh();
|
|
282
310
|
const item = data.items[index]!;
|
|
283
311
|
if (item.page !== undefined) state.page = data.pages.findIndex(p => p.name === item.page);
|
|
284
312
|
renderList(); renderFlags(); renderVerdict(); renderMesh(); renderComparison(); void paint();
|
|
285
313
|
}
|
|
286
314
|
|
|
287
|
-
function setView(view: 'item' | 'page'): void {
|
|
288
|
-
state.
|
|
315
|
+
function setView(view: 'item' | 'page' | 'assembled'): void {
|
|
316
|
+
if(view==='assembled'&&(state.data?.mode!=='parts'||!state.data.rigSize))return;
|
|
317
|
+
if(state.view!==view&&viewport){viewport.writeCamera('rig',{zoom:1,center:null});viewport.writeCamera('reference',{zoom:1,center:null});}
|
|
318
|
+
state.view = view;renderMesh();renderComparison();$('rig-label').textContent=t(view==='assembled'?'Assembled':'Selected part');commentUi?.refresh();
|
|
289
319
|
for (const b of document.querySelectorAll<HTMLButtonElement>('[data-pv-view]')) b.setAttribute('aria-pressed', String(b.dataset.pvView === view));
|
|
290
320
|
void paint();
|
|
291
321
|
}
|
|
@@ -335,6 +365,9 @@ async function boot(): Promise<void> {
|
|
|
335
365
|
$('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
366
|
if(stageEmbedded){$('pv-load').hidden=$('pv-load').textContent==='';document.querySelector<HTMLElement>('.pv-layout')!.hidden=false;}
|
|
337
367
|
$('pv-atlas-switch').hidden = data.mode !== 'atlas';
|
|
368
|
+
const assemble=$<HTMLButtonElement>('pv-assemble');assemble.disabled=data.mode!=='parts'||!data.rigSize;assemble.title=assemble.disabled?t(data.mode==='atlas'?'Assembly unavailable: atlas regions carry no rig placement.':'Assembly unavailable: rig_size is not declared.'):'';
|
|
369
|
+
assemble.onclick=()=>{setView(state.view==='assembled'?'item':'assembled');assemble.setAttribute('aria-pressed',String(state.view==='assembled'));};
|
|
370
|
+
bindAssemblyPicking();
|
|
338
371
|
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
372
|
$<HTMLInputElement>('pv-opacity').oninput=e=>{state.comparison.opacity=Number((e.target as HTMLInputElement).value);renderComparison();void paint();};
|
|
340
373
|
const footprints = $<HTMLInputElement>('pv-footprints');
|
|
@@ -353,6 +386,21 @@ async function boot(): Promise<void> {
|
|
|
353
386
|
document.body.dataset.ready = 'true';
|
|
354
387
|
}
|
|
355
388
|
|
|
389
|
+
/** Observe taps only; the shared controller exclusively owns pan, zoom and pinch. */
|
|
390
|
+
function bindAssemblyPicking():void {
|
|
391
|
+
const pane=$('rig-viewport');let tap:{id:number;x:number;y:number}|null=null;const pointers=new Set<number>();
|
|
392
|
+
pane.addEventListener('pointerdown',e=>{pointers.add(e.pointerId);if(pointers.size===1&&e.button===0)tap={id:e.pointerId,x:e.clientX,y:e.clientY};else tap=null;});
|
|
393
|
+
pane.addEventListener('pointermove',e=>{if(tap&&Math.hypot(e.clientX-tap.x,e.clientY-tap.y)>4)tap=null;});
|
|
394
|
+
pane.addEventListener('pointercancel',e=>{pointers.delete(e.pointerId);tap=null;});
|
|
395
|
+
pane.addEventListener('pointerup',e=>{
|
|
396
|
+
pointers.delete(e.pointerId);const start=tap;tap=null;
|
|
397
|
+
if(!start||start.id!==e.pointerId||Math.hypot(e.clientX-start.x,e.clientY-start.y)>4||state.view!=='assembled'||painting||paintFailure||commentUi?.active())return;
|
|
398
|
+
const data=state.data!,r=$('pv-canvas').getBoundingClientRect(),zoom=viewport!.paneCamera('rig').zoom;
|
|
399
|
+
const layers=data.items.flatMap(box=>{const img=images.get(`${partsApi}/image/${box.index}`);return img?[{box,alpha:sourceAlpha(box,img)}]:[];});
|
|
400
|
+
const hit=pickAssembly(layers,(e.clientX-r.left)/zoom,(e.clientY-r.top)/zoom,state.hidden);if(hit)select(hit.index);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
356
404
|
interface PartsPose extends CommentUiPose {item:Item;sourceHash:string;view:PartsComment['view']}
|
|
357
405
|
function setupPartsComments():void {
|
|
358
406
|
const codec:CommentCodec<PartsComment,PartsPose>={
|
|
@@ -364,8 +412,8 @@ function setupPartsComments():void {
|
|
|
364
412
|
};
|
|
365
413
|
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
414
|
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});
|
|
415
|
+
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');setView('item');$('pv-assemble').setAttribute('aria-pressed','false');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;}},
|
|
416
|
+
feedback:()=>comments,locked:()=>false,add:c=>comments.push(c),changed:()=>renderVerdict(),error:m=>{$('pv-save-status').textContent=t(m);},blocked:()=>painting,refusal:()=>paintFailure??(state.view==='assembled'?'PARTS_COMMENT_UNAVAILABLE: select the individual part view to comment':null)??(state.data?.mode!=='parts'||stageEmbedded?'PARTS_COMMENT_UNAVAILABLE: original part image required':null),codec});
|
|
369
417
|
}
|
|
370
418
|
|
|
371
419
|
if (typeof document !== 'undefined' && document.getElementById('parts-app')) void boot();
|