@rig-c/review 1.1.0 → 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.
@@ -1,6 +1,6 @@
1
1
  /** Inspection graphics from the last successfully drawn public player pose. */
2
2
  import {partBounds} from './part-selection.ts';
3
- import {placeLabels} from './label-placement.ts';
3
+ import {boxesIntersect,placeLabels,type LabelBox} from './label-placement.ts';
4
4
  import type {BoneWorld,PosedFrame,RigPlayer} from '@rig-c/play';
5
5
 
6
6
  export interface OverlayPoint {x:number;y:number}
@@ -27,7 +27,7 @@ export interface OverlayRegion {name:string;points:OverlayPoint[];stroke:string;
27
27
  * outer circle at r + band. With handles it is the chest editor's drawing (centre, core edge on the right, band on
28
28
  * top, a label under the outer circle). Colours are theme token values.
29
29
  */
30
- export interface OverlayCircle {center:OverlayPoint;r:number;band:number;label?:string;/** Label rows below the outer circle, so two labels never overlap. */labelRow?:number;handles:boolean;flash?:boolean;colors:{stroke:string;fill:string;handle:string;ink:string;labelBg:string;flash:string}}
30
+ export interface OverlayCircle {center:OverlayPoint;r:number;band:number;/** #315: an ellipse row's vertical semi-axis (world px); absent for a circle. */ry?:number;/** #315: a clipped ellipse's medial clip x (world px). */clipX?:number;label?:string;/** Label rows below the outer circle, so two labels never overlap. */labelRow?:number;handles:boolean;flash?:boolean;colors:{stroke:string;fill:string;handle:string;ink:string;labelBg:string;flash:string}}
31
31
  /**
32
32
  * Mesh edit preview in rig world coordinates: the selected slot's original triangles (cut out of the veil that dims the
33
33
  * rest of the rig), the edges after the delta by kind, moved-vertex ghosts and the vertices as handles. A box is in
@@ -70,11 +70,33 @@ export interface OverlayAnchors {
70
70
  }
71
71
  export interface OverlayView {project:OverlayProject;settings:RigOverlaySettings;dpr?:number;regions?:readonly OverlayRegion[];circles?:readonly OverlayCircle[];markers?:readonly OverlayMarker[];meshEdit?:OverlayMeshEdit|null;weights?:OverlayWeights|null;anchors?:OverlayAnchors|null}
72
72
  /** Canvas-pixel geometry of a circle designation, the same numbers the editor hit-tests against. */
73
- export function projectCircle(project:OverlayProject,circle:Pick<OverlayCircle,'center'|'r'|'band'>):{center:OverlayPoint;pxR:number;pxBand:number}|null {
74
- const {x,y}=circle.center,center=project(x,y),edge=project(x+circle.r,y),top=project(x,y+circle.r+circle.band);
73
+ export function projectCircle(project:OverlayProject,circle:Pick<OverlayCircle,'center'|'r'|'band'|'ry'>):{center:OverlayPoint;pxR:number;pxBand:number;pxRy?:number}|null {
74
+ const {x,y}=circle.center,ry=circle.ry??circle.r,center=project(x,y),edge=project(x+circle.r,y),top=project(x,y+ry+circle.band);
75
75
  if(![center,edge,top].every(finite))return null;
76
76
  const pxR=Math.max(2,Math.hypot(edge.x-center.x,edge.y-center.y));
77
- return {center,pxR,pxBand:Math.max(pxR+2,Math.hypot(top.x-center.x,top.y-center.y))};
77
+ if(circle.ry===undefined)return {center,pxR,pxBand:Math.max(pxR+2,Math.hypot(top.x-center.x,top.y-center.y))};
78
+ // #315: an ellipse row — pxRy is its vertical core; pxBand stays the distance to the band's top, where its handle sits.
79
+ const low=project(x,y+ry);if(!finite(low))return null;
80
+ const pxRy=Math.max(2,Math.hypot(low.x-center.x,low.y-center.y));
81
+ return {center,pxR,pxRy,pxBand:Math.max(pxRy+2,Math.hypot(top.x-center.x,top.y-center.y))};
82
+ }
83
+ export interface CircleLabelInput {center:OverlayPoint;pxBand:number;width:number;height?:number;row?:number}
84
+ /**
85
+ * Circle coordinate label rects (#307): R (row 0 / image-left) anchors below-left of its outer ring, L (row 1 / image-right)
86
+ * anchors below-right of its outer ring, away from the other circle. If two rects would still intersect, the later one
87
+ * stacks vertically below the earlier one.
88
+ */
89
+ export function circleLabelRects(items:readonly CircleLabelInput[]):LabelBox[] {
90
+ const out:LabelBox[]=[];
91
+ for(let i=0;i<items.length;i++){
92
+ const item=items[i]!,w=item.width,h=item.height??15,other=items.length===2?items[1-i]:undefined;
93
+ const leftSide=item.row!==undefined?item.row===0:other?item.center.x<=other.center.x:true;
94
+ const x=items.length===1&&item.row===undefined?item.center.x-w/2:leftSide?item.center.x-w:item.center.x;
95
+ let box:LabelBox={x,y:item.center.y+item.pxBand+3,w,h};
96
+ while(out.some(p=>boxesIntersect(box,p))){const hit=out.find(p=>boxesIntersect(box,p))!;box={...box,y:hit.y+hit.h+2};}
97
+ out.push(box);
98
+ }
99
+ return out;
78
100
  }
79
101
  export interface OverlayRefresh extends OverlayView {player:OverlayPlayer|null;bones:readonly BoneOverlaySpec[];frame?:PosedFrame;selectedSlot?:string|null}
80
102
  const point=(x:number,y:number):OverlayPoint=>({x,y});
@@ -208,18 +230,32 @@ export class RigOverlays {
208
230
  if(region.name){ctx.font='600 11px ui-monospace, monospace';const width=ctx.measureText(region.name).width+8;ctx.fillStyle=c.labelBg;ctx.fillRect(top!.x-width/2,top!.y-24,width,15);ctx.fillStyle=region.stroke;ctx.fillText(region.name,top!.x-width/2+4,top!.y-13);}
209
231
  }
210
232
  }
