rig-review 1.1.1 → 1.2.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.
@@ -19,8 +19,21 @@ export const CHEST_REGIONS_CLAMPED='CHEST_REGIONS_CLAMPED';
19
19
  const sideRow=(side:BustSide)=>side==='r'?0:1;
20
20
  const sideTag=(side:BustSide)=>side==='r'?'R':'L';
21
21
 
22
- /** The toggle belongs to Setup only. */
23
- export function chestEditVisible(inspector:string|undefined):boolean {return inspector==='rig';}
22
+ /** The toggle is available in both Setup and Animate so the overlay can be inspected and adjusted on the posed rig (#307). */
23
+ export function chestEditVisible(inspector:string|undefined):boolean {return inspector==='rig'||inspector==='playback';}
24
+
25
+ export interface BoneWorldReader {bone:(name:string)=>{x:number;y:number}|null|undefined}
26
+ /** World-space delta of the posed `chest` bone from its setup-pose world position, matching Family's poseDx/poseDy. */
27
+ export function chestPoseOffset(player:BoneWorldReader|null|undefined,setupChest:{x:number;y:number}|null|undefined):{x:number;y:number} {
28
+ if(!player||!setupChest)return {x:0,y:0};
29
+ try{const b=player.bone('chest');if(b&&Number.isFinite(b.x)&&Number.isFinite(b.y))return {x:b.x-setupChest.x,y:b.y-setupChest.y};}catch{/* rig lacks a chest bone */}
30
+ return {x:0,y:0};
31
+ }
32
+ /** Shifts a crop → world mapping by the posed chest bone's world offset so overlays and hit-testing follow the chest bone. */
33
+ export function posedChestMapping<T extends CropWorldMapping>(mapping:T,offset:{x:number;y:number}):T {
34
+ if(!mapping.available||(!offset.x&&!offset.y))return mapping;
35
+ return {...mapping,toWorld:(x:number,y:number)=>{const w=mapping.toWorld(x,y);return {x:w.x+offset.x,y:w.y+offset.y};}};
36
+ }
24
37
 
25
38
  const number=(read:ChestFieldReader,id:string)=>{const raw=(read(id)?.value??'').trim();if(!raw)return null;const value=Number(raw);return Number.isFinite(value)?value:null;};
26
39
  /** A row is a circle when its semi-axes are equal and it has no medial clip; then r is that semi-axis. */
@@ -29,36 +42,77 @@ export function rowCircle(read:ChestFieldReader,row:number):ChestCircle|null {
29
42
  if(cx===null||cy===null||ax===null||band===null||ax<=0||ay!==ax||(read(chestRowId(row,'clip'))?.value??'').trim())return null;
30
43
  return {cx,cy,r:ax,band};
31
44
  }