211
- if(this.playerAvailable)for(const circle of circles){
212
- const at=projectCircle(project,circle);if(!at)continue;const {center,pxR,pxBand}=at,c=circle.colors;
213
- ctx.globalAlpha=.95;
214
- ctx.beginPath();ctx.setLineDash([5,4]);ctx.strokeStyle=c.stroke;ctx.lineWidth=1.6;ctx.arc(center.x,center.y,pxBand,0,Math.PI*2);ctx.stroke();
215
- ctx.beginPath();ctx.setLineDash([]);ctx.fillStyle=c.fill;ctx.lineWidth=2.2;ctx.arc(center.x,center.y,pxR,0,Math.PI*2);ctx.fill();ctx.stroke();
216
- if(!circle.handles)continue;
217
- ctx.globalAlpha=1;
218
- ctx.beginPath();ctx.moveTo(center.x-7,center.y);ctx.lineTo(center.x+7,center.y);ctx.moveTo(center.x,center.y-7);ctx.lineTo(center.x,center.y+7);ctx.stroke();
219
- for(const [x,y,fill,stroke] of [[center.x,center.y,c.handle,c.stroke],[center.x+pxR,center.y,c.stroke,c.ink],[center.x,center.y-pxBand,c.ink,c.stroke]] as const){ctx.beginPath();ctx.fillStyle=fill;ctx.strokeStyle=stroke;ctx.lineWidth=2;ctx.arc(x,y,4.5,0,Math.PI*2);ctx.fill();ctx.stroke();}
220
- if(circle.label){
221
- ctx.font='600 11px ui-monospace, monospace';const width=ctx.measureText(circle.label).width+8,lx=center.x-width/2,ly=center.y+pxBand+14+(circle.labelRow??0)*17;
222
- ctx.fillStyle=circle.flash?c.flash:c.labelBg;ctx.fillRect(lx,ly-11,width,15);ctx.fillStyle=circle.flash?c.ink:c.stroke;ctx.fillText(circle.label,lx+4,ly);
233
+ if(this.playerAvailable){
234
+ const drawnCircles=circles.flatMap(circle=>{const at=projectCircle(project,circle);return at?[{circle,at}]:[];});
235
+ for(const {circle,at} of drawnCircles){
236
+ const {center,pxR,pxBand}=at,pxRy=at.pxRy??pxR,c=circle.colors,ring=pxBand-pxRy;
237
+ ctx.globalAlpha=.95;
238
+ // #315: an ellipse row draws its own core and band ring; a clipped one is cut at its medial clip line.
239
+ const clipPx=circle.clipX===undefined?null:project(circle.clipX,circle.center.y).x;
240
+ ctx.save();
241
+ if(clipPx!==null&&Number.isFinite(clipPx)){ctx.beginPath();if(clipPx>center.x)ctx.rect(center.x-pxR-ring-4,center.y-pxBand-4,clipPx-(center.x-pxR-ring-4),2*pxBand+8);else ctx.rect(clipPx,center.y-pxBand-4,center.x+pxR+ring+4-clipPx,2*pxBand+8);ctx.clip();}
242
+ ctx.beginPath();ctx.setLineDash([5,4]);ctx.strokeStyle=c.stroke;ctx.lineWidth=1.6;ctx.ellipse(center.x,center.y,pxR+ring,pxBand,0,0,Math.PI*2);ctx.stroke();
243
+ ctx.beginPath();ctx.setLineDash([]);ctx.fillStyle=c.fill;ctx.lineWidth=2.2;ctx.ellipse(center.x,center.y,pxR,pxRy,0,0,Math.PI*2);ctx.fill();ctx.stroke();
244
+ ctx.restore();ctx.strokeStyle=c.stroke;ctx.lineWidth=2.2;ctx.setLineDash([]);
245
+ if(!circle.handles)continue;
246
+ ctx.globalAlpha=1;
247
+ ctx.beginPath();ctx.moveTo(center.x-7,center.y);ctx.lineTo(center.x+7,center.y);ctx.moveTo(center.x,center.y-7);ctx.lineTo(center.x,center.y+7);ctx.stroke();
248
+ for(const [x,y,fill,stroke] of [[center.x,center.y,c.handle,c.stroke],[center.x+pxR,center.y,c.stroke,c.ink],[center.x,center.y-pxBand,c.ink,c.stroke]] as const){ctx.beginPath();ctx.fillStyle=fill;ctx.strokeStyle=stroke;ctx.lineWidth=2;ctx.arc(x,y,4.5,0,Math.PI*2);ctx.fill();ctx.stroke();}
249
+ }
250
+ const labelled=drawnCircles.filter(({circle})=>circle.handles&&!!circle.label);
251
+ if(labelled.length){
252
+ ctx.globalAlpha=1;ctx.font='600 11px ui-monospace, monospace';
253
+ const rects=circleLabelRects(labelled.map(({circle,at})=>({center:at.center,pxBand:at.pxBand,width:ctx.measureText(circle.label!).width+8,row:circle.labelRow})));
254
+ labelled.forEach(({circle},i)=>{
255
+ const box=rects[i]!,c=circle.colors;
256
+ ctx.fillStyle=circle.flash?c.flash:c.labelBg;ctx.fillRect(box.x,box.y,box.w,box.h);
257
+ ctx.fillStyle=circle.flash?c.ink:c.stroke;ctx.fillText(circle.label!,box.x+4,box.y+11);
258
+ });
223
259
  }
224
260
  }
225
261
  if(this.playerAvailable){
package/web/styles.css CHANGED
@@ -218,11 +218,14 @@ footer.status-bar{flex-wrap:nowrap}
218
218
  .review-dialog-header h2{margin:0;font-size:14px;font-weight:600;color:var(--fg-strong)}
219
219
  .review-dialog-header .hint{margin:0;flex:1;min-width:0}
220
220
  .review-dialog-body{flex:1;min-height:0;overflow:auto;padding:14px 16px;overscroll-behavior:contain}
221
- .review-dialog-actions{flex:none;display:flex;align-items:center;gap:12px;padding:10px 14px;border-top:1px solid var(--border)}
222
- .review-message{flex:1;min-width:0;font-size:11px;color:var(--fg-soft);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
221
+ .review-dialog-actions{flex:none;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;padding:10px 14px;border-top:1px solid var(--border)}
222
+ .review-message{flex:1 1 200px;min-width:0;font-size:11px;color:var(--fg-soft);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
223
223
  .review-message.error{color:var(--fail)}
224
224
  .review-draft-state{font-size:11px;color:var(--warn)}
225
225
  .review-draft-state:empty{display:none}
226
+ .review-draft-recovery{display:inline-flex;align-items:center;flex-wrap:wrap;gap:6px}
227
+ .review-draft-recovery:empty{display:none}
228
+ .review-draft-recovery button{font-size:11px;padding:2px 6px}
226
229
  .review-dialog .provenance{margin-top:10px}
227
230
  .review-dialog .review-summary>label{display:block;font-size:11px;margin:10px 0 5px}
228
231
  .review-dialog .report-panel{padding:10px 0}
@@ -246,7 +249,7 @@ footer.status-bar{flex-wrap:nowrap}
246
249
  .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)}.transport.has-idle-blink{padding-top:22px}.idle-blink-strip{position:absolute;height:12px;pointer-events:none}.idle-blink-marker{position:absolute;top:0;width:14px;height:12px;margin-left:-7px;padding:0;border:0;background:transparent;color:var(--link);font-size:10px;line-height:12px;pointer-events:auto;cursor:ew-resize;touch-action:none}.idle-blink-marker.pending{color:var(--warn)}.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}
247
250
  .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)}
248
251
  /* Inspector block row (#124): sticky at the top of each section's scroll (the section pads 12px 15px), one line that scrolls sideways when narrow. */
249
- .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}
252
+ .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}
250
253
  /* Setup · Weights (#107): the weight ramp (low → half → high) and max influence's bone colours. Drawn on the stage, which stays dark, so both schemes carry the same values. */
251
254
  :root{--rv-weight-0:#3d1a78;--rv-weight-half:#e0573a;--rv-weight-1:#fcef6c;--rv-weight-bone-1:#00e5ff;--rv-weight-bone-2:#ff7ae0;--rv-weight-bone-3:#52ff88;--rv-weight-bone-4:#ffb020;--rv-weight-bone-5:#a98bff;--rv-weight-bone-6:#ff5252}
252
255
  :root[data-theme=light]{--rv-weight-0:#3d1a78;--rv-weight-half:#e0573a;--rv-weight-1:#fcef6c;--rv-weight-bone-1:#00e5ff;--rv-weight-bone-2:#ff7ae0;--rv-weight-bone-3:#52ff88;--rv-weight-bone-4:#ffb020;--rv-weight-bone-5:#a98bff;--rv-weight-bone-6:#ff5252}