32
- /** Field values that store a circle in a detail row: r writes both semi-axes. */
33
- export function circleFields(row:number,circle:Partial<ChestCircle>):Record<string,string> {
45
+ /**
46
+ * #315: a row the handles edit — a circle, or an axis-aligned ellipse (`r` = ax, `ry` = ay) with an optional medial clip.
47
+ * The rule for an ellipse: the r handle sets ax and scales ay and the clip's offset from the centre by the same factor
48
+ * (the shape keeps its aspect); the band handle sets band from the core's top (ay); a move shifts the centre and the clip.
49
+ */
50
+ export interface BustShape extends ChestCircle {ry?:number;clip?:number}
51
+ export function rowShape(read:ChestFieldReader,row:number):BustShape|null {
52
+ const circle=rowCircle(read,row);if(circle)return circle;
53
+ const cx=number(read,chestRowId(row,'cx')),cy=number(read,chestRowId(row,'cy')),ax=number(read,chestRowId(row,'ax')),ay=number(read,chestRowId(row,'ay')),band=number(read,chestRowId(row,'band'));
54
+ const clipText=(read(chestRowId(row,'clip'))?.value??'').trim(),clip=clipText?number(read,chestRowId(row,'clip')):undefined;
55
+ if(cx===null||cy===null||ax===null||ay===null||band===null||ax<=0||ay<=0||clip===null)return null;
56
+ return {cx,cy,r:ax,ry:ay,band,...(clip===undefined?{}:{clip})};
57
+ }
58
+ const grid=(value:number)=>Math.round(value*256)/256;
59
+ /** The ellipse rule's resize: r → ax, and ay and the clip offset scale with it; a circle just takes r. */
60
+ export function resizeBust(from:BustShape,r:number):BustShape {
61
+ if(from.ry===undefined&&from.clip===undefined)return {...from,r};
62
+ const k=from.r>0?r/from.r:1;
63
+ return {...from,r,...(from.ry===undefined?{}:{ry:grid(from.ry*k)}),...(from.clip===undefined?{}:{clip:grid(from.cx+(from.clip-from.cx)*k)})};
64
+ }
65
+ /** Field values that store a shape in a detail row: a circle's r writes both semi-axes; an ellipse's ry writes ay. */
66
+ export function circleFields(row:number,circle:Partial<BustShape>):Record<string,string> {
34
67
  const out:Record<string,string>={};
35
68
  if(circle.cx!==undefined)out[chestRowId(row,'cx')]=String(circle.cx);
36
69
  if(circle.cy!==undefined)out[chestRowId(row,'cy')]=String(circle.cy);
37
- if(circle.r!==undefined){out[chestRowId(row,'ax')]=String(circle.r);out[chestRowId(row,'ay')]=String(circle.r);}
70
+ if(circle.r!==undefined){out[chestRowId(row,'ax')]=String(circle.r);out[chestRowId(row,'ay')]=String(circle.ry??circle.r);}
38
71
  if(circle.band!==undefined)out[chestRowId(row,'band')]=String(circle.band);
72
+ if(circle.clip!==undefined)out[chestRowId(row,'clip')]=String(circle.clip);
39
73
  return out;
40
74
  }
41
- export const bustLabel=(side:BustSide,c:ChestCircle)=>`${sideTag(side)} (${Math.round(c.cx)},${Math.round(c.cy)}) r:${Math.round(c.r)} b:${Math.round(c.band)}`;
75
+ export const bustLabel=(side:BustSide,c:BustShape)=>c.ry===undefined?`${sideTag(side)} (${Math.round(c.cx)},${Math.round(c.cy)}) r:${Math.round(c.r)} b:${Math.round(c.band)}`:`${sideTag(side)} (${Math.round(c.cx)},${Math.round(c.cy)}) r:${Math.round(c.r)}×${Math.round(c.ry)} b:${Math.round(c.band)}`;
42
76
 
43
- export interface ProjectedBust {side:BustSide;center:OverlayPoint;pxR:number;pxBand:number}
44
- /** The example's hit order: core handle or core edge → r, band handle or outer edge → band, inside the core → move. */
77
+ export interface ProjectedBust {side:BustSide;center:OverlayPoint;pxR:number;pxBand:number;/** #315: an ellipse's vertical semi-axis in canvas px. */pxRy?:number}
78
+ /** Canvas distance from the centre to the core's edge toward p: pxR for a circle, the ellipse's radius along p for an ellipse. */
79
+ const edgeAlong=(c:ProjectedBust,dx:number,dy:number)=>{if(c.pxRy===undefined)return c.pxR;const d=Math.hypot(dx,dy);if(!d)return Math.min(c.pxR,c.pxRy);return c.pxR*c.pxRy/Math.hypot(c.pxRy*dx/d,c.pxR*dy/d);};
80
+ /** The example's hit order: core handle or core edge → r, band handles or outer edge → band, anywhere inside the outer band disc → move (#307). */
45
81
  export function hitBustHandle(circles:readonly ProjectedBust[],p:OverlayPoint):{side:BustSide;mode:BustMode}|null {
46
82
  for(const c of circles){
47
- const toR=Math.hypot(p.x-(c.center.x+c.pxR),p.y-c.center.y),toBand=Math.hypot(p.x-c.center.x,p.y-(c.center.y-c.pxBand)),toCenter=Math.hypot(p.x-c.center.x,p.y-c.center.y);
48
- if(toR<=10||Math.abs(toCenter-c.pxR)<=6)return {side:c.side,mode:'r'};
49
- if(toBand<=10||Math.abs(toCenter-c.pxBand)<=6)return {side:c.side,mode:'band'};
50
- if(toCenter<=Math.max(12,c.pxR))return {side:c.side,mode:'move'};
83
+ const toR=Math.hypot(p.x-(c.center.x+c.pxR),p.y-c.center.y),toBand=Math.min(Math.hypot(p.x-c.center.x,p.y-(c.center.y-c.pxBand)),Math.hypot(p.x-c.center.x,p.y-(c.center.y+c.pxBand))),toCenter=Math.hypot(p.x-c.center.x,p.y-c.center.y);
84
+ const core=edgeAlong(c,p.x-c.center.x,p.y-c.center.y),outer=core+(c.pxBand-(c.pxRy??c.pxR));
85
+ if(toR<=10||Math.abs(toCenter-core)<=6)return {side:c.side,mode:'r'};
86
+ if(toBand<=10||Math.abs(toCenter-outer)<=6)return {side:c.side,mode:'band'};
87
+ }
88
+ let best:{side:BustSide;dist:number}|null=null;
89
+ for(const c of circles){
90
+ const toCenter=Math.hypot(p.x-c.center.x,p.y-c.center.y);
91
+ const outer=edgeAlong(c,p.x-c.center.x,p.y-c.center.y)+(c.pxBand-(c.pxRy??c.pxR));
92
+ if(toCenter<=Math.max(12,outer)&&(!best||toCenter<best.dist))best={side:c.side,dist:toCenter};
51
93
  }
52
- return null;
94
+ return best?{side:best.side,mode:'move'}:null;
53
95
  }
54
96
  const limit=(value:number,[low,high]:readonly [number,number])=>Math.max(low,Math.min(high,value));
55
- export interface BustDrag {side:BustSide;mode:BustMode;start:OverlayPoint;centre:OverlayPoint;from:ChestCircle}
56
- /** Pointer (canvas px) → source px through the camera scale (canvas px per source px), rounded as the example does. */
57
- export function dragBust(drag:BustDrag,p:OverlayPoint,scale:number):ChestCircle {
97
+ export interface BustDrag {side:BustSide;mode:BustMode;start:OverlayPoint;centre:OverlayPoint;from:BustShape}
98
+ /** Pointer (canvas px) → source px through the camera scale (canvas px per source px), rounded as the example does; an ellipse follows the BustShape rule. */
99
+ export function dragBust(drag:BustDrag,p:OverlayPoint,scale:number):BustShape {
58
100
  const from=drag.from;if(!(scale>0)||!Number.isFinite(scale))return {...from};
59
- if(drag.mode==='move')return {...from,cx:Math.round(from.cx+(p.x-drag.start.x)/scale),cy:Math.round(from.cy+(p.y-drag.start.y)/scale)};
101
+ if(drag.mode==='move'){const cx=Math.round(from.cx+(p.x-drag.start.x)/scale),cy=Math.round(from.cy+(p.y-drag.start.y)/scale);return {...from,cx,cy,...(from.clip===undefined?{}:{clip:grid(from.clip+cx-from.cx)})};}
60
102
  const distance=Math.hypot(p.x-drag.centre.x,p.y-drag.centre.y)/scale;
61
- if(drag.mode==='r')return {...from,r:limit(Math.round(distance),CHEST_CIRCLE_LIMITS.r)};
103
+ if(from.ry!==undefined){
104
+ // #316: an ellipse is measured along the grab ray. The core's radius there (r_dir) is what the pointer holds, so a grab
105
+ // changes nothing until it moves, and +d along the ray scales the core by (r_dir + d) / r_dir or grows the band by d.
106
+ const gx=drag.start.x-drag.centre.x,gy=drag.start.y-drag.centre.y,grabbed=Math.hypot(gx,gy)/scale;
107
+ const [ux,uy]=grabbed>0?[gx,gy]:[p.x-drag.centre.x,p.y-drag.centre.y],u=Math.hypot(ux,uy);
108
+ const rDir=u>0?from.r*from.ry/Math.hypot(from.ry*ux/u,from.r*uy/u):from.r;
109
+ // A grab at the centre (no ray) reads the pointer as on the edge, or on the band ring, along its own ray.
110
+ const held=grabbed>0?grabbed:drag.mode==='r'?rDir:rDir+from.band,d=distance-held;
111
+ if(d===0)return {...from};
112
+ if(drag.mode==='r')return resizeBust(from,limit(Math.round(from.r*(rDir+d)/rDir),CHEST_CIRCLE_LIMITS.r));
113
+ return {...from,band:limit(Math.round(from.band+d),CHEST_CIRCLE_LIMITS.band)};
114
+ }
115
+ if(drag.mode==='r')return resizeBust(from,limit(Math.round(distance),CHEST_CIRCLE_LIMITS.r));
62
116
  return {...from,band:limit(Math.round(distance-from.r),CHEST_CIRCLE_LIMITS.band)};
63
117
  }
64
118
  /** Mirror: L takes R's y, core radius and band; L keeps its own x. */
@@ -79,7 +133,7 @@ export function editorStatus(notice:{text:string;error:boolean}|null,mapping:Cro
79
133
 
80
134
  /** Circles (#92/#99: the R / L rows) or Landmarks (#105: `contour.bust`). The mode lives in a hidden input, so the draft keeps it. */
81
135
  export type ChestMode='circles'|'landmarks';
82
- export const LANDMARKS=[{key:'apex_r',tag:'Apex R'},{key:'apex_l',tag:'Apex L'},{key:'cleavage',tag:'Cleavage'}] as const;
136
+ export const LANDMARKS=[{key:'apex_r',tag:"Right apex (character's right, image left)"},{key:'apex_l',tag:"Left apex (character's left, image right)"},{key:'cleavage',tag:'Cleavage'}] as const;
83
137
  export type LandmarkKey=typeof LANDMARKS[number]['key'];
84
138
  export const landmarkInputId=(key:LandmarkKey,axis:'x'|'y')=>`lm-${key}-${axis}`;
85
139
  /** Slider ranges; the producer's defaults sit inside them. */
@@ -185,23 +239,19 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
185
239
  return LANDMARKS.flatMap(({key})=>{const x=Number((read(landmarkInputId(key,'x'))?.value??'').trim()||NaN),y=Number((read(landmarkInputId(key,'y'))?.value??'').trim()||NaN);if(!Number.isFinite(x)||!Number.isFinite(y))return [];const w=mapping.toWorld(x,y);return [{key,at:project(w.x,w.y)}];});
186
240
  };
187
241
  const cropAt=(p:OverlayPoint):RigPoint|null=>{const project=host.project(),mapping=host.mapping();return project&&mapping.available?canvasToCrop(project,mapping.toWorld,p):null;};
188
- let active=false,space=false,drag:(BustDrag&{pointer:number;other:ChestCircle|null})|null=null,flashTimer:ReturnType<typeof setTimeout>|null=null;
242
+ let active=false,space=false,drag:(BustDrag&{pointer:number;other:ChestCircle|null})|null=null;
189
243
  const flash=new Set<BustSide>();
190
- const write=(row:number,circle:Partial<ChestCircle>)=>{for(const [id,value] of Object.entries(circleFields(row,circle))){const f=field(id);if(f)f.value=value;}};
191
- const flashSides=(sides:readonly BustSide[])=>{
192
- if(!sides.length)return;for(const side of sides)flash.add(side);
193
- host.message(`${CHEST_REGIONS_CLAMPED}: ${sides.map(sideTag).join(' and ')} — both cores plus 8 px must fit the centre distance minus 2 px and the bands share the rest`,true);
194
- if(flashTimer)clearTimeout(flashTimer);flashTimer=setTimeout(()=>{flash.clear();flashTimer=null;host.changed();},700);
195
- };
196
- /** Writes a changed side; when both rows are circles the pair is clamped as the rebuild script would. */
197
- const commit=(side:BustSide,next:ChestCircle,other:ChestCircle|null)=>{
198
- if(!other){write(sideRow(side),next);return;}
199
- const [right,left]=side==='r'?[next,other]:[other,next],settled=settleBust(right,left);
200
- write(0,settled.right);write(1,settled.left);flashSides(settled.clamped);
244
+ const write=(row:number,circle:Partial<BustShape>)=>{
245
+ for(const [id,value] of Object.entries(circleFields(row,circle))){const f=field(id);if(f)f.value=value;}
246
+ const nameField=field(chestRowId(row,'name'));if(nameField&&!nameField.value.trim())nameField.value=row===0?'bust_r':'bust_l';
247
+ const boneField=field(chestRowId(row,'bone'));if(boneField&&!boneField.value.trim())boneField.value=(field(row===0?'lm-bone_r':'lm-bone_l')?.value??'').trim()||(row===0?'boob_r':'boob_l');
248
+ const spacingField=field(chestRowId(row,'spacing'));if(spacingField&&!spacingField.value.trim())spacingField.value='14';
201
249
  };
250
+ /** Writes a changed side directly as Family does (without clamping overlapping outer bands across sides). */
251
+ const commit=(side:BustSide,next:BustShape)=>{write(sideRow(side),next);};
202
252
  const projected=():ProjectedBust[]=>{
203
253
  const project=host.project(),mapping=host.mapping();if(!project||!mapping.available)return [];
204
- return bustSides.flatMap(({side,row})=>{const c=rowCircle(read,row);if(!c)return [];const at=projectCircle(project,{center:mapping.toWorld(c.cx,c.cy),r:c.r,band:c.band});return at?[{side,...at}]:[];});
254
+ return bustSides.flatMap(({side,row})=>{const c=rowShape(read,row);if(!c)return [];const at=projectCircle(project,{center:mapping.toWorld(c.cx,c.cy),r:c.r,...(c.ry===undefined?{}:{ry:c.ry}),band:c.band});return at?[{side,...at}]:[];});
205
255
  };
206
256
  const local=(event:PointerEvent):OverlayPoint=>{const rect=host.canvas.getBoundingClientRect();return {x:event.clientX-rect.left,y:event.clientY-rect.top};};
207
257
  const scale=()=>{const project=host.project();if(!project)return 0;const a=project(0,0),b=project(1,0);return Math.hypot(b.x-a.x,b.y-a.y);};
@@ -209,7 +259,7 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
209
259
  const visible=chestEditVisible(host.inspector());toggle.hidden=!visible;
210
260
  if(!visible&&active)setActive(false);
211
261
  for(const {side,row} of bustSides){
212
- const circle=rowCircle(read,row),values={x:read(chestRowId(row,'cx'))?.value??'',y:read(chestRowId(row,'cy'))?.value??'',r:circle?String(circle.r):'',band:read(chestRowId(row,'band'))?.value??''};
262
+ const circle=rowShape(read,row),values={x:read(chestRowId(row,'cx'))?.value??'',y:read(chestRowId(row,'cy'))?.value??'',r:circle?String(circle.r):'',band:read(chestRowId(row,'band'))?.value??''};
213
263
  for(const f of bustFields){const input=field(bustInputId(side,f));if(input&&document.activeElement!==input)input.value=values[f];}
214
264
  const r=field(bustInputId(side,'r'));if(r)r.placeholder=circle||!(read(chestRowId(row,'ax'))?.value??'').trim()?'':'ellipse';
215
265
  }
@@ -229,21 +279,30 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
229
279
  const target=event.target as HTMLInputElement,match=/^bust-([rl])-(x|y|r|band)$/.exec(target.id);if(!match)return;
230
280
  const value=Number(target.value);if(!target.value.trim()||!Number.isFinite(value))return;
231
281
  const side=match[1] as BustSide,key=({x:'cx',y:'cy',r:'r',band:'band'} as const)[match[2] as typeof bustFields[number]];
232
- write(sideRow(side),{[key]:value});host.changed();
282
+ // #315: r on an ellipse row follows the handles' rule (ay and the clip offset scale with it).
283
+ const shape=key==='r'?rowShape(read,sideRow(side)):null;
284
+ write(sideRow(side),shape?resizeBust(shape,value):{[key]:value});host.changed();
233
285
  });
234
286
  bar.addEventListener('change',event=>{
235
287
  const target=event.target as HTMLInputElement,match=/^bust-([rl])-/.exec(target.id);if(!match)return;
236
- const side=match[1] as BustSide,mine=rowCircle(read,sideRow(side)),other=rowCircle(read,sideRow(side==='r'?'l':'r'));
237
- if(mine)commit(side,{...mine,r:limit(Math.round(mine.r),CHEST_CIRCLE_LIMITS.r),band:limit(Math.round(mine.band),CHEST_CIRCLE_LIMITS.band)},other);
288
+ const side=match[1] as BustSide,mine=rowShape(read,sideRow(side));
289
+ if(mine){const r=limit(Math.round(mine.r),CHEST_CIRCLE_LIMITS.r);commit(side,{...(r===mine.r?mine:resizeBust(mine,r)),band:limit(Math.round(mine.band),CHEST_CIRCLE_LIMITS.band)});}
238
290
  sync();host.changed();
239
291
  });
240
- for(const button of bar.querySelectorAll<HTMLButtonElement>('[data-bust-mode]'))button.addEventListener('click',()=>{if(modeInput){modeInput.value=button.dataset.bustMode==='landmarks'?'landmarks':'circles';modeInput.dispatchEvent(new Event('input',{bubbles:true}));}armed=null;sync();host.changed();});
292
+ for(const button of bar.querySelectorAll<HTMLButtonElement>('[data-bust-mode]'))button.addEventListener('click',()=>{
293
+ const nextMode=button.dataset.bustMode==='landmarks'?'landmarks':'circles';
294
+ if(nextMode==='circles'&&!rowShape(read,0)&&!rowShape(read,1)){
295
+ const lm=readLandmarks(read);if('derived' in lm){const [r,l]=lm.derived.regions;write(0,{cx:r.cx,cy:r.cy,r:r.r,band:r.band});write(1,{cx:l.cx,cy:l.cy,r:l.r,band:l.band});}
296
+ }
297
+ if(modeInput){modeInput.value=nextMode;modeInput.dispatchEvent(new Event('input',{bubbles:true}));}
298
+ armed=null;sync();host.changed();
299
+ });
241
300
  for(const button of bar.querySelectorAll<HTMLButtonElement>('[data-landmark]'))button.addEventListener('click',()=>{const key=button.dataset.landmark as LandmarkKey;armed=armed===key?null:key;sync();host.changed();});
242
301
  bar.addEventListener('input',event=>{const id=(event.target as HTMLElement).id;if(/^lm-/.test(id)){sync();host.changed();}});
243
302
  node<HTMLButtonElement>('bust-mirror').addEventListener('click',()=>{
244
303
  const right=rowCircle(read,0),leftX=Number((read(chestRowId(1,'cx'))?.value??'').trim()||NaN);
245
304
  if(!right||!Number.isFinite(leftX)){host.message('Mirror needs a complete R circle and an L x.',true);return;}
246
- commit('l',mirrorBust(right,{cx:leftX}),right);sync();host.changed();
305
+ write(0,right);write(1,mirrorBust(right,{cx:leftX}));sync();host.changed();
247
306
  });
248
307
  node<HTMLButtonElement>('bust-download').addEventListener('click',()=>host.download());
249
308
  apply.addEventListener('click',()=>host.apply());
@@ -265,7 +324,7 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
265
324
  sync();host.changed();return;
266
325
  }
267
326
  const p=local(event),circles=projected(),hit=hitBustHandle(circles,p);if(!hit)return;
268
- const row=sideRow(hit.side),from=rowCircle(read,row),at=circles.find(c=>c.side===hit.side);if(!from||!at)return;
327
+ const row=sideRow(hit.side),from=rowShape(read,row),at=circles.find(c=>c.side===hit.side);if(!from||!at)return;
269
328
  // A handle drag edits values; it never reaches the viewport's pan and never moves the camera.
270
329
  event.stopPropagation();event.preventDefault();
271
330
  drag={side:hit.side,mode:hit.mode,start:p,centre:at.center,from,pointer:event.pointerId,other:rowCircle(read,sideRow(hit.side==='r'?'l':'r'))};
@@ -274,7 +333,7 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
274
333
  const move=(event:PointerEvent)=>{
275
334
  if(landmarkDrag&&event.pointerId===landmarkDrag.pointer){event.stopPropagation();const at=cropAt(local(event));if(at){writePoint(landmarkDrag.key,at);sync();host.changed();}return;}
276
335
  if(active&&!space&&mode()==='landmarks'){if(hitLandmark(landmarkMarkers(),local(event)))host.pane.dataset.chestHover='move';else delete host.pane.dataset.chestHover;return;}
277
- if(drag&&event.pointerId===drag.pointer){event.stopPropagation();commit(drag.side,dragBust(drag,local(event),scale()),drag.other);sync();host.changed();return;}
336
+ if(drag&&event.pointerId===drag.pointer){event.stopPropagation();commit(drag.side,dragBust(drag,local(event),scale()));sync();host.changed();return;}
278
337
  if(active&&!space&&!drag){const hit=hitBustHandle(projected(),local(event));if(hit)host.pane.dataset.chestHover=hit.mode;else delete host.pane.dataset.chestHover;}
279
338
  };
280
339
  const end=(event:PointerEvent)=>{
@@ -292,6 +351,6 @@ export function bindChestEditor(host:ChestEditorHost):ChestEditor {
292
351
  notify:(text,error=false,lines)=>{notice=text===null?null:{text,error};if(lines){log.textContent=lines.join('\n');log.hidden=!lines.length;log.scrollTop=log.scrollHeight;}sync();},
293
352
  noticeText:()=>notice?.text??'',
294
353
  rebuildState:({busy,applied})=>{apply.disabled=busy;apply.setAttribute('aria-busy',String(busy));reset.disabled=busy||!applied;},
295
- dispose:()=>{observer.disconnect();if(flashTimer)clearTimeout(flashTimer);host.pane.removeEventListener('pointerdown',down,true);host.pane.removeEventListener('pointermove',move,true);for(const type of ['pointerup','pointercancel','lostpointercapture'] as const)host.pane.removeEventListener(type,end,true);document.removeEventListener('keydown',keyDown,true);window.removeEventListener('keyup',keyUp,true);window.removeEventListener('blur',blur);},
354
+ dispose:()=>{observer.disconnect();host.pane.removeEventListener('pointerdown',down,true);host.pane.removeEventListener('pointermove',move,true);for(const type of ['pointerup','pointercancel','lostpointercapture'] as const)host.pane.removeEventListener(type,end,true);document.removeEventListener('keydown',keyDown,true);window.removeEventListener('keyup',keyUp,true);window.removeEventListener('blur',blur);},
296
355
  };
297
356
  }
@@ -1,5 +1,5 @@
1
1
  /** Setup's Chest regions tool: form fields → designation input, without DOM access (main.ts owns the elements). */
2
- import {buildChestRegions,ChestRegionError,serializeChestRegions,type ChestRegionsDocument,type ChestRegionsInput,type CropWorldMapping} from '../src/chest-regions.ts';
2
+ import {buildChestRegions,chestDisplayRegions,ChestRegionError,serializeChestRegions,type ChestRegion,type ChestRegionsDocument,type ChestRegionsInput,type CropWorldMapping} from '../src/chest-regions.ts';
3
3
 
4
4
  export const chestRegionRows=[0,1] as const;
5
5
  export const chestRegionFields=['name','bone','cx','cy','ax','ay','spacing','band','clip'] as const;
@@ -25,8 +25,9 @@ function numberField(read:ChestFieldReader,id:string,what:string,optional=false)
25
25
  /** Reads the tool's fields; crop comes from the model mapping when it exists, else from the crop fields. */
26
26
  export function readChestForm(read:ChestFieldReader,mapping:CropWorldMapping,bones:readonly string[]|null):ChestRegionsInput {
27
27
  const crop=mapping.available?mapping.crop:{w:numberField(read,'chest-crop-w','crop w')!,h:numberField(read,'chest-crop-h','crop h')!};
28
- const contour={tolerance:0,margin:0,spacing:0,maxEdge:0,stray:0,bridges:read('chest-bridges')?.checked===true};
29
- for(const [key,id] of chestContourFields)contour[key]=numberField(read,id,`contour ${key}`)!;
28
+ // #318: max edge and stray are optional as in the producer's contour block; an empty field is absent, never 0.
29
+ const contour:ChestRegionsInput['contour']={tolerance:0,margin:0,spacing:0,bridges:read('chest-bridges')?.checked===true};
30
+ for(const [key,id] of chestContourFields){const value=numberField(read,id,`contour ${key}`,key==='maxEdge'||key==='stray');if(value!==undefined)contour[key]=value;}
30
31
  // A row without a centre x is not designated (#118): one row exports alone, as Apply · Rebuild sends it.
31
32
  const regions=chestRegionRows.filter(row=>(read(chestRowId(row,'cx'))?.value??'').trim()).map(row=>{
32
33
  const name=(read(chestRowId(row,'name'))?.value??'').trim()||`row ${row+1}`,num=(field:typeof chestRegionFields[number],optional=false)=>numberField(read,chestRowId(row,field),`${name} ${field}`,optional);
@@ -39,19 +40,32 @@ export function readChestForm(read:ChestFieldReader,mapping:CropWorldMapping,bon
39
40
  return {crop,generator:(read('chest-generator')?.value??'').trim(),contour,regions,...(r===undefined?{}:{r}),...(segments===undefined?{}:{segments}),...(sourceRule?{sourceRule}:{}),bones};
40
41
  }
41
42
 
42
- export type ChestEvaluation={ok:true;document:ChestRegionsDocument;text:string}|{ok:false;error:string};
43
+ /**
44
+ * A refused designation; `regions` (#323) only when the generator alone refused it — every other rule passed, so the
45
+ * overlay draws them while export, which reads `ok`, still refuses `CHEST_REGIONS_GENERATOR_MISSING`.
46
+ */
47
+ export type ChestEvaluation={ok:true;document:ChestRegionsDocument;text:string}|{ok:false;error:string;regions?:ChestRegion[]};
43
48
  export function evaluateChestForm(read:ChestFieldReader,mapping:CropWorldMapping,bones:readonly string[]|null):ChestEvaluation {
44
- try{const document=buildChestRegions(readChestForm(read,mapping,bones));return {ok:true,document,text:serializeChestRegions(document)};}
45
- catch(error){if(error instanceof ChestRegionError)return {ok:false,error:error.message};throw error;}
49
+ let input:ChestRegionsInput|null=null;
50
+ try{input=readChestForm(read,mapping,bones);const document=buildChestRegions(input);return {ok:true,document,text:serializeChestRegions(document)};}
51
+ catch(error){
52
+ if(!(error instanceof ChestRegionError))throw error;
53
+ if(error.code!=='CHEST_REGIONS_GENERATOR_MISSING'||!input)return {ok:false,error:error.message};
54
+ // The export refusal stays the generator's; a region rule failing as well draws nothing, as before.
55
+ try{return {ok:false,error:error.message,regions:chestDisplayRegions(input)};}
56
+ catch(inner){if(inner instanceof ChestRegionError)return {ok:false,error:error.message};throw inner;}
57
+ }
46
58
  }
59
+ /** The regions the overlay shows: a valid designation's, or (#323) those only the generator held back from export. */
60
+ const shownRegions=(evaluation:ChestEvaluation):ChestRegion[]=>evaluation.ok?evaluation.document.mesh.value.contour.regions:evaluation.regions??[];
47
61
 
48
62
  /** Polygon regions in rig world coordinates for the overlay; none without a model-fixed mapping. Circles are drawn as circles. */
49
63
  export function chestOverlayPolygons(evaluation:ChestEvaluation,mapping:CropWorldMapping):{name:string;row:number;points:{x:number;y:number}[]}[] {
50
- if(!evaluation.ok||!mapping.available)return [];
51
- return evaluation.document.mesh.value.contour.regions.flatMap((region,row)=>region.shape==='polygon'?[{name:region.name,row,points:region.points.map(([x,y])=>mapping.toWorld(x,y))}]:[]);
64
+ if(!mapping.available)return [];
65
+ return shownRegions(evaluation).flatMap((region,row)=>region.shape==='polygon'?[{name:region.name,row,points:region.points.map(([x,y])=>mapping.toWorld(x,y))}]:[]);
52
66
  }
53
- /** Circle regions of a valid designation: world centre, core r and band (crop px = world px under the mapping). */
67
+ /** Circle regions of a valid designation (or one only the generator refused): world centre, core r and band (crop px = world px under the mapping). */
54
68
  export function chestOverlayCircles(evaluation:ChestEvaluation,mapping:CropWorldMapping):{name:string;row:number;center:{x:number;y:number};r:number;band:number}[] {
55
- if(!evaluation.ok||!mapping.available)return [];
56
- return evaluation.document.mesh.value.contour.regions.flatMap((region,row)=>region.shape==='circle'?[{name:region.name,row,center:mapping.toWorld(region.cx,region.cy),r:region.r,band:region.band}]:[]);
69
+ if(!mapping.available)return [];
70
+ return shownRegions(evaluation).flatMap((region,row)=>region.shape==='circle'?[{name:region.name,row,center:mapping.toWorld(region.cx,region.cy),r:region.r,band:region.band}]:[]);
57
71
  }
@@ -16,7 +16,7 @@ import type { AnimationSourceOp } from '../src/animation-ops.ts';
16
16
  import { partBounds, type PartExplorer } from './part-selection.ts';
17
17
  import { bindInspectorBlocks, activeBlocksUI, restoreActiveBlocksUI, type InspectorBlocks } from './inspector-blocks.ts';
18
18
  import { sourceTextContent, tr } from './i18n.ts';
19
- import { bindChestEditor, canvasToCrop, bustLabel, bustSides, LANDMARKS, landmarkInputId, rowCircle, type ChestEditor, type LandmarkKey } from './chest-editor.ts';
19
+ import { bindChestEditor, canvasToCrop, bustLabel, bustSides, chestPoseOffset, LANDMARKS, landmarkInputId, posedChestMapping, rowShape, type ChestEditor, type LandmarkKey } from './chest-editor.ts';
20
20
  import { chestOverlayCircles, chestOverlayPolygons, chestRegionRows, chestRowId, evaluateChestForm } from './chest-regions-tool.ts';
21
21
  import { chestRegionsBinding, cropWorldMapping, type CropWorldMapping } from '../src/chest-regions.ts';
22
22
  import { bindMeshEditor, meshEditSource, sha256Hex, type MeshEditor } from './mesh-editor.ts';
@@ -43,7 +43,7 @@ import { bindRetargetPanel, type PoseMap, type RetargetPanel } from './retarget-
43
43
  import type { RetargetFlags } from '../src/retarget.ts';
44
44
  import {
45
45
  historyRow, isPatchJob, recordFor, refusedText, restoredOutcomeForJob, retargetStage, undoControl,
46
- animationAppliedRecord, animationOutcomeLine, appliedRecord, deltaAppliedRecord, deltaOutcomeLine, designatedRegions, handoffText,
46
+ animationAppliedRecord, animationOutcomeLine, appliedRecord, deltaAppliedRecord, deltaOutcomeLine, chestSeed, designatedRegions, handoffText,
47
47
  landmarksRequest, seedLandmarks, makePatch, outcomeLine, patchAppliedRecord, patchOutcomeLine,
48
48
  pickBustPart, pickPart, runRebuild, seedFields, stageModel, retargetAppliedRecord, retargetOutcomeLine, stripPendingAfter,
49
49
  type AnimationJobView, type AnimationRequestBody, type AppliedHistoryView, type UndoView, type AnyJobView, type AppliedAnimation, type AppliedDelta, type AppliedPatch,
@@ -87,6 +87,7 @@ interface SideBuildState {
87
87
  stageCheck: { lines: string[]; check: CheckSummary | null } | null;
88
88
  chestInputs: Record<string, string> | null;
89
89
  chestMapping: CropWorldMapping;
90
+ setupChestWorld: { x: number; y: number } | null;
90
91
  stripView: DensityStripViewLike | null;
91
92
  stripPending: {
92
93
  index: number;
@@ -122,6 +123,7 @@ function emptySideState(): SideBuildState {
122
123
  stageCheck: null,
123
124
  chestInputs: null,
124
125
  chestMapping: { available: false, reason: 'CHEST_REGION_MAPPING_UNAVAILABLE: no compiled model drawn' },
126
+ setupChestWorld: null,
125
127
  stripView: null,
126
128
  stripPending: null,
127
129
  readingsJob: null,
@@ -461,7 +463,6 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
461
463
  else if (currentInspector() === 'rig' || currentInspector() === 'playback') selectInspectorTab('view');
462
464
  }
463
465
  refreshAnimationInspection();
464
- inspectorBlocks?.refresh();
465
466
  host.redrawOverlays(modeBoundaryChanged);
466
467
  host.saveDraft();
467
468
  }
@@ -598,6 +599,11 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
598
599
  return evaluateChestForm(chestField, currentState().chestMapping, currentSideData()?.feedbackCatalog.bones);
599
600
  }
600
601
 
602
+ function activeChestMapping(side: Side = pickedSide): CropWorldMapping {
603
+ const state = sides[side];
604
+ return posedChestMapping(state.chestMapping, chestPoseOffset(host.players[side], state.setupChestWorld));
605
+ }
606
+
601
607
  function updateChestMapping(side: Side = pickedSide): void {
602
608
  const state = sides[side];
603
609
  const player = host.players[side], sideAssets = host.assets[side];
@@ -639,7 +645,7 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
639
645
 
640
646
  function chestRegions(): OverlayRegion[] {
641
647
  const style = getComputedStyle(document.documentElement), token = (name: string) => style.getPropertyValue(name).trim();
642
- return chestOverlayPolygons(chestEvaluation(), currentState().chestMapping).map((region, i) => ({
648
+ return chestOverlayPolygons(chestEvaluation(), activeChestMapping()).map((region, i) => ({
643
649
  ...region,
644
650
  stroke: token(i ? '--rv-region-b' : '--rv-region-a'),
645
651
  fill: token(i ? '--rv-region-b-fill' : '--rv-region-a-fill'),
@@ -647,7 +653,7 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
647
653
  }
648
654
 
649
655
  function chestCircles(): OverlayCircle[] {
650
- const mapping = currentState().chestMapping;
656
+ const mapping = activeChestMapping();
651
657
  if (!mapping.available) return [];
652
658
  const style = getComputedStyle(document.documentElement), token = (name: string) => style.getPropertyValue(name).trim();
653
659
  const colors = (row: number, overlap: boolean) => ({
@@ -667,17 +673,17 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
667
673
  }));
668
674
  }
669
675
  if (chestEditor?.active()) {
670
- const rows = bustSides.map(({ side, row }) => ({ side, row, circle: rowCircle(chestField, row) })), [r, l] = [rows[0]!.circle, rows[1]!.circle];
676
+ const rows = bustSides.map(({ side, row }) => ({ side, row, circle: rowShape(chestField, row) })), [r, l] = [rows[0]!.circle, rows[1]!.circle];
671
677
  const overlap = !!r && !!l && r.r + l.r > Math.hypot(l.cx - r.cx, l.cy - r.cy);
672
678
  return rows.flatMap(({ side, row, circle }) => circle ? [{
673
- center: mapping.toWorld(circle.cx, circle.cy), r: circle.r, band: circle.band, label: bustLabel(side, circle), labelRow: row, handles: true, flash: chestEditor!.flashing(side), colors: colors(row, overlap),
679
+ center: mapping.toWorld(circle.cx, circle.cy), r: circle.r, ...(circle.ry === undefined ? {} : { ry: circle.ry }), ...(circle.clip === undefined ? {} : { clipX: mapping.toWorld(circle.clip, circle.cy).x }), band: circle.band, label: bustLabel(side, circle), labelRow: row, handles: true, flash: chestEditor!.flashing(side), colors: colors(row, overlap),
674
680
  }] : []);
675
681
  }
676
682
  return chestOverlayCircles(chestEvaluation(), mapping).map(c => ({ center: c.center, r: c.r, band: c.band, handles: false, colors: colors(c.row, false) }));
677
683
  }
678
684
 
679
685
  function chestMarkers(): OverlayMarker[] {
680
- const mapping = currentState().chestMapping;
686
+ const mapping = activeChestMapping();
681
687
  if (!mapping.available || !chestEditor?.active() || chestEditor.mode() !== 'landmarks') return [];
682
688
  const style = getComputedStyle(document.documentElement), token = (name: string) => style.getPropertyValue(name).trim(), armed = chestEditor.armed();
683
689
  const at = (key: LandmarkKey) => {
@@ -797,7 +803,7 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
797
803
  const read = chestEditor.landmarks();
798
804
  return 'derived' in read ? pickBustPart(status, read.derived.regions) : pickBustPart(status, []);
799
805
  }
800
- const designated = designatedRegions(chestField);
806
+ const designated = designatedRegions(chestField, chestSeed(status));
801
807
  return 'regions' in designated ? pickPart(status, designated.regions) : status.parts.length === 1 ? status.parts[0]!.name : null;
802
808
  }
803
809
 
@@ -941,7 +947,10 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
941
947
  state.chestInputs = snapshotChestInputs();
942
948
  }
943
949
  el('chest-regions').dispatchEvent(new Event('input', { bubbles: true }));
950
+ // #315: a config polygon the editor cannot read as an ellipse is named, never shown as an empty row.
951
+ const refused = chestSeed(status).refusals;
944
952
  if (!status.available) chestEditor?.notify(status.reason, true);
953
+ else if (refused.length) chestEditor?.notify(refused.join(' · '), true, refused);
945
954
  else chestEditor?.notify('', false);
946
955
  renderHandoff(status);
947
956
  retargetPanel?.load(status.retarget ?? null, status.reason);
@@ -1249,7 +1258,7 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
1249
1258
  }
1250
1259
  ({ part, body } = request);
1251
1260
  } else {
1252
- const designated = designatedRegions(chestField);
1261
+ const designated = designatedRegions(chestField, chestSeed(status));
1253
1262
  if ('error' in designated) { if (pickedSide === side) chestEditor?.notify(designated.error, true); return; }
1254
1263
  const picked = pickPart(status, designated.regions);
1255
1264
  if (!picked) { if (pickedSide === side) chestEditor?.notify(`REBUILD_PART_AMBIGUOUS: the config states ${status.parts.length} contour meshes and the designated bones name none of them alone`, true); return; }
@@ -2255,7 +2264,7 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
2255
2264
  pane: paneProxy,
2256
2265
  canvas: overlayProxy,
2257
2266
  project: () => currentPlayer() ? rigProject() : null,
2258
- mapping: () => currentState().chestMapping,
2267
+ mapping: () => activeChestMapping(),
2259
2268
  changed: renderChest,
2260
2269
  download: () => { void exportChest(); },
2261
2270
  apply: () => { void applyRebuild(); },
@@ -2692,6 +2701,8 @@ export function mountComparePickedTools(host: ComparePickedToolsHost): ComparePi
2692
2701
  st.stageSource = { url: modelUrl, prefix, hash: sha256 };
2693
2702
  st.stageModelHash = sha256;
2694
2703
  st.partModel = partModel;
2704
+ const p = host.players[side];
2705
+ try { const b = p?.bone('chest'); st.setupChestWorld = b && Number.isFinite(b.x) && Number.isFinite(b.y) ? { x: b.x, y: b.y } : null; } catch { st.setupChestWorld = null; }
2695
2706
  if (side !== pickedSide && st.animationState) {
2696
2707
  st.animationState.document = null;
2697
2708
  st.animationState.baseInspection = null;
package/web/compare.css CHANGED
@@ -158,7 +158,7 @@ main{position:relative}.viewbar,.toolbar{anchor-name:--stage-comment-bar}#stage-
158
158
  .readings-panel{padding:15px;border-top:1px solid var(--border);background:var(--rv-panel);font-size:11px}.readings-panel .row{margin-bottom:9px}.readings-panel .row label{display:flex;align-items:center;gap:4px;color:var(--fg-muted)}.readings-panel .hint{margin:0 0 9px}.readings-panel code{font:11px var(--font-mono)}.readings-panel button{padding:4px 9px;font-size:11px}.readings-pair{flex-wrap:nowrap}.readings-pair label{flex:none;min-width:92px}.readings-pair input[type=text]{flex:1;min-width:0;width:auto;padding:4px 6px;font:11px var(--font-mono)}.readings-worst{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.readings-line{display:grid;grid-template-columns:8px minmax(0,1fr);gap:6px;align-items:start}.readings-line .tick-swatch{margin-top:5px}.readings-line code,.readings-go{font:11px var(--font-mono);overflow-wrap:anywhere;text-align:left;color:var(--fg-strong)}.readings-go{border:0;background:transparent;padding:0;cursor:pointer}.readings-go:hover{background:transparent;color:var(--link-hover)}.readings-line.error code{color:var(--fail)}.readings-items{grid-column:2;color:var(--fg-muted)}.readings-items summary{cursor:pointer}.readings-items ul{margin:4px 0 0;padding-left:14px;display:flex;flex-direction:column;gap:3px}.tick-swatch{display:inline-block;width:8px;height:8px;border-radius:2px;vertical-align:baseline}.tick-swatch.inspected{background:var(--rv-tick-inspected)}.tick-swatch.scratch{background:var(--rv-tick-scratch)}
159
159
  .idle-panel .idle-add-row input[type=text]{flex:1;min-width:90px;width:auto;padding:4px 6px;font:11px var(--font-mono)}.idle-preview-label{margin-left:auto;padding:2px 7px;border:1px solid var(--warn);border-radius:4px;color:var(--warn);font-size:11px;overflow-wrap:anywhere}.idle-preview-label.refused{border-style:dashed}.idle-preview-toggle{display:inline-flex;align-items:center;gap:4px;color:var(--fg-muted)}.idle-table tr.pending td,.idle-panel p.pending{color:var(--warn)}.idle-blink{margin:10px 0}.idle-blink .eyebrow{margin:0 0 6px}.idle-period select{width:100%;min-width:0}.idle-precheck{display:flex;flex-direction:column;gap:4px;margin-bottom:9px}.idle-precheck code{font:11px var(--font-mono);overflow-wrap:anywhere}.idle-precheck .idle-note{color:var(--fg-muted)}.idle-handles{position:absolute;inset:0;pointer-events:none;z-index:3}.idle-handle{position:absolute;width:14px;height:14px;margin:-7px 0 0 -7px;padding:0;border:2px solid var(--rv-tick-scratch);border-radius:50%;background:var(--rv-pane-label-bg);pointer-events:auto;cursor:ns-resize;touch-action:none}.idle-handle span{position:absolute;left:16px;top:-3px;white-space:nowrap;padding:1px 4px;border-radius:3px;background:var(--rv-pane-label-bg);color:var(--rv-stage-fg);font:10px var(--font-mono);pointer-events:none}
160
160
  .mesh-params{margin:0 0 10px}.mesh-param{grid-template-columns:78px minmax(0,1fr) 72px 18px auto}.mesh-param select{max-width:140px}.mesh-param-toggle{margin-top:2px}.mesh-tools{display:flex;align-items:center;flex-wrap:wrap;gap:6px}.mesh-tools .eyebrow{margin:0 6px 0 0}.mesh-tools button[aria-pressed=true]{background:var(--rv-pressed-bg);border-color:var(--rv-pressed-border);color:var(--rv-pressed-fg)}.mesh-regions{display:flex;flex-direction:column;gap:6px;margin:0 0 10px}.mesh-region{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;margin:0;padding:6px 8px;border:1px solid var(--border);border-radius:6px}.mesh-region.selected{border-color:var(--rv-mesh-region)}.mesh-region legend{padding:0 4px;font:600 11px var(--font-mono);color:var(--rv-mesh-region)}.mesh-region label{display:flex;align-items:center;gap:4px;color:var(--fg-muted)}.mesh-region input[type=number]{width:62px}.mesh-region input[type=text]{width:96px;padding:3px 5px;font-size:11px}.mesh-segments li{display:flex;flex-wrap:wrap;align-items:center;gap:6px}.mesh-ribs{display:inline-flex;align-items:center;gap:4px;color:var(--fg-muted)}.mesh-ribs input{width:64px}.mesh-precheck{margin:0 0 9px;padding-left:18px}.mesh-precheck li{color:var(--fail);overflow-wrap:anywhere}#mesh-counts code.error,#mesh-status.error{color:var(--fail)}
161
- .block-row{position:sticky;top:-12px;z-index:3;display:flex;flex-wrap:nowrap;gap:4px;margin:-12px -15px 10px;padding:6px 15px;overflow-x:auto;overscroll-behavior-x:contain;background:var(--rv-panel);border-bottom:1px solid var(--border)}.block-row button{flex:none;padding:3px 9px;font-size:11px;white-space:nowrap;color:var(--fg-muted);background:transparent;border-color:transparent}.block-row button:hover{color:var(--fg-strong);background:var(--rv-control-hover)}.block-row button[aria-current=true]{color:var(--rv-pressed-fg);background:var(--rv-pressed-bg);border-color:var(--rv-pressed-border)}.block-row button:focus-visible{outline:2px solid var(--rv-focus);outline-offset:-2px}
161
+ .block-row{position:sticky;top:-12px;z-index:3;display:flex;flex-wrap:nowrap;gap:4px;margin:-12px -15px 10px;padding:6px 15px;overflow-x:auto;overscroll-behavior-x:contain;background:var(--rv-panel);border-bottom:1px solid var(--border)}.block-row button{flex:none;padding:3px 9px;font-size:11px;white-space:nowrap;color:var(--fg-muted);background:transparent;border-color:transparent}.block-row button:hover{color:var(--fg-strong);background:var(--rv-control-hover)}.block-row button[aria-selected=true]{color:var(--rv-pressed-fg);background:var(--rv-pressed-bg);border-color:var(--rv-pressed-border)}.block-row button:focus-visible{outline:2px solid var(--rv-focus);outline-offset:-2px}[data-block-hidden]{display:none!important}
162
162
  .weights-controls{display:flex;align-items:center;flex-wrap:wrap;gap:6px 12px}.weights-controls label{display:inline-flex;align-items:center;gap:5px}.weights-controls select{width:auto;max-width:220px}#weights-state.error{color:var(--fail)}.weights-legend{display:flex;align-items:center;flex-wrap:wrap;gap:6px 10px;margin:0 0 8px;font:11px var(--font-mono);color:var(--fg-muted)}.weights-ramp{display:inline-block;width:140px;height:10px;border-radius:3px;background:linear-gradient(90deg,var(--rv-weight-0),var(--rv-weight-half),var(--rv-weight-1))}.weights-swatch{display:inline-flex;align-items:center;gap:5px}.weights-swatch i{display:inline-block;width:10px;height:10px;border-radius:50%}
163
163
  .bones-controls{display:flex;align-items:center;flex-wrap:wrap;gap:6px 10px}.bones-controls button[aria-pressed=true]{background:var(--rv-pressed-bg);border-color:var(--rv-pressed-border);color:var(--rv-pressed-fg)}.bones-controls select{max-width:260px}#bones-panel-state.error{color:var(--fail)}#bones-status.error{color:var(--fail)!important}.bones-anchor-editor{margin:0 0 10px;padding:9px 10px;border:1px solid var(--border);border-radius:6px}.bones-anchor{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr) 64px 64px auto;align-items:center;gap:6px;margin:3px 0;color:var(--fg-muted)}.bones-anchor code{overflow-wrap:anywhere}.bones-anchor.pending span,.bones-anchor.pending output{color:var(--warn)}.bones-anchor output{font:11px var(--font-mono)}.bones-lines{display:flex;flex-direction:column;gap:3px;margin-top:8px}.bones-lines .eyebrow{margin:0 0 2px}.bones-lines code{overflow-wrap:anywhere;color:var(--fg-strong)}.bones-lines code.lint{color:var(--warn)}.bones-lines code.error{color:var(--fail)}.bones-coverage summary{cursor:pointer;font:11px var(--font-mono);color:var(--fg-muted)}.bones-coverage code{display:block;margin:2px 0 2px 12px;color:var(--fg-muted)}.pane[data-bones-hover=move]{cursor:move}
164
164
  .rig-fields-group{margin:8px 0 10px}.rig-fields-group .eyebrow{margin:0 0 5px}.rig-fields-group .row{flex-wrap:wrap;gap:6px;align-items:center}.rig-fields-group select{min-width:0;max-width:100%}.rig-fields-group input[type=number]{width:76px}.rig-fields-group .physics-control{display:grid;grid-template-columns:minmax(64px,auto) minmax(0,1fr) 76px auto;gap:6px;align-items:center}
package/web/compare.html CHANGED
@@ -3,5 +3,5 @@
3
3
  <header><div class="brand">rig review <span>COMPARE</span></div><div><h1 id="title">A / B comparison</h1><span id="animation" class="hint"></span></div><div class="mode-switch" role="group" aria-label="Mode"><button type="button" data-mode="rig" aria-pressed="false">Setup</button><button type="button" data-mode="playback" aria-pressed="false">Animate</button><button type="button" data-mode="compare" aria-pressed="true">Compare</button></div><div id="mode-build-picker" class="mode-build-picker" role="group" aria-label="Picked build for Setup and Animate" hidden><span class="eyebrow">Editing</span><button type="button" data-build-side="a" aria-pressed="true">Build A</button><button type="button" data-build-side="b" aria-pressed="false">Build B</button><span id="picked-build-label" class="picked-build-label" role="status" aria-live="polite">Build A</span></div><div class="actions"><span id="save-state" class="hint">Loading…</span><button id="export-json">Feedback JSON</button><button id="export-markdown">Issue Markdown</button><button id="submit" class="primary" disabled>Submit review</button></div></header>
4
4
  <div class="layout"><main><div class="toolbar"><button id="stage-comment" type="button" aria-pressed="false" aria-expanded="false" aria-controls="stage-comment-list" title="Comment · C (active mesh editor keeps C)">Comment · C (0)</button><span id="toolbar-mode-hint">Inspect A and B at the reference video time</span><!-- shared:view-tools --><div class="row"><label class="camera-sync"><input id="camera-sync" type="checkbox" checked>Sync cameras</label><button id="zoom-out" aria-label="Zoom active view out">−</button><output id="zoom-label">100%</output><button id="zoom-in" aria-label="Zoom active view in">+</button><button id="fit">Fit synchronized views</button></div></div><!-- shared:stage-bars -->
5
5
  <div id="stage-layout" class="stages"><section id="reference-pane" class="pane"><div class="pane-head"><strong>REFERENCE</strong><span id="reference-name"></span></div><div id="reference-viewport" class="reference-viewport"><video id="reference-video" preload="auto" playsinline muted></video><p id="reference-empty" class="empty">Loading reference video…</p></div><div class="pane-foot"><span id="reference-time">— s</span><label><input id="reference-audio" type="checkbox">Video audio</label></div></section><section id="a-pane" class="pane"><div class="pane-head"><strong class="side-label">A</strong><span id="a-title"></span></div><div id="a-viewport" class="rig-viewport"><div id="a-root" class="rig-root"></div><canvas id="a-overlay" class="rig-overlay" aria-label="A actual rig mesh and bone overlay"></canvas><!-- shared:stage-handles --><p id="a-empty" class="empty">Loading rig…</p></div><div class="pane-foot"><span id="a-time">— s</span><span id="a-frame">rate unknown</span><span id="a-renderer" aria-label="A last draw backend" title="DOM images for rigid parts; WebGL meshes when available, Canvas2D fallback.">Not rendered</span></div></section><section id="b-pane" class="pane"><div class="pane-head"><strong class="side-label">B</strong><span id="b-title"></span></div><div id="b-viewport" class="rig-viewport"><div id="b-root" class="rig-root"></div><canvas id="b-overlay" class="rig-overlay" aria-label="B actual rig mesh and bone overlay"></canvas><p id="b-empty" class="empty">Loading rig…</p></div><div class="pane-foot"><span id="b-time">— s</span><span id="b-frame">rate unknown</span><span id="b-renderer" aria-label="B last draw backend" title="DOM images for rigid parts; WebGL meshes when available, Canvas2D fallback.">Not rendered</span></div></section></div>
6
- <section class="inspector" aria-label="Inspection controls"><div class="inspector-heading"><strong>INSPECTOR</strong><div role="tablist" aria-label="Inspector sections"><button role="tab" id="tab-view" data-inspector="view" aria-controls="inspector-view" aria-selected="true" tabindex="0">View</button><button role="tab" id="tab-rig" data-inspector="rig" aria-controls="inspector-rig" aria-selected="false" tabindex="-1">Rig</button><button role="tab" id="tab-playback" data-inspector="playback" aria-controls="inspector-playback" aria-selected="false" tabindex="-1">Playback</button><button role="tab" id="tab-feedback" data-inspector="feedback" aria-controls="inspector-feedback" aria-selected="false" tabindex="-1">Feedback</button></div><span class="hint">Local view controls · source files stay unchanged</span></div><div class="draft-notice"><span id="draft-state" role="status" aria-live="polite"></span><div id="draft-recovery"></div></div><div class="inspector-body"><!-- shared:applied-records --><section id="inspector-view" role="tabpanel" aria-labelledby="tab-view" data-inspector-panel="view"><div class="view-link-controls"><button id="copy-view" type="button">Copy view link</button><span class="hint">Numeric source region · opening this link restores a paused inspection</span></div><pre id="view-coordinates" class="numeric-view" aria-label="Current numeric inspection region"></pre><div class="inspection-controls" aria-label="Inspection display controls"><label>Appearance <select id="appearance"><option value="system">System</option><option value="dark">Dark</option><option value="light">Light</option></select></label><label><input id="idle-repeat" type="checkbox" checked>Repeat idle</label><span id="idle-state" class="hint" role="status">Idle preview unavailable</span><span id="control-state" class="hint" role="status"></span></div><p class="hint">Sync cameras links fit-relative zoom and viewport-relative pan across visible panes. Turn it off for independent Reference, A and B views. Toolbar zoom and Fit use the last active pane.</p></section><section id="inspector-rig" role="tabpanel" aria-labelledby="tab-rig" data-inspector-panel="rig" hidden><!-- shared:setup-block-row --><section id="selected-part" aria-label="Selected part" aria-live="polite"></section><div class="rig-layer-controls"><fieldset id="layer-controls"><legend>Rig layers</legend><label><input id="layer-images" type="checkbox" checked disabled>Images</label><label><input id="layer-mesh" type="checkbox" disabled>Mesh edges</label><label><input id="layer-bones" type="checkbox" disabled>Bone points</label></fieldset><span id="layer-state" class="hint">No rig supplied</span></div><p id="rig-inspector-hint" class="hint">These controls show actual images, last-drawn mesh edges and named bone points. Both builds use the fixed animation named above. This inspector does not author geometry or motion.</p><!-- shared:setup-panels --></section><section id="inspector-playback" role="tabpanel" aria-labelledby="tab-playback" data-inspector-panel="playback" hidden><div id="animation-dock" class="animation-dock-panel" role="region" aria-label="Animation timeline"><section id="transport" class="transport"><button id="play" aria-label="Play reference video and both rigs" disabled>▶</button><input id="scrub" type="range" min="0" max="1" step="0.0001" value="0" aria-label="Shared comparison time" disabled><output id="time">— / — s</output><label for="time-input" class="sr-only">Reference video time to inspect</label><input id="time-input" type="number" min="0" step="0.0001" placeholder="Seconds" disabled><button id="seek" disabled>Go to time</button><!-- shared:transport-strips --></section><section id="animation-inspection" aria-label="Read-only animation inspection"></section></div><div id="animate-blocks" class="animate-blocks-panel" data-inspector-scroll><!-- shared:animate-block-row --><div class="compare-info"><output id="sync-status">Presentation pending</output><span id="sync-warning"></span></div><div class="compare-info"><label for="frame-basis">Review frame</label><select id="frame-basis"><option value="a">A explicit samples</option><option value="b">B explicit samples</option></select><input id="frame-input" type="number" min="0" step="1" aria-label="Explicit producer frame" disabled><button id="frame-seek" type="button" disabled>Inspect frame</button><span id="frame-index-status">Loading reference timestamp index…</span></div><div class="compare-info"><span id="domain">Checking shared playback range…</span><span id="clock-source">Waiting for video time</span></div><details class="trace"><summary>Synchronization trace</summary><pre id="trace">No frame presented yet.</pre></details><p id="playback-inspector-hint" class="boundary">Motion is read only. The reference video FPS is not used to infer the pose frame clock.</p><!-- shared:animate-panels --></div></section><section id="inspector-feedback" role="tabpanel" aria-labelledby="tab-feedback" data-inspector-panel="feedback" hidden><div class="review-summary"><div class="eyebrow">COMPARE REVIEW</div><label for="status">Review status</label><select id="status"><option value="pending">Pending</option><option value="approved">Approved</option><option value="changes-requested">Changes requested</option></select><section class="provenance"><h2>Source provenance</h2><div id="provenance-brief"></div><details><summary>Both builds, versions and reference video hash</summary><pre id="provenance-full"></pre></details></section></div><section class="feedback-form"><h2>Frame-range feedback</h2><label for="side">Target build</label><select id="side"><option value="">Select A or B</option><option value="a">A</option><option value="b">B</option></select><div class="frame-range"><label>Start frame<input id="frame-start" type="number" min="0" step="1" inputmode="numeric"></label><label>End frame<input id="frame-end" type="number" min="0" step="1" inputmode="numeric"></label></div><p id="feedback-range-hint" class="hint">Select A or B to check frame bounds.</p><label for="target-kind">Target type</label><select id="target-kind"><option value="">Select</option><option value="bone">Bone</option><option value="slot">Slot</option><option value="rig">Entire rig</option></select><label for="target-name">Actual target name</label><input id="target-name" type="text" list="target-names" autocomplete="off"><datalist id="target-names"></datalist><p id="target-hint" class="hint">Select a target build and type.</p><label for="category">Category</label><select id="category"><option value="">Select</option><option value="defect">Defect</option><option value="quality">Quality</option></select><label for="summary">One-line summary</label><input id="summary" type="text" maxlength="1000" placeholder="What looks wrong, and over which frames?"><button id="add-feedback" class="block" disabled>Add feedback</button><p id="feedback-warnings" class="hint" role="status" hidden></p><div id="feedback-list"></div></section><details id="strip-panel" class="trace"><summary>Export frame strip</summary><p class="hint">Uses the feedback form start and end frames, inclusive. Exports Reference / A / B rows without changing inspection time.</p><label for="strip-scope">Export range</label><select id="strip-scope"><option value="interval">Entered start–end frames</option><option value="feedback">All feedback ranges</option></select><label for="strip-basis">Report defining the range frames</label><select id="strip-basis"><option value="">Select A or B as frame basis</option><option value="a">A report frameTimes</option><option value="b">B report frameTimes</option></select><label for="strip-format">Format</label><select id="strip-format"><option value="png">PNG strip</option><option value="json">JSON frames and provenance</option></select><p class="hint">The same frame number in A and B is not assumed to mean the same time. Batch export uses each feedback side as its frame basis. Without frameTimes, PNG is refused and JSON preserves time: null.</p><button id="strip-export" type="button" disabled>Download strip</button><p id="strip-status" class="hint" role="status" aria-live="polite">Loading comparison provenance…</p></details></section></div></section></main><aside id="parts-explorer" class="parts-explorer" aria-label="Parts explorer"><div class="parts-tools"><h2>PARTS</h2><button type="button" data-part-whole aria-pressed="true">Whole rig</button><label for="part-search">Find slot</label><input id="part-search" data-part-search type="search" autocomplete="off" placeholder="Exact slot name or text"><label class="part-solo"><input id="part-solo" data-part-solo type="checkbox" disabled>Solo selected slot</label><p data-part-status class="hint" role="status">Loading actual slots…</p></div><ul data-part-list aria-label="Actual rig slots"></ul><p class="hint">Select in context or enable Solo. Thumbnails are each slot's declared page region; a type icon stands in where the model declares none. Atlas pages are not part thumbnails.</p></aside>
6
+ <section class="inspector" aria-label="Inspection controls"><div class="inspector-heading"><strong>INSPECTOR</strong><div role="tablist" aria-label="Inspector sections"><button role="tab" id="tab-view" data-inspector="view" aria-controls="inspector-view" aria-selected="true" tabindex="0">View</button><button role="tab" id="tab-rig" data-inspector="rig" aria-controls="inspector-rig" aria-selected="false" tabindex="-1">Rig</button><button role="tab" id="tab-playback" data-inspector="playback" aria-controls="inspector-playback" aria-selected="false" tabindex="-1">Playback</button><button role="tab" id="tab-feedback" data-inspector="feedback" aria-controls="inspector-feedback" aria-selected="false" tabindex="-1">Feedback</button></div><span class="hint">Local view controls · source files stay unchanged</span></div><div class="draft-notice"><span id="draft-state" role="status" aria-live="polite"></span><div id="draft-recovery"></div></div><div class="inspector-body"><!-- shared:applied-records --><section id="inspector-view" role="tabpanel" aria-labelledby="tab-view" data-inspector-panel="view"><div class="view-link-controls"><button id="copy-view" type="button">Copy view link</button><span class="hint">Numeric source region · opening this link restores a paused inspection</span></div><pre id="view-coordinates" class="numeric-view" aria-label="Current numeric inspection region"></pre><div class="inspection-controls" aria-label="Inspection display controls"><label>Appearance <select id="appearance"><option value="system">System</option><option value="dark">Dark</option><option value="light">Light</option></select></label><label><input id="idle-repeat" type="checkbox" checked>Repeat idle</label><span id="idle-state" class="hint" role="status">Idle preview unavailable</span><span id="control-state" class="hint" role="status"></span></div><p class="hint">Sync cameras links fit-relative zoom and viewport-relative pan across visible panes. Turn it off for independent Reference, A and B views. Toolbar zoom and Fit use the last active pane.</p></section><section id="inspector-rig" role="tabpanel" aria-labelledby="tab-rig" data-inspector-panel="rig" hidden><!-- shared:setup-block-row --><section id="selected-part" role="tabpanel" aria-labelledby="block-tab-selected-part" aria-label="Selected part" aria-live="polite"></section><div class="rig-layer-controls"><fieldset id="layer-controls"><legend>Rig layers</legend><label><input id="layer-images" type="checkbox" checked disabled>Images</label><label><input id="layer-mesh" type="checkbox" disabled>Mesh edges</label><label><input id="layer-bones" type="checkbox" disabled>Bone points</label></fieldset><span id="layer-state" class="hint">No rig supplied</span></div><p id="rig-inspector-hint" class="hint">These controls show actual images, last-drawn mesh edges and named bone points. Both builds use the fixed animation named above. This inspector does not author geometry or motion.</p><!-- shared:setup-panels --></section><section id="inspector-playback" role="tabpanel" aria-labelledby="tab-playback" data-inspector-panel="playback" hidden><div id="animation-dock" class="animation-dock-panel" role="region" aria-label="Animation timeline"><section id="transport" class="transport"><button id="play" aria-label="Play reference video and both rigs" disabled>▶</button><input id="scrub" type="range" min="0" max="1" step="0.0001" value="0" aria-label="Shared comparison time" disabled><output id="time">— / — s</output><label for="time-input" class="sr-only">Reference video time to inspect</label><input id="time-input" type="number" min="0" step="0.0001" placeholder="Seconds" disabled><button id="seek" disabled>Go to time</button><!-- shared:transport-strips --></section><section id="animation-inspection" aria-label="Read-only animation inspection"></section></div><div id="animate-blocks" class="animate-blocks-panel" data-inspector-scroll><!-- shared:animate-block-row --><div class="compare-info"><output id="sync-status">Presentation pending</output><span id="sync-warning"></span></div><div class="compare-info"><label for="frame-basis">Review frame</label><select id="frame-basis"><option value="a">A explicit samples</option><option value="b">B explicit samples</option></select><input id="frame-input" type="number" min="0" step="1" aria-label="Explicit producer frame" disabled><button id="frame-seek" type="button" disabled>Inspect frame</button><span id="frame-index-status">Loading reference timestamp index…</span></div><div class="compare-info"><span id="domain">Checking shared playback range…</span><span id="clock-source">Waiting for video time</span></div><details class="trace"><summary>Synchronization trace</summary><pre id="trace">No frame presented yet.</pre></details><p id="playback-inspector-hint" class="boundary">Motion is read only. The reference video FPS is not used to infer the pose frame clock.</p><!-- shared:animate-panels --></div></section><section id="inspector-feedback" role="tabpanel" aria-labelledby="tab-feedback" data-inspector-panel="feedback" hidden><div class="review-summary"><div class="eyebrow">COMPARE REVIEW</div><label for="status">Review status</label><select id="status"><option value="pending">Pending</option><option value="approved">Approved</option><option value="changes-requested">Changes requested</option></select><section class="provenance"><h2>Source provenance</h2><div id="provenance-brief"></div><details><summary>Both builds, versions and reference video hash</summary><pre id="provenance-full"></pre></details></section></div><section class="feedback-form"><h2>Frame-range feedback</h2><label for="side">Target build</label><select id="side"><option value="">Select A or B</option><option value="a">A</option><option value="b">B</option></select><div class="frame-range"><label>Start frame<input id="frame-start" type="number" min="0" step="1" inputmode="numeric"></label><label>End frame<input id="frame-end" type="number" min="0" step="1" inputmode="numeric"></label></div><p id="feedback-range-hint" class="hint">Select A or B to check frame bounds.</p><label for="target-kind">Target type</label><select id="target-kind"><option value="">Select</option><option value="bone">Bone</option><option value="slot">Slot</option><option value="rig">Entire rig</option></select><label for="target-name">Actual target name</label><input id="target-name" type="text" list="target-names" autocomplete="off"><datalist id="target-names"></datalist><p id="target-hint" class="hint">Select a target build and type.</p><label for="category">Category</label><select id="category"><option value="">Select</option><option value="defect">Defect</option><option value="quality">Quality</option></select><label for="summary">One-line summary</label><input id="summary" type="text" maxlength="1000" placeholder="What looks wrong, and over which frames?"><button id="add-feedback" class="block" disabled>Add feedback</button><p id="feedback-warnings" class="hint" role="status" hidden></p><div id="feedback-list"></div></section><details id="strip-panel" class="trace"><summary>Export frame strip</summary><p class="hint">Uses the feedback form start and end frames, inclusive. Exports Reference / A / B rows without changing inspection time.</p><label for="strip-scope">Export range</label><select id="strip-scope"><option value="interval">Entered start–end frames</option><option value="feedback">All feedback ranges</option></select><label for="strip-basis">Report defining the range frames</label><select id="strip-basis"><option value="">Select A or B as frame basis</option><option value="a">A report frameTimes</option><option value="b">B report frameTimes</option></select><label for="strip-format">Format</label><select id="strip-format"><option value="png">PNG strip</option><option value="json">JSON frames and provenance</option></select><p class="hint">The same frame number in A and B is not assumed to mean the same time. Batch export uses each feedback side as its frame basis. Without frameTimes, PNG is refused and JSON preserves time: null.</p><button id="strip-export" type="button" disabled>Download strip</button><p id="strip-status" class="hint" role="status" aria-live="polite">Loading comparison provenance…</p></details></section></div></section></main><aside id="parts-explorer" class="parts-explorer" aria-label="Parts explorer"><div class="parts-tools"><h2>PARTS</h2><button type="button" data-part-whole aria-pressed="true">Whole rig</button><label for="part-search">Find slot</label><input id="part-search" data-part-search type="search" autocomplete="off" placeholder="Exact slot name or text"><label class="part-solo"><input id="part-solo" data-part-solo type="checkbox" disabled>Solo selected slot</label><p data-part-status class="hint" role="status">Loading actual slots…</p></div><ul data-part-list aria-label="Actual rig slots"></ul><p class="hint">Select in context or enable Solo. Thumbnails are each slot's declared page region; a type icon stands in where the model declares none. Atlas pages are not part thumbnails.</p></aside>
7
7
  </div><footer><span id="message" role="status" aria-live="polite">Loading comparison provenance from the server…</span><span>Source files remain unchanged.</span></footer><script type="module" src="main.js"></script></body></html>
package/web/compare.ts CHANGED
@@ -4,7 +4,7 @@ import {sharedTurnDials,type TurnDial} from '../src/turn-pad.ts';
4
4
  import {bindTurnPad,type TurnPad} from './turn-pad.ts';
5
5
  import {PartExplorer,loadPartModel} from './part-selection.ts';
6
6
  import {PartThumbnails,pageRegionTable} from './part-thumbnails.ts';
7
- import {cameraFrame,cameraSignature,cameraFromSignature,assertCameraView,boundsFitSignature,dragSignature,zoomSignature,type CameraFrame,type CameraSignature,type PaneCamera} from './camera-view.ts';
7
+ import {cameraFrame,cameraSignature,cameraFromSignature,assertCameraView,boundsFitSignature,dragSignature,zoomSignature,type CameraFrame,type CameraPoint,type CameraSignature,type PaneCamera} from './camera-view.ts';
8
8
  import { CanvasRenderer, loadModel, RigPlayer, type ModelAssets, type PoseBounds } from '@rig-c/play';
9
9
  import type { CompareResponse, CompareSide } from '../src/compare.ts';
10
10
  import type { CompareFeedback, CompareSession } from '../src/compare-session.ts';
@@ -395,7 +395,7 @@ function bind(): void {
395
395
  button('zoom-in').onclick=()=>cameraAction(()=>zoomCamera(1.25));button('zoom-out').onclick=()=>cameraAction(()=>zoomCamera(1/1.25));button('fit').onclick=()=>cameraAction(()=>fitActiveCamera());
396
396
  input('camera-sync').onchange=()=>cameraAction(()=>setCameraSync(input('camera-sync').checked));
397
397
  for(const target of ['a','b','reference'] as const){
398
- el(target+'-viewport').addEventListener('wheel',event=>{event.preventDefault();cameraAction(()=>zoomCamera(event.deltaY<0?1.1:1/1.1,target));},{passive:false});
398
+ el(target+'-viewport').addEventListener('wheel',event=>{event.preventDefault();const rect=el(target+'-viewport').getBoundingClientRect();cameraAction(()=>zoomCamera(event.deltaY<0?1.1:1/1.1,target,{x:event.clientX-rect.left,y:event.clientY-rect.top}));},{passive:false});
399
399
  for(const event of ['pointerdown','focusin'] as const)el(target+'-viewport').addEventListener(event,()=>activateCamera(target));
400
400
  }
401
401
  select('status').onchange = () => { session.status = select('status').value as CompareSession['status']; markDirty(); };
@@ -500,7 +500,7 @@ function updateCamera(target:CameraTarget,value:CameraSignature,rigGroup=false):
500
500
  for(const other of ['a','b','reference'] as const){if(other===target||!cameraSync&&!(rigGroup&&other!=='reference'))continue;const next=paneFrame(other);if(next)updates[other]=cameraFromSignature(value,next);}
501
501
  Object.assign(cameras,updates);activeCamera=target;fit();
502
502
  }
503
- function zoomCamera(factor:number,target=availableCamera()):void {if(!target)return;const frame=paneFrame(target);if(frame)updateCamera(target,zoomSignature(cameraSignature(cameras[target],frame),factor));}
503
+ function zoomCamera(factor:number,target=availableCamera(),point?:CameraPoint|null):void {if(!target)return;const frame=paneFrame(target);if(frame)updateCamera(target,zoomSignature(cameraSignature(cameras[target],frame),factor,frame,point));}
504
504
  function panCamera(target:CameraTarget,dx:number,dy:number):void {const frame=paneFrame(target);if(frame)updateCamera(target,dragSignature(cameraSignature(cameras[target],frame),frame,dx,dy));}
505
505
  function fitActiveCamera(target=availableCamera()):void {if(!target)return;const tools=typeof pickedTools!=='undefined'?pickedTools:null,mode=tools?.mode()??'compare',picked=tools?.pickedSide()??'a',suffix=mode==='compare'?'':` on Build ${picked.toUpperCase()} (${data[picked].manifest.title})`;const part=parts?.value();if(part?.side===target){const box=parts?.bounds(),frame=paneFrame(target);if(!box||!frame){message('PART_FIT_UNAVAILABLE: selected slot has no positive drawn bounds.',true);return;}updateCamera(target,boundsFitSignature(box,frame,22,38));message(`Selected slot fitted${suffix}.`);}else{if(!paneFrame(target))return;updateCamera(target,{zoom:1,pan:{x:0,y:0}});message(`View fitted${suffix}.`);}}
506
506
  function referenceFit():void {const frame=paneFrame('reference');if(!frame)return;const signature=cameraSignature(cameras.reference,frame);video.style.transform=`translate(${signature.pan.x*frame.width}px,${signature.pan.y*frame.height}px) scale(${signature.zoom})`;}