@rig-c/review 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/DESIGN.md +38 -14
- package/docs/PANELS.md +37 -13
- package/docs/PARTS_VIEW.md +79 -0
- package/docs/REVIEW_PACKAGE.md +66 -0
- package/package.json +1 -1
- package/src/applied-context.ts +17 -4
- package/src/front.ts +5 -1
- package/src/parts-comment-crops.ts +3 -1
- package/src/parts-comparison.ts +25 -2
- package/src/parts-server.ts +11 -2
- package/src/parts-view.ts +37 -5
- package/src/rebuild.ts +84 -1
- package/src/retune-check.ts +1 -1
- package/src/server.ts +4 -2
- package/src/stage-parts.ts +81 -4
- package/web/catalog-en.ts +38 -1
- package/web/catalog-ko.ts +38 -1
- package/web/chest-editor.ts +3 -0
- package/web/main.ts +59 -13
- package/web/parts.css +7 -0
- package/web/parts.html +2 -1
- package/web/parts.ts +87 -16
- package/web/rebuild-client.ts +15 -7
- package/web/stage-nav.ts +21 -6
package/web/main.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {bindDensityStrip,type DensityStripPanel,type DensityStripViewLike} from
|
|
|
18
18
|
import {densityField,densityPath} from '../src/density-strip.ts';
|
|
19
19
|
import {assertMeshPatch,countsText,meshApplyOutcome,meshPatchOps,setEntryValue,triangleAgreement,type MeshEntry} from '../src/mesh-entry.ts';
|
|
20
20
|
import {worstLine} from '../src/readings.ts';
|
|
21
|
-
import {chestOverlayPolygons,chestRegionRows,chestRowId,evaluateChestForm} from './chest-regions-tool.ts';
|
|
21
|
+
import {chestOverlayPolygons,chestInputIds,chestRegionRows,chestRowId,evaluateChestForm} from './chest-regions-tool.ts';
|
|
22
22
|
import {bindChestEditor,canvasToCrop,bustLabel,bustSides,chestPoseOffset,LANDMARKS,landmarkInputId,posedChestMapping,rowShape,type ChestEditor,type LandmarkKey} from './chest-editor.ts';
|
|
23
23
|
import {bindMeshEditor,meshEditSource,sha256Hex,type MeshEditor} from './mesh-editor.ts';
|
|
24
24
|
import {bindWeightsView,setupPoseMesh,type WeightsView} from './weights-view.ts';
|
|
@@ -29,7 +29,7 @@ import {bindClothPanel,type ClothPanel} from './cloth-panel.ts';
|
|
|
29
29
|
import {animationAppliedRecord,animationOutcomeLine,retargetAppliedRecord,retargetOutcomeLine,stripPendingAfter,type AnimationJobView,type AnimationRequestBody,type AnimationSourceOp,type StageChange,type AppliedAnimation,type AppliedRetarget,type RetargetJobView,type RetargetRequestBody} from './rebuild-client.ts';
|
|
30
30
|
import {bindRetargetPanel,type PoseMap,type RetargetPanel} from './retarget-panel.ts';
|
|
31
31
|
import type {RetargetFlags} from '../src/retarget.ts';
|
|
32
|
-
import {historyRow,isPatchJob,recordFor,refusedText,restoredOutcomeForJob,retargetStage,undoControl,type AppliedHistoryView,type UndoView,type AnyJobView,appliedRecord,deltaAppliedRecord,deltaOutcomeLine,chestSeed,designatedRegions,handoffText,landmarksRequest,noContourReason,seedLandmarks,makePatch,outcomeLine,patchAppliedRecord,patchOutcomeLine,pickBustPart,pickPart,runRebuild,seedFields,stageModel,type AppliedDelta,type AppliedPatch,type AppliedRecord,type DeltaJobView,type DeltaRequestBody,type ConfigPatch,type PatchJobView,type RebuildJobView,type RebuildRefusal,type RebuildRequestBody,type RebuildStatusView} from './rebuild-client.ts';
|
|
32
|
+
import {historyRow,isPatchJob,recordFor,refusedText,restoredOutcomeForJob,retargetStage,undoControl,type AppliedHistoryView,type UndoView,type AnyJobView,appliedRecord,deltaAppliedRecord,deltaOutcomeLine,chestPartFields,chestStatusForPart,chestSeed,designatedRegions,handoffText,landmarksRequest,noContourReason,seedLandmarks,makePatch,outcomeLine,patchAppliedRecord,patchOutcomeLine,pickBustPart,pickPart,runRebuild,seedFields,stageModel,type AppliedDelta,type AppliedPatch,type AppliedRecord,type DeltaJobView,type DeltaRequestBody,type ConfigPatch,type PatchJobView,type RebuildJobView,type RebuildRefusal,type RebuildRequestBody,type RebuildStatusView} from './rebuild-client.ts';
|
|
33
33
|
import {meshEditBinding,meshEditText,type MeshEditDocument} from '../src/mesh-edit.ts';
|
|
34
34
|
import {chestRegionsBinding,cropWorldMapping,type CropWorldMapping} from '../src/chest-regions.ts';
|
|
35
35
|
import {bindWorkspaceUI,selectedInspector,type WorkspaceUI} from './workspace-ui.ts';
|
|
@@ -123,7 +123,7 @@ let playbackIntent=0,desiredPlay=false,seekingControl=false;
|
|
|
123
123
|
let parts:PartExplorer|null=null;
|
|
124
124
|
let animationPanel:AnimationInspectionPanel|null=null;
|
|
125
125
|
let inspectionSourceState:'ready'|'pending'|'failed'='ready';
|
|
126
|
-
function refreshAnimationInspection(){if(inspectionSourceState!=='ready'){animationPanel?.unavailable(`ANIMATION_INSPECTION_SOURCE_${inspectionSourceState.toUpperCase()}: current model source is unavailable`);return;}animationPanel?.update(
|
|
126
|
+
function refreshAnimationInspection(){if(inspectionSourceState!=='ready'){animationPanel?.unavailable(`ANIMATION_INSPECTION_SOURCE_${inspectionSourceState.toUpperCase()}: current model source is unavailable`);return;}animationPanel?.update(time,duration);animationPanel?.model(partModel,player?.current??'');animationPanel?.update(time,duration);}
|
|
127
127
|
let overlays:RigOverlays|null=null;
|
|
128
128
|
let chestEditor:ChestEditor|null=null;
|
|
129
129
|
let meshEditor:MeshEditor|null=null;
|
|
@@ -875,7 +875,7 @@ function bind(): void {
|
|
|
875
875
|
} catch (error) { message(`Submission failed: ${errorText(error)}`, true); } finally { saving = false; updateSavedState(); }
|
|
876
876
|
};
|
|
877
877
|
// Saved browser defaults seed a new inspection; explicit links and source drafts restore over them.
|
|
878
|
-
viewDisposers.push(bindStageNav({model:!!data.manifest.model,setup:()=>showInspector('rig')}));
|
|
878
|
+
viewDisposers.push(bindStageNav({model:!!data.manifest.model,setup:()=>showInspector('rig'),draftBuild:()=>appliedOnStage?.buildId??'inspected',correction:openStageCorrection}));
|
|
879
879
|
workspace=bindWorkspaceUI({changed:fitCamera,defaultTheme:theme=>appearance?.set(theme),currentTheme:()=>appearance?.get()});
|
|
880
880
|
viewport.state.cameraSync=workspace.defaults().defaultCameraSync;input('camera-sync').checked=viewport.state.cameraSync;input('idle-repeat').checked=workspace.defaults().defaultIdleRepeat;
|
|
881
881
|
appearance=bindAppearance(select('settings-theme'),workspace.defaults().theme);
|
|
@@ -949,7 +949,7 @@ async function start(): Promise<void> {
|
|
|
949
949
|
// Checkpoints and reference fold away when the package supplies neither.
|
|
950
950
|
(el('package-context') as HTMLDetailsElement).open = data.manifest.checkpoints.length > 0 || data.manifest.references.length > 0;
|
|
951
951
|
const sourceFiles = el('source-files'); for (const file of data.manifest.authoring) { const a = document.createElement('a'); a.href = assetUrl(file.path); a.textContent = file.label; a.className = 'source-link'; a.target = '_blank'; a.rel = 'noopener'; sourceFiles.append(a); } if (!data.manifest.authoring.length) sourceFiles.textContent = 'No source files supplied';
|
|
952
|
-
populateChestBones(); bind(); parts=new PartExplorer(el('workspace-left'),el('selected-part'),previous=>{if(player&&inspectionSourceState==='ready')animationPanel?.capture(player,parts?.frame('single'));else animationPanel?.capture(null,undefined);weightsView?.refresh();redrawOverlay(true);meshEditor?.selectionChanged();const part=parts?.value();animationPanel?.fromParts(part?.slot??null);meshPanel?.select(part?.slot??null);requirementsPanel?.selectionChanged();renderDropNotices();if(part){viewport.state.activeCamera='rig';if(view==='reference')setView('rig');if(selectedInspector(document)!=='playback')showInspector('rig');renderCameraControls();}if(!viewport.state.cameraRestoring&&(previous?.side!==part?.side||previous?.slot!==part?.slot))cameraAction(()=>fitActiveCamera(part?'rig':availableCamera()));persistence?.save();},part=>{select('feedback-target-kind').value='slot';renderFeedbackTargets(true);input('feedback-target-name').value=part.slot;showInspector('feedback');}); animationPanel=new AnimationInspectionPanel({host:el('animation-inspection'),stage:el('rig-viewport'),project:(x,y)=>rigProject()(x,y),enabled:()=>inspectionSourceState==='ready'&&selectedInspector(document)==='playback',pause,preview:fn=>{animAdjust=fn;if(!player)return;player.adjust=composeAdjust(composeAdjust(composeAdjust(idleAdjust,dialAdjust),turnAdjust),animAdjust);if(!inDrawRig&&player.current&&!playing){player.seek(time);drawRig(()=>player!.draw());}},apply:ops=>applyAnimation(ops),reset:()=>resetAnimationBuild(),seek:exact=>{if(!Number.isFinite(exact)||exact<0||exact>duration){message('KEY_TIME_OUT_OF_DOMAIN: no substitute time was used.',true);return;}seekMarker(animation,exact,'Stored key');},select:value=>{const slot=value?.kind==='slot'?value.name:null;if((parts?.value()?.slot??null)!==slot)parts?.select(slot?{side:'single',slot,mode:parts?.value()?.mode??'context'}:null);parts?.highlightBone(value?.kind==='bone'?value.name:null);redrawOverlay(false);}});viewDisposers.push(()=>animationPanel?.dispose()); updateStripControls(); stripStatus('Choose the entered start–end frames or all feedback ranges to download. Unsubmitted feedback is included; exporting does not submit the review.'); renderFeedbackTargets(true); renderFeedbackRange(); renderCheckpoints(); renderProposals(); renderProvenance(); updateSavedState(); renderCues(); initReport();
|
|
952
|
+
populateChestBones(); bind(); parts=new PartExplorer(el('workspace-left'),el('selected-part'),previous=>{if(player&&inspectionSourceState==='ready')animationPanel?.capture(player,parts?.frame('single'));else animationPanel?.capture(null,undefined);weightsView?.refresh();redrawOverlay(true);meshEditor?.selectionChanged();const part=parts?.value();if(stageCorrectionPart&&!stageCorrectionRebinding&&(part?.slot??null)!==stageCorrectionPart){stageCorrectionPart=null;document.getElementById('stage-draft-label')?.remove();}animationPanel?.fromParts(part?.slot??null);meshPanel?.select(part?.slot??null);requirementsPanel?.selectionChanged();renderDropNotices();if(part){viewport.state.activeCamera='rig';if(view==='reference')setView('rig');if(selectedInspector(document)!=='playback')showInspector('rig');renderCameraControls();}if(!viewport.state.cameraRestoring&&(previous?.side!==part?.side||previous?.slot!==part?.slot))cameraAction(()=>fitActiveCamera(part?'rig':availableCamera()));persistence?.save();},part=>{select('feedback-target-kind').value='slot';renderFeedbackTargets(true);input('feedback-target-name').value=part.slot;showInspector('feedback');}); animationPanel=new AnimationInspectionPanel({host:el('animation-inspection'),stage:el('rig-viewport'),project:(x,y)=>rigProject()(x,y),enabled:()=>inspectionSourceState==='ready'&&selectedInspector(document)==='playback',pause,preview:fn=>{animAdjust=fn;if(!player)return;player.adjust=composeAdjust(composeAdjust(composeAdjust(idleAdjust,dialAdjust),turnAdjust),animAdjust);if(!inDrawRig&&player.current&&!playing){player.seek(time);drawRig(()=>player!.draw());}},apply:ops=>applyAnimation(ops),reset:()=>resetAnimationBuild(),seek:exact=>{if(!Number.isFinite(exact)||exact<0||exact>duration){message('KEY_TIME_OUT_OF_DOMAIN: no substitute time was used.',true);return;}seekMarker(animation,exact,'Stored key');},select:value=>{const slot=value?.kind==='slot'?value.name:null;if((parts?.value()?.slot??null)!==slot)parts?.select(slot?{side:'single',slot,mode:parts?.value()?.mode??'context'}:null);parts?.highlightBone(value?.kind==='bone'?value.name:null);redrawOverlay(false);}});viewDisposers.push(()=>animationPanel?.dispose()); updateStripControls(); stripStatus('Choose the entered start–end frames or all feedback ranges to download. Unsubmitted feedback is included; exporting does not submit the review.'); renderFeedbackTargets(true); renderFeedbackRange(); renderCheckpoints(); renderProposals(); renderProvenance(); updateSavedState(); renderCues(); initReport();
|
|
953
953
|
const requestedId = new URLSearchParams(location.search).get('checkpoint'),initial=initialReviewSelection(data.manifest,requestedId,data.explicitReference?.id,data.initialAnimation??undefined),first=initial.checkpoint;
|
|
954
954
|
rigInput=data.manifest.model?{state:'pending'}:{state:'absent'};renderLayout();
|
|
955
955
|
if(initial.referenceId){select('reference-select').value=initial.referenceId;await showReference(initial.referenceId);}
|
|
@@ -1013,7 +1013,7 @@ async function playPreview():Promise<void> {
|
|
|
1013
1013
|
function localDraft():boolean{return !!comments?.draft()||dirty||!!input('feedback-summary').value.trim()||!!input('feedback-start').value.trim()||!!input('feedback-end').value.trim()||!!select('feedback-category').value||!!input('feedback-target-name').value.trim()&&input('feedback-target-name').value!==data.manifest.id;}
|
|
1014
1014
|
function controlState():ControlInspection {
|
|
1015
1015
|
const box=assets?.stage??player?.bounds(),center=box?{x:box.x+box.width/2,y:box.y+box.height/2}:null;
|
|
1016
|
-
return {part:parts?.value()??null,partGeneration:parts?.observation()?.generation??null,view:numericView(),theme:appearance?.get()??'system',layout:'auto',effectiveLayout:el('stage-layout').dataset.orientation==='vertical'?'column':'row',cameras:{rig:{zoom:player?viewport.state.zoom:1,pan:{x:center&&viewport.state.cameraCenter?(center.x-viewport.state.cameraCenter.x)*viewport.state.rigScale:0,y:center&&viewport.state.cameraCenter?(viewport.state.cameraCenter.y-center.y)*viewport.state.rigScale:0}},reference:{zoom:referenceSize?viewport.state.referenceZoom:1,pan:{x:referenceSize&&viewport.state.referenceCenter?(referenceSize.width/2-viewport.state.referenceCenter.x)*viewport.state.referenceScale:0,y:referenceSize&&viewport.state.referenceCenter?(referenceSize.height/2-viewport.state.referenceCenter.y)*viewport.state.referenceScale:0}}},animation:animation||null,time
|
|
1016
|
+
return {part:parts?.value()??null,partGeneration:parts?.observation()?.generation??null,view:numericView(),theme:appearance?.get()??'system',layout:'auto',effectiveLayout:el('stage-layout').dataset.orientation==='vertical'?'column':'row',cameras:{rig:{zoom:player?viewport.state.zoom:1,pan:{x:center&&viewport.state.cameraCenter?(center.x-viewport.state.cameraCenter.x)*viewport.state.rigScale:0,y:center&&viewport.state.cameraCenter?(viewport.state.cameraCenter.y-center.y)*viewport.state.rigScale:0}},reference:{zoom:referenceSize?viewport.state.referenceZoom:1,pan:{x:referenceSize&&viewport.state.referenceCenter?(referenceSize.width/2-viewport.state.referenceCenter.x)*viewport.state.referenceScale:0,y:referenceSize&&viewport.state.referenceCenter?(referenceSize.height/2-viewport.state.referenceCenter.y)*viewport.state.referenceScale:0}}},animation:animation||null,time,playing,loop:canRepeatIdle()?'idle':'off',layers:{images:!!player&&layers.images,meshes:!!player&&layers.mesh,bones:!!player&&layers.bones},ready:!!data,seeking:seekingControl||!!video?.seeking||!!persistence?.restoring(),dirty:localDraft(),busy:saving||stripBusy||!!persistence?.restoring(),feedbackEligible:!persistence?.restoring(),comparison:controlComparison(layoutEligibility()),capabilities:{camera:!!player,referenceCamera:!!referenceSize,animation:!!player,time:duration>0,playback:duration>0,layers:{images:!!player,meshes:!!player,bones:!!player}}};
|
|
1017
1017
|
}
|
|
1018
1018
|
async function applyControl(command:ControlCommand,signal:AbortSignal):Promise<void> {
|
|
1019
1019
|
if(signal.aborted)throw new Error('CONTROL_SUPERSEDED');
|
|
@@ -1075,7 +1075,8 @@ async function decodedControlTime(media:HTMLVideoElement,target:number,signal:Ab
|
|
|
1075
1075
|
}
|
|
1076
1076
|
function numericView():ControlView {return viewport.numericView();}
|
|
1077
1077
|
function inspectionBinding():InspectionBinding{return {mode:'single',sourceHash:data.sourceHash,rigs:[data.reviewedSource.rig?.sha256??null]};}
|
|
1078
|
-
|
|
1078
|
+
// Persist the displayed inspection clock; the runtime clock accumulates across idle loops for physics.
|
|
1079
|
+
function inspectionBookmark():InspectionBookmark {return {schema:'rig-review-inspection/1',binding:inspectionBinding(),animation:animation||null,time,theme:appearance?.get()??'system',layers:{images:layers.images,meshes:layers.mesh,bones:layers.bones},view:numericView(),selection:{...(turnPad?{turn:turnPad.snapshot()}:{}),part:parts?.value()??null,view,checkpoint:checkpoint?.id??null,reference:select('reference-select').value||null,person:selectedPerson||null,inspector:selectedInspector()??'view',partSet:select('part-set').disabled?null:select('part-set').value,axis:axisInspection?{id:select('axis-select').value,value:Number(input('axis-value').value)}:null}};}
|
|
1079
1080
|
async function restoreInspection(bookmark:InspectionBookmark,signal:AbortSignal,preserveSeconds=false):Promise<void> {
|
|
1080
1081
|
await restoreTransaction(()=>prepareInspection(bookmark,signal),()=>({bookmark:inspectionBookmark(),inputs:captureInputs()}),()=>applyInspection(bookmark,signal,preserveSeconds),async previous=>{await applyInspection(previous.bookmark,new AbortController().signal);restoreInputs(previous.inputs);renderFeedbackRange();});
|
|
1081
1082
|
}
|
|
@@ -1426,13 +1427,30 @@ async function applyMeshDelta(doc:MeshEditDocument,line:(text:string)=>void):Pro
|
|
|
1426
1427
|
}catch(error){const text=`REBUILD_FAILED: ${errorText(error)}`;message(text,true);return {built:false,text,error:true};}
|
|
1427
1428
|
finally{rebuildBusy=false;rebuildState();}
|
|
1428
1429
|
}
|
|
1430
|
+
let chestFormPart:string|null=null;
|
|
1431
|
+
/** Rebinding is explicit: defaults and both modes belong to the new part, while reopening the same part keeps edits. */
|
|
1432
|
+
function rebindChestPart(status:RebuildStatusView,part:string):void {
|
|
1433
|
+
if(chestFormPart===part)return;
|
|
1434
|
+
const next=chestPartFields(status,part);
|
|
1435
|
+
const ids=[...chestInputIds,...LANDMARKS.flatMap(({key})=>['x','y'].map(axis=>`lm-${key}-${axis}`)),'lm-alpha','lm-clearance','lm-bone_r','lm-bone_l','bust-mode'];
|
|
1436
|
+
for(const id of ids){const node=document.getElementById(id) as HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement|null;if(!node)continue;
|
|
1437
|
+
if(node instanceof HTMLInputElement){node.value=node.defaultValue;node.checked=node.defaultChecked;}
|
|
1438
|
+
else if(node instanceof HTMLTextAreaElement)node.value=node.defaultValue;
|
|
1439
|
+
else node.value=[...node.options].find(option=>option.defaultSelected)?.value??node.options[0]?.value??'';
|
|
1440
|
+
}
|
|
1441
|
+
for(const [id,value] of Object.entries(next.fields)){const node=document.getElementById(id) as HTMLInputElement|HTMLSelectElement|null;if(!node)continue;if(node instanceof HTMLInputElement&&node.type==='checkbox')node.checked=value==='true';else node.value=value;}
|
|
1442
|
+
input('bust-mode').value=next.mode;chestFormPart=part;chestEditor?.rebind();
|
|
1443
|
+
const refusal=next.seed.refusals.join(' · ');chestEditor?.notify(refusal||null,!!refusal,next.seed.refusals);
|
|
1444
|
+
el('chest-regions').dispatchEvent(new Event('input',{bubbles:true}));
|
|
1445
|
+
}
|
|
1429
1446
|
/** `GET /api/rebuild`: whether Apply can run, and the producer config's regions to start an untouched editor from. */
|
|
1430
1447
|
async function loadRebuildStatus():Promise<RebuildStatusView|null> {
|
|
1431
1448
|
try{rebuildStatus=await api<RebuildStatusView>('/api/rebuild');}catch(error){rebuildStatus=null;const reason=`REBUILD_STATUS_UNAVAILABLE: ${errorText(error)}`;chestEditor?.notify(reason,true);animationPanel?.loadSource(null,reason);return null;}
|
|
1432
1449
|
const seed={...(seedFields(rebuildStatus,chestField)??{}),...(seedLandmarks(rebuildStatus,chestField)??{})};
|
|
1433
1450
|
if(Object.keys(seed).length){for(const [id,value] of Object.entries(seed)){const node=document.getElementById(id) as HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement|null;if(!node)continue;if(node instanceof HTMLInputElement&&node.type==='checkbox')node.checked=value==='true';else node.value=value;}el('chest-regions').dispatchEvent(new Event('input',{bubbles:true}));}
|
|
1434
1451
|
// #315: a config polygon the editor cannot read as an ellipse is named, never shown as an empty row.
|
|
1435
|
-
|
|
1452
|
+
chestFormPart??=chestSeed(rebuildStatus).part;
|
|
1453
|
+
const refused=chestSeed(chestStatusForPart(rebuildStatus,chestFormPart)).refusals;if(refused.length)chestEditor?.notify(refused.join(' · '),true,refused);
|
|
1436
1454
|
// #342: a rig with no contour mesh disables the chest tools before use and says why in words about the rig.
|
|
1437
1455
|
const noContour=noContourReason(rebuildStatus);chestEditor?.unavailable(noContour?.text??null);
|
|
1438
1456
|
if(noContour)chestEditor?.notify(noContour.text,false,noContour.lines);else if(!rebuildStatus.available)chestEditor?.notify(rebuildStatus.reason,!rebuildStatus.viewOnly);
|
|
@@ -1468,7 +1486,7 @@ function chestPartForNotice():string|null {
|
|
|
1468
1486
|
const read=chestEditor.landmarks();
|
|
1469
1487
|
return 'derived' in read?pickBustPart(rebuildStatus,read.derived.regions):pickBustPart(rebuildStatus,[]);
|
|
1470
1488
|
}
|
|
1471
|
-
const designated=designatedRegions(chestField,rebuildStatus?chestSeed(rebuildStatus):null);
|
|
1489
|
+
const designated=designatedRegions(chestField,rebuildStatus?chestSeed(chestStatusForPart(rebuildStatus,chestFormPart)):null);
|
|
1472
1490
|
return 'regions' in designated?pickPart(rebuildStatus,designated.regions):rebuildStatus.parts.length===1?rebuildStatus.parts[0]!.name:null;
|
|
1473
1491
|
}
|
|
1474
1492
|
function renderDropNotices():void {
|
|
@@ -1603,7 +1621,9 @@ async function undoApply():Promise<UndoView|null> {
|
|
|
1603
1621
|
async function applyRebuild():Promise<void> {
|
|
1604
1622
|
if(rebuildBusy)return;
|
|
1605
1623
|
if(readOnly){chestEditor?.notify(readOnly,true);return;}
|
|
1606
|
-
const
|
|
1624
|
+
const loadedStatus=rebuildStatus??await loadRebuildStatus();
|
|
1625
|
+
const status=loadedStatus?chestStatusForPart(loadedStatus,stageCorrectionPart):loadedStatus;
|
|
1626
|
+
if(stageCorrectionPart&&parts?.value()?.slot!==stageCorrectionPart){chestEditor?.notify('STAGE_DRAFT_MISMATCH',true);return;}
|
|
1607
1627
|
if(!status||!status.available||!status.inputs){const noContour=status?noContourReason(status):null,reason=noContour?.text??status?.reason??'REBUILD_STATUS_UNAVAILABLE';chestEditor?.notify(reason,!noContour,noContour?.lines??[reason]);message(reason,!noContour);return;}
|
|
1608
1628
|
let part:string,body:RebuildRequestBody;const lines:string[]=[];
|
|
1609
1629
|
if(chestEditor?.mode()==='landmarks'){
|
|
@@ -2101,7 +2121,9 @@ async function resetRebuild(world:StageWorld|null=null):Promise<void> {
|
|
|
2101
2121
|
*/
|
|
2102
2122
|
let stageSource:{url:string;prefix:string;hash:string}|null=null;
|
|
2103
2123
|
async function swapRig(modelUrl:string,prefix:string,sha256:string,world:StageWorld|null=null):Promise<void> {
|
|
2104
|
-
|
|
2124
|
+
stageCorrectionRebinding++;try{
|
|
2125
|
+
const keepPart=stageCorrectionPart?parts?.value():null;
|
|
2126
|
+
const keepAnimation=animation,keepTime=time,wasPlaying=playing,keepSet=select('part-set').disabled?'':select('part-set').value;
|
|
2105
2127
|
inspectionSourceState='pending';partModel=null;pause();refreshAnimationInspection();
|
|
2106
2128
|
const next=await loadModel({modelUrl,setsUrl:null,resolvePage:(name,url)=>{const target=new URL(name,url);if(target.origin!==location.origin||!target.pathname.startsWith(prefix))throw new Error(`Model page escapes its build: ${name}`);return target.href;}}).catch(error=>{inspectionSourceState='failed';refreshAnimationInspection();throw error;});
|
|
2107
2129
|
physicsPanel?.clearPreview();
|
|
@@ -2122,10 +2144,12 @@ async function swapRig(modelUrl:string,prefix:string,sha256:string,world:StageWo
|
|
|
2122
2144
|
// when none was staged — and nothing claims a clip the stage is not drawing.
|
|
2123
2145
|
else{drawRig(()=>player!.draw());animation='';duration=0;time=0;select('animation-select').value='';renderTransport();renderCues();renderIdle();}
|
|
2124
2146
|
if(environmentApplied())applyEnvironment();
|
|
2147
|
+
if(keepPart&&parts&&inspectionSourceState==='ready'){try{parts.select({side:keepPart.side,slot:keepPart.slot,mode:keepPart.mode});}catch{message('STAGE_DRAFT_MISMATCH',true);}}
|
|
2125
2148
|
updateChestMapping();fitCamera();
|
|
2126
2149
|
// The preview (#104) drives the new player once its bone setups are read (an idle Apply cleared it first).
|
|
2127
2150
|
stageDocumentSet=true;void loadModelDocument(modelUrl,sha256).then(loaded=>{if(loaded.ok&&stageModelHash===sha256)idlePanel?.model(boneSetup(loaded.document));});
|
|
2128
2151
|
if(wasPlaying)void playPreview();
|
|
2152
|
+
}finally{stageCorrectionRebinding--;}
|
|
2129
2153
|
}
|
|
2130
2154
|
/**
|
|
2131
2155
|
* Mesh Apply (#106): the pending `meshes.<part>` entry becomes one config patch — `replace /meshes/<part>` and nothing
|
|
@@ -2286,11 +2310,33 @@ function setupComments():void {
|
|
|
2286
2310
|
comments=bindStageComments({toolbar:el('stage-comment').parentElement!,viewports:{rig:el('rig-viewport'),reference:el('reference-viewport')},
|
|
2287
2311
|
pose:view=>{
|
|
2288
2312
|
if(view!=='rig'&&view!=='reference')return null;const workspaceMode=document.querySelector<HTMLElement>('[data-mode][aria-pressed="true"]')?.dataset.mode;if(workspaceMode!=='rig'&&workspaceMode!=='playback')return null;const camera=numericView().cameras[view],pane=el(view+'-viewport');if(!camera||pane.clientWidth<=0||pane.clientHeight<=0)return null;
|
|
2289
|
-
const renderer=player?.renderer;const current=
|
|
2313
|
+
const renderer=player?.renderer;const current=time,index=frameAtTime(activeFrameClock(),current),referenceId=view==='reference'?select('reference-select').value||null:null,referenceHash=referenceId?data.referenceHashes?.[referenceId]??(data.explicitReference?.id===referenceId?data.explicitReference.sha256:null):null;
|
|
2290
2314
|
return {mode:workspaceMode==='playback'?'animate':'setup',capture:{pane,root:view==='rig'?el('rig-root'):undefined,images:view==='reference'||layers.images,canvas:view==='rig'&&renderer instanceof CanvasRenderer?renderer.canvas:undefined,backend:renderer instanceof CanvasRenderer?renderer.backendActive:renderer?.meshBackendActive??'canvas2d'},camera,frame:index===null?null:{index,basis:'producer'},...(index===null?{timeBasis:timeOnlyBasis}:{}),time:current,animation:animation||null,turn:turnPad?.snapshot()??null,sourceHash:data.sourceHash,modelHash:view==='reference'?null:stageModelHash,referenceHash,referenceId,rig:data.manifest.id,...(view==='reference'?{media:video??el('reference-content').querySelector('img')??undefined}:{posed:parts?.frame('single'),assets:assets??undefined})} as CommentPose;
|
|
2291
2315
|
},
|
|
2292
|
-
pause:async()=>{const running=playing||!!video&&!video.paused;pause();if(running&&video&&video.readyState>=1){seekingControl=true;try{await inspectControlTime(
|
|
2316
|
+
pause:async()=>{const running=playing||!!video&&!video.paused;pause();if(running&&video&&video.readyState>=1){seekingControl=true;try{await inspectControlTime(time,new AbortController().signal);}finally{seekingControl=false;}}if(turnPad)turnPad.restore({...turnPad.snapshot(),held:true},false);},bookmark:inspectionBookmark,restore:(b,timed)=>restoreInspection(parseBookmark(b,inspectionBinding()),new AbortController().signal,!!timed),feedback:()=>session.feedback,
|
|
2293
2317
|
locked:id=>!!submittedBaseline?.updatedAt&&submittedBaseline.feedback.some(f=>f.id===id),add:f=>session.feedback.push(f),changed:()=>{markDirty();renderProposals();persistence?.save();},error:value=>message(value,true),
|
|
2294
2318
|
refusal:commentCaptureRefusal,blocked:()=>saving||!!persistence?.restoring()||seekingControl||!!video?.seeking||!!rebuildBusy||!!appliedOnStage,shortcutBlocked:()=>!!meshEditor?.active()
|
|
2295
2319
|
});
|
|
2296
2320
|
}
|
|
2321
|
+
|
|
2322
|
+
/** Open the existing precision instruments only after re-reading the same displayed draft binding. */
|
|
2323
|
+
let stageCorrectionPart:string|null=null,stageCorrectionRebinding=0;
|
|
2324
|
+
async function openStageCorrection(request:{part:string;sourceHash:string;buildId:string;instrument:string}):Promise<void>{
|
|
2325
|
+
const buildId=appliedOnStage?.buildId??'inspected';
|
|
2326
|
+
if(request.buildId!==buildId)throw new Error('STAGE_DRAFT_STALE');
|
|
2327
|
+
const data=await api<{sourceHash:string;draft?:{buildId:string;mappings:{part:string;slot:string;skin:string;attachment:string}[]}}>('/api/stage-parts',{headers:{'X-Review-Stage-Build':buildId}});
|
|
2328
|
+
const mapping=data.draft?.mappings.find(m=>m.part===request.part);
|
|
2329
|
+
if(!mapping||data.sourceHash!==request.sourceHash||data.draft?.buildId!==buildId||mapping.slot!==mapping.part)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2330
|
+
pause();seek(0);showInspector('rig');parts?.select({side:'single',slot:mapping.slot,mode:'context'});meshPanel?.select(mapping.part);
|
|
2331
|
+
const identity=parts?.value()?.identity;if(!identity||identity.skin!==mapping.skin||identity.attachment!==mapping.attachment)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2332
|
+
const status=rebuildStatus??await loadRebuildStatus();
|
|
2333
|
+
if(!status)throw new Error('REBUILD_STATUS_UNAVAILABLE');
|
|
2334
|
+
if(request.instrument==='chest'&&!status.parts.some(part=>part.name===mapping.part))throw new Error(`REBUILD_PART_NOT_CONTOUR: ${mapping.part}`);
|
|
2335
|
+
rebindChestPart(status,mapping.part);
|
|
2336
|
+
stageCorrectionPart=mapping.part;
|
|
2337
|
+
let label=document.getElementById('stage-draft-label');if(!label){label=document.createElement('p');label.id='stage-draft-label';label.setAttribute('data-i18n','Draft rig · structure evidence only');document.querySelector('.viewbar')?.prepend(label);}label.textContent=tr('Draft rig · structure evidence only');
|
|
2338
|
+
inspectorBlocks?.select('rig',request.instrument==='chest'?'chest-regions':request.instrument==='mesh'?'mesh-panel':'modeling-tools');
|
|
2339
|
+
if(request.instrument==='chest'&&button('chest-edit').getAttribute('aria-pressed')!=='true')button('chest-edit').click();
|
|
2340
|
+
if(request.instrument==='delta'&&button('mesh-edit').getAttribute('aria-pressed')!=='true')button('mesh-edit').click();
|
|
2341
|
+
message(tr('Draft rig · structure evidence only')+tr(` · ${mapping.part} · rig-parts remesh ${request.instrument==='delta'?'--delta':'--mesh'}`));
|
|
2342
|
+
}
|
package/web/parts.css
CHANGED
|
@@ -94,3 +94,10 @@ main{position:relative}.toolbar{anchor-name:--stage-comment-bar}#stage-comment{w
|
|
|
94
94
|
.pv-comparison{display:flex;flex-wrap:wrap;align-items:center;gap:12px}#pv-opacity{width:100px}
|
|
95
95
|
|
|
96
96
|
.pv-overlay canvas{position:absolute;left:0;top:0;pointer-events:none}
|
|
97
|
+
|
|
98
|
+
/* Draft correction tools wrap independently of the raster viewport and compact part list. */
|
|
99
|
+
#pv-corrections{flex:none;padding:8px 12px;border-bottom:1px solid var(--line);overflow-wrap:anywhere}
|
|
100
|
+
#pv-corrections p{margin:0 0 8px}
|
|
101
|
+
#pv-corrections p:last-child{margin:8px 0 0;color:var(--muted)}
|
|
102
|
+
#pv-corrections button{font:inherit;color:inherit;background:var(--panel);border:1px solid var(--line);border-radius:5px;padding:5px 9px;margin:0 6px 4px 0;cursor:pointer}
|
|
103
|
+
#reference-empty{padding:30px 12px 12px;color:var(--muted);overflow-wrap:anywhere}
|
package/web/parts.html
CHANGED
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
<label class="pv-field"><input type="checkbox" id="pv-alpha" data-pv-alpha> Alpha only</label>
|
|
17
17
|
<label class="pv-field" id="pv-footprint-control"><input type="checkbox" id="pv-footprints" data-pv-footprints> Footprints of parts in front</label>
|
|
18
18
|
<span id="pv-comparison" class="pv-comparison" hidden>
|
|
19
|
-
<span class="pv-field">Painting comparison <span class="pv-group" role="group" aria-label="Painting comparison"><button type="button" data-pv-comparison="part" aria-pressed="true">Part</button><button type="button" data-pv-comparison="overlay" aria-pressed="false">Overlay</button></span></span>
|
|
19
|
+
<span class="pv-field">Painting comparison <span class="pv-group" role="group" aria-label="Painting comparison"><button type="button" data-pv-comparison="part" aria-pressed="true">Part</button><button type="button" data-pv-comparison="overlay" aria-pressed="false">Overlay</button><button type="button" data-pv-comparison="difference" aria-pressed="false">Difference</button></span></span>
|
|
20
20
|
<label class="pv-field" id="pv-opacity-control" hidden>Part opacity <input type="range" id="pv-opacity" min="0" max="1" step="0.001" value="0.5"><output id="pv-opacity-value">50.0%</output></label>
|
|
21
|
+
<label class="pv-field" id="pv-threshold-control" hidden>Threshold <input type="number" id="pv-threshold" min="0" max="255" step="1" value="0"></label>
|
|
21
22
|
</span>
|
|
22
23
|
<span class="pv-group" role="group" aria-label="Atlas view" id="pv-atlas-switch" hidden><button type="button" data-pv-view="item" aria-pressed="true">Region</button><button type="button" data-pv-view="page" aria-pressed="false">Pages</button></span>
|
|
23
24
|
</div>
|
package/web/parts.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {defaultPartsComparison,paintingRectangle} from '../src/parts-comparison.ts';
|
|
1
|
+
import {defaultPartsComparison,paintingRectangle,type PartsComparison} from '../src/parts-comparison.ts';
|
|
2
2
|
import {mountViewportPair} from './viewport-pair.ts';
|
|
3
3
|
import {createPartsViewport} from './parts-viewport-provider.ts';
|
|
4
4
|
import {bindStageComments,type CommentUiPose,type CommentCodec} from './stage-comments.ts';
|
|
5
5
|
import {parsePartsComment,snapImageRegion,type PartsComment} from '../src/parts-comment.ts';
|
|
6
6
|
import {projectMark,unprojectMark,region} from '../src/stage-comment.ts';
|
|
7
|
-
import {bindStageNav} from './stage-nav.ts';
|
|
7
|
+
import {bindStageNav,stagePartsSelectionIndex,type StagePartsState,type StagePartsWindow} from './stage-nav.ts';
|
|
8
8
|
/**
|
|
9
9
|
* The parts and atlas view (#348). Every part on its own, on a sentinel background, through the shared native-scale
|
|
10
10
|
* viewport controller; the footprints of the parts drawn in front of it; the producer's flags on it; and a
|
|
@@ -29,7 +29,9 @@ type Flag =
|
|
|
29
29
|
| { id: string; item: string; source: 'mesh_report'; kind: 'faint'; art: number; maxAlpha: number; box: [number, number, number, number] }
|
|
30
30
|
| { id: string; item: string; source: 'check'; kind: 'check'; path: string; line: string; root: string; status: string | null; entry: Record<string, unknown>; classification?: 'part' | 'pair' | 'evidence' | 'unclassified' };
|
|
31
31
|
interface ViewData {
|
|
32
|
-
|
|
32
|
+
inspectionSourceHash?:string;
|
|
33
|
+
draft?:{label:string;buildId:string;inspectionSourceHash:string;mappings:{part:string;skin:string;slot:string;attachment:string;vertices:number;triangles:number}[];evidence:unknown};draftUnavailable?:string;
|
|
34
|
+
differenceAvailable?:boolean;painting:{sha256:string;width:number;height:number}|null;sourceHash:string;mode: 'parts' | 'atlas'; title: string; rigSize: [number, number] | null; items: Item[]; pages: Page[]; flags: Flag[]; readings?: Flag[];
|
|
33
35
|
flagSources: string[]; flagMissing: string[]; verdictFile: string;
|
|
34
36
|
verdict: { comments?:PartsComment[];status: string; parts: Record<string, Entry> } | null; verdictStale: 'files' | 'flags' | null;
|
|
35
37
|
}
|
|
@@ -41,9 +43,13 @@ const $ = <T extends HTMLElement>(id: string) => document.getElementById(id) as
|
|
|
41
43
|
const access = pageInstanceAccess();
|
|
42
44
|
const stageEmbedded=new URL(location.href).searchParams.get('stageEmbed')==='1';
|
|
43
45
|
const stageSide=new URL(location.href).searchParams.get('side');
|
|
46
|
+
let stageBuild='inspected',stageRestore:StagePartsState|null=null;
|
|
47
|
+
let receiveSource:()=>void=()=>{};const sourceReady=new Promise<void>(resolve=>{receiveSource=resolve;});
|
|
48
|
+
if(typeof window!=='undefined')window.addEventListener('message',event=>{if(event.source===parent&&event.origin===location.origin&&event.data?.type==='review-stage-source'&&(event.data.buildId==='inspected'||/^[a-f0-9]{64}$/.test(event.data.buildId))){stageBuild=event.data.buildId;stageRestore=event.data.state??null;receiveSource();}});
|
|
49
|
+
const stageHeaders=()=>access.headers(stageEmbedded?{'X-Review-Stage-Build':stageBuild}:{});
|
|
44
50
|
const partsApi=stageEmbedded?(stageSide==='a'||stageSide==='b'?`/api/compare/${stageSide}/stage-parts`:'/api/stage-parts'):'/api/parts';
|
|
45
51
|
|
|
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>() };
|
|
52
|
+
const state = { data: null as ViewData | null, selected: 0, zoom: 1, bg: 'green', alpha: false, footprints: false, comparison:defaultPartsComparison(), differenceThreshold:0, hidden: new Set<string>(), view: 'item' as 'item' | 'page' | 'assembled', page: 0, meshShown: new Set<string>(), verdict: new Map<string, Entry>() };
|
|
47
53
|
const comments:PartsComment[]=[];let commentUi:ReturnType<typeof bindStageComments>|null=null;let viewport:ReturnType<typeof createPartsViewport>|null=null;let painting=false;
|
|
48
54
|
const images = new Map<string, HTMLImageElement>();
|
|
49
55
|
|
|
@@ -54,7 +60,8 @@ function load(src: string): Promise<HTMLImageElement> {
|
|
|
54
60
|
const img = new Image();
|
|
55
61
|
img.onload = () => { images.set(src, img); resolve(img); };
|
|
56
62
|
img.onerror = () => reject(new Error(src));
|
|
57
|
-
|
|
63
|
+
if(stageEmbedded)void fetch(access.route(src),{headers:stageHeaders()}).then(async res=>{if(!res.ok)throw new Error('STAGE_DRAFT_CHANGED');const url=URL.createObjectURL(await res.blob());img.addEventListener('load',()=>URL.revokeObjectURL(url),{once:true});img.src=url;}).catch(reject);
|
|
64
|
+
else img.src = access.route(src);
|
|
58
65
|
});
|
|
59
66
|
}
|
|
60
67
|
const itemImage = (item: Item) => load(`${partsApi}/image/${item.index}`);
|
|
@@ -84,9 +91,9 @@ async function paint():Promise<void>{
|
|
|
84
91
|
await paintRaster(token);if(token!==paintToken)return;
|
|
85
92
|
await paintReference(token);if(token!==paintToken)return;
|
|
86
93
|
viewport?.fitCamera();if(paintFailure)$('pv-save-status').textContent='';paintFailure=null;commentUi?.refresh();
|
|
87
|
-
}catch{
|
|
94
|
+
}catch(error){
|
|
88
95
|
if(token!==paintToken)return;
|
|
89
|
-
paintFailure='PARTS_PAINT_FAILED: view could not be rendered; select the part to retry';
|
|
96
|
+
paintFailure=error instanceof Error&&error.message.startsWith('PARTS_DIFFERENCE_')?error.message:'PARTS_PAINT_FAILED: view could not be rendered; select the part to retry';
|
|
90
97
|
const canvas=$<HTMLCanvasElement>('pv-canvas');canvas.getContext('2d')?.clearRect(0,0,canvas.width,canvas.height);$('pv-overlay').replaceChildren();
|
|
91
98
|
$('pv-caption').textContent=t(paintFailure);$('pv-save-status').textContent=t(paintFailure);commentUi?.refresh();
|
|
92
99
|
}finally{if(token===paintToken)painting=false;}
|
|
@@ -155,6 +162,14 @@ async function paintRaster(token:number): Promise<void> {
|
|
|
155
162
|
caption.textContent = t('Region {name} on {page} at {x},{y}, {width}×{height} px, with {margin} px of the page around it (dashed: the region box).', { name: item.name, page: item.page!, x: item.x, y: item.y, width: item.w, height: item.h, margin: REGION_MARGIN }) + (item.degrees ? ' ' + t('Packed at {degrees}°.', { degrees: item.degrees }) : '');
|
|
156
163
|
return;
|
|
157
164
|
}
|
|
165
|
+
if(state.comparison.mode==='difference'){
|
|
166
|
+
const response=await fetch(access.route(`${partsApi}/difference/${item.index}?threshold=${state.comparison.threshold}&footprints=${state.footprints}`),{headers:stageHeaders()});
|
|
167
|
+
if(!response.ok){const out=await response.json() as {error:string};throw new Error(out.error);}
|
|
168
|
+
const image=await createImageBitmap(await response.blob());
|
|
169
|
+
try{if(token!==paintToken)return;const ctx=setCanvas(canvas,item.w,item.h);paintBackground(ctx,item.w,item.h,state.bg);ctx.drawImage(image,0,0);overlay.replaceChildren();
|
|
170
|
+
caption.textContent=t('Difference: {count} pixels above threshold · {covered} covered pixels excluded · visual comparison, no automatic verdict.',{count:response.headers.get('X-Difference-Count')??'',covered:response.headers.get('X-Difference-Covered')??''});
|
|
171
|
+
}finally{image.close();}return;
|
|
172
|
+
}
|
|
158
173
|
const img = await itemImage(item), front = state.footprints ? frontParts(data.items, item) : [];
|
|
159
174
|
const fronts = await Promise.all(front.map(async o => ({ o, img: await itemImage(o) })));
|
|
160
175
|
const original=state.comparison.mode==='overlay'&&data.painting?await load('/api/parts/painting'):null;
|
|
@@ -176,11 +191,14 @@ async function paintRaster(token:number): Promise<void> {
|
|
|
176
191
|
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);}
|
|
177
192
|
|
|
178
193
|
function renderComparison():void {
|
|
179
|
-
const active=state.data?.mode==='parts'
|
|
194
|
+
const active=state.data?.mode==='parts'&&(!!state.data.painting||!!state.data.differenceAvailable),overlay=active&&state.comparison.mode==='overlay',difference=state.comparison.mode==='difference';
|
|
195
|
+
const button=document.querySelector<HTMLButtonElement>('[data-pv-comparison="difference"]');if(button){button.disabled=!state.data?.differenceAvailable||state.view!=='item';button.title=button.disabled?t('PARTS_DIFFERENCE_UNAVAILABLE: declared painting_in_rig and individual part view required.'):'';}
|
|
196
|
+
document.querySelector<HTMLButtonElement>('[data-pv-comparison="overlay"]')!.disabled=!state.data?.painting;
|
|
197
|
+
$('pv-threshold-control').hidden=!difference;$<HTMLInputElement>('pv-threshold').value=String(state.comparison.mode==='difference'?state.comparison.threshold:state.differenceThreshold);
|
|
180
198
|
$('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));
|
|
181
199
|
$('pv-opacity-control').hidden=!overlay;$<HTMLInputElement>('pv-opacity').value=String(state.comparison.opacity);$('pv-opacity-value').textContent=(state.comparison.opacity*100).toFixed(1)+'%';
|
|
182
|
-
$<HTMLInputElement>('pv-alpha').disabled=overlay;
|
|
183
|
-
const mesh=document.querySelector<HTMLInputElement>('#pv-mesh-control input');if(mesh)mesh.disabled=overlay||state.view==='assembled';
|
|
200
|
+
$<HTMLInputElement>('pv-alpha').disabled=overlay||difference;
|
|
201
|
+
const mesh=document.querySelector<HTMLInputElement>('#pv-mesh-control input');if(mesh)mesh.disabled=overlay||difference||state.view==='assembled';
|
|
184
202
|
$<HTMLInputElement>('pv-footprints').disabled=state.data?.mode==='atlas'||state.view==='assembled';
|
|
185
203
|
}
|
|
186
204
|
|
|
@@ -289,7 +307,7 @@ function renderMesh(): void {
|
|
|
289
307
|
const item = state.data!.items[state.selected]!;
|
|
290
308
|
if (!item.mesh) return;
|
|
291
309
|
const control = document.createElement('label'); control.id = 'pv-mesh-control'; control.className = 'pv-field';
|
|
292
|
-
const toggle = document.createElement('input'); toggle.type = 'checkbox'; toggle.checked = state.meshShown.has(item.name); toggle.disabled=state.comparison.mode
|
|
310
|
+
const toggle = document.createElement('input'); toggle.type = 'checkbox'; toggle.checked = state.meshShown.has(item.name); toggle.disabled=state.comparison.mode!=='part'||state.view==='assembled';
|
|
293
311
|
toggle.onchange = () => { if (toggle.checked) state.meshShown.add(item.name); else state.meshShown.delete(item.name); void paint(); };
|
|
294
312
|
control.append(toggle, t('mesh from rig.json UVs')); document.querySelector('.pv-toolbar')!.append(control);
|
|
295
313
|
const panel = document.createElement('section'); panel.id = 'pv-mesh-panel';
|
|
@@ -302,6 +320,7 @@ function renderMesh(): void {
|
|
|
302
320
|
}
|
|
303
321
|
panel.append(figures);
|
|
304
322
|
const help = document.createElement('p'); help.textContent = t('Pink: art pixels outside every triangle.'); panel.append(help);
|
|
323
|
+
if(stageEmbedded){document.querySelector('.pv-verdict')!.before(panel);return;}
|
|
305
324
|
const entry = state.verdict.get(item.name)!;
|
|
306
325
|
const select = document.createElement('select'); select.setAttribute('aria-label', t('Mesh outcome'));
|
|
307
326
|
for (const [value, label] of [['pending', 'Pending'], ['clean', 'Clean'], ['flagged', 'Flagged']]) { const option = document.createElement('option'); option.value = value!; option.textContent = t(label!); select.append(option); }
|
|
@@ -315,6 +334,7 @@ function renderMesh(): void {
|
|
|
315
334
|
}
|
|
316
335
|
|
|
317
336
|
function select(index: number): void {
|
|
337
|
+
queueMicrotask(renderCorrections);
|
|
318
338
|
const data = state.data!;
|
|
319
339
|
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});}
|
|
320
340
|
commentUi?.refresh();
|
|
@@ -326,6 +346,7 @@ function select(index: number): void {
|
|
|
326
346
|
function setView(view: 'item' | 'page' | 'assembled'): void {
|
|
327
347
|
if(view==='assembled'&&(state.data?.mode!=='parts'||!state.data.rigSize))return;
|
|
328
348
|
if(state.view!==view&&viewport){viewport.writeCamera('rig',{zoom:1,center:null});viewport.writeCamera('reference',{zoom:1,center:null});}
|
|
349
|
+
if(view!=='item'&&state.comparison.mode==='difference')state.comparison={mode:'part',opacity:state.comparison.opacity};
|
|
329
350
|
state.view = view;renderMesh();renderComparison();$('rig-label').textContent=t(view==='assembled'?'Assembled':'Selected part');commentUi?.refresh();
|
|
330
351
|
for (const b of document.querySelectorAll<HTMLButtonElement>('[data-pv-view]')) b.setAttribute('aria-pressed', String(b.dataset.pvView === view));
|
|
331
352
|
void paint();
|
|
@@ -388,10 +409,11 @@ async function boot(): Promise<void> {
|
|
|
388
409
|
}
|
|
389
410
|
window.addEventListener('message',event=>{if(event.source!==parent||event.origin!==location.origin||event.data?.type!=='review-stage-language'||!['en','ko'].includes(event.data.language))return;setLinkLanguage(null);setLanguagePreference(event.data.language);});
|
|
390
411
|
connectLiveWindow(access);
|
|
391
|
-
|
|
412
|
+
if(stageEmbedded)await sourceReady;
|
|
413
|
+
const res = await fetch(access.route(partsApi), { headers: stageHeaders() });
|
|
392
414
|
const data = await res.json() as ViewData & { error?: string };
|
|
393
415
|
if (!res.ok) { const status=$('pv-load');status.textContent=t(data.error??'Load failed.');status.dataset.result='refused';return; }
|
|
394
|
-
state.data = data;$('reference-empty').textContent=data.painting?'':t('PARTS_REFERENCE_UNAVAILABLE: supply --painting to compare the original painting');$('reference-empty').hidden=!!data.painting;if(data.painting)viewport.state.cameraSync=true;comments.push(...data.verdict?.comments??[]);setupPartsComments();viewport.bindNavigation(undefined,()=>!commentUi?.active());viewport.observeResize();
|
|
416
|
+
state.data = data;if(!data.differenceAvailable)document.querySelector('[data-pv-comparison="difference"]')?.remove();if(stageEmbedded)for(const item of data.items)if(item.mesh)state.meshShown.add(item.name);$('reference-empty').textContent=data.painting?'':t('PARTS_REFERENCE_UNAVAILABLE: supply --painting to compare the original painting');$('reference-empty').hidden=!!data.painting;if(data.painting)viewport.state.cameraSync=true;comments.push(...data.verdict?.comments??[]);setupPartsComments();viewport.bindNavigation(undefined,()=>!commentUi?.active());viewport.observeResize();
|
|
395
417
|
for (const item of data.items) state.verdict.set(item.name, { outcome: 'pending', note: '', ...(item.mesh ? { mesh: { outcome: 'pending' as Outcome, note: '' } } : {}) });
|
|
396
418
|
if (data.verdict) { for (const [name, v] of Object.entries(data.verdict.parts)) if (state.verdict.has(name)) state.verdict.set(name, { outcome: v.outcome, note: v.note ?? '', ...(v.mesh ? { mesh: v.mesh } : {}) }); $<HTMLSelectElement>('pv-overall').value = data.verdict.status; }
|
|
397
419
|
document.title = data.title;
|
|
@@ -404,8 +426,21 @@ async function boot(): Promise<void> {
|
|
|
404
426
|
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.'):'';
|
|
405
427
|
assemble.onclick=()=>{setView(state.view==='assembled'?'item':'assembled');assemble.setAttribute('aria-pressed',String(state.view==='assembled'));};
|
|
406
428
|
bindAssemblyPicking();
|
|
407
|
-
for(const button of document.querySelectorAll<HTMLElement>('[data-pv-comparison]'))button.onclick=()=>{
|
|
429
|
+
for(const button of document.querySelectorAll<HTMLElement>('[data-pv-comparison]'))button.onclick=()=>{const mode=button.dataset.pvComparison as PartsComparison['mode'];state.comparison=mode==='difference'?{mode,opacity:state.comparison.opacity,threshold:state.differenceThreshold}:{mode,opacity:state.comparison.opacity};if(state.comparison.mode!=='part'){state.alpha=false;$<HTMLInputElement>('pv-alpha').checked=false;state.meshShown.delete(state.data!.items[state.selected]!.name);renderMesh();}renderComparison();void paint();};
|
|
408
430
|
$<HTMLInputElement>('pv-opacity').oninput=e=>{state.comparison.opacity=Number((e.target as HTMLInputElement).value);renderComparison();void paint();};
|
|
431
|
+
$<HTMLInputElement>('pv-threshold').oninput=e=>{
|
|
432
|
+
const input=e.target as HTMLInputElement,threshold=input.valueAsNumber,status=$('pv-save-status');
|
|
433
|
+
if(!Number.isInteger(threshold)||threshold<0||threshold>255){
|
|
434
|
+
input.value=String(state.differenceThreshold);
|
|
435
|
+
status.dataset.thresholdRefused='true';
|
|
436
|
+
status.textContent=t('PARTS_COMPARISON_INVALID: enter an integer threshold from 0 to 255. Last valid value restored.');
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if(status.dataset.thresholdRefused){delete status.dataset.thresholdRefused;status.textContent='';}
|
|
440
|
+
state.differenceThreshold=threshold;
|
|
441
|
+
if(state.comparison.mode==='difference')state.comparison.threshold=threshold;
|
|
442
|
+
void paint();
|
|
443
|
+
};
|
|
409
444
|
const footprints = $<HTMLInputElement>('pv-footprints');
|
|
410
445
|
if (data.mode === 'atlas') { footprints.disabled = true; $('pv-footprint-control').title = t('Footprints need a parts package: atlas regions carry no rig placement.'); }
|
|
411
446
|
$<HTMLSelectElement>('pv-bg').onchange = e => { state.bg = (e.target as HTMLSelectElement).value; void paint(); };
|
|
@@ -419,7 +454,9 @@ async function boot(): Promise<void> {
|
|
|
419
454
|
$('pv-approve-all').onclick = () => approveAll();
|
|
420
455
|
for(const format of ['json','issue'])$('pv-export-'+format).onclick=async()=>{const res=await fetch(access.route('/api/parts/export?format='+format),{headers:access.headers()});const value=await res.text();if(!res.ok){$('pv-save-status').textContent=value;return;}const url=URL.createObjectURL(new Blob([value],{type:format==='json'?'application/json':'text/markdown'})),a=document.createElement('a');a.href=url;a.download=format==='json'?'parts-review-export.json':'parts-review-export.md';a.click();setTimeout(()=>URL.revokeObjectURL(url),1000);};
|
|
421
456
|
onLanguageChange(() => { if (state.data) select(state.selected); });
|
|
422
|
-
if
|
|
457
|
+
if(stageEmbedded)(window as StagePartsWindow).rigReviewStageParts={snapshot:stagePartsSnapshot};
|
|
458
|
+
if(data.items.length){if(stageRestore)await restoreStageParts(stageRestore);else select(0);}
|
|
459
|
+
renderCorrections();
|
|
423
460
|
document.body.dataset.ready = 'true';
|
|
424
461
|
}
|
|
425
462
|
|
|
@@ -449,8 +486,42 @@ function setupPartsComments():void {
|
|
|
449
486
|
};
|
|
450
487
|
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}};};
|
|
451
488
|
commentUi=bindStageComments({toolbar:document.querySelector<HTMLElement>('.pv-toolbar')!,viewports:{rig:$('rig-viewport')},pose,pause:async()=>{},bookmark:()=>null,
|
|
452
|
-
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;}},
|
|
489
|
+
restore:async(raw)=>{const res=await fetch(access.route(partsApi),{headers:stageHeaders()});const current=await res.json() as ViewData&{error?:string};if(!res.ok||current.sourceHash!==state.data?.sourceHash)throw new Error(current.error??'PARTS_COMMENT_STALE_SOURCE');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())};if(state.comparison.mode==='difference')state.differenceThreshold=state.comparison.threshold;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;}},
|
|
453
490
|
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});
|
|
454
491
|
}
|
|
455
492
|
|
|
456
493
|
if (typeof document !== 'undefined' && document.getElementById('parts-app')) void boot();
|
|
494
|
+
|
|
495
|
+
function renderCorrections():void {
|
|
496
|
+
let host=document.getElementById('pv-corrections');if(!host){host=document.createElement('section');host.id='pv-corrections';document.querySelector('.pv-toolbar')!.after(host);}
|
|
497
|
+
host.replaceChildren();const data=state.data,item=data?.items[state.selected],mapping=data?.draft?.mappings.find(m=>m.part===item?.name);
|
|
498
|
+
const label=document.createElement('p');label.textContent=t(data?.draft&&!mapping?'STAGE_DRAFT_NO_MESH: this part has no mesh attachment; direct correction is unavailable.':data?.draft?.label??data?.draftUnavailable??'STAGE_DRAFT_UNAVAILABLE: no producer-compatible draft is supplied.');host.append(label);
|
|
499
|
+
if(!mapping||!data?.draft)return;
|
|
500
|
+
label.textContent+=` · ${mapping.part} · ${mapping.skin}/${mapping.slot}/${mapping.attachment} · v ${mapping.vertices} t ${mapping.triangles} · ${data.draft.buildId}`;
|
|
501
|
+
for(const [instrument,title,operation]of [['chest','Chest regions',t('rig-parts remesh --mesh')],['mesh','Mesh parameters',t('rig-parts remesh --mesh')],['delta','Edit Mesh',t('rig-parts remesh --delta')]]){
|
|
502
|
+
const button=document.createElement('button');button.type='button';button.textContent=t(title!);button.title=`${mapping.part} · ${operation}`;button.onclick=()=>parent.postMessage({type:'review-stage-correction',part:mapping.part,sourceHash:data.sourceHash,buildId:data.draft!.buildId,instrument},location.origin);host.append(button);
|
|
503
|
+
}
|
|
504
|
+
const unavailable=document.createElement('p');unavailable.textContent=t('Correction-record export unavailable: waiting for the shared correction contract.');host.append(unavailable);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function stagePartsSnapshot():StagePartsState|null {
|
|
508
|
+
const data=state.data,item=data?.items[state.selected],mapping=data?.draft?.mappings.find(m=>m.part===item?.name);
|
|
509
|
+
if(!data?.inspectionSourceHash||!item?.imageHash||!mapping||!viewport)return null;
|
|
510
|
+
return {inspectionSourceHash:data.inspectionSourceHash,part:item.name,imageHash:item.imageHash,box:{x:item.x,y:item.y,w:item.w,h:item.h},mapping:{skin:mapping.skin,slot:mapping.slot,attachment:mapping.attachment},rig:{...viewport.paneCamera('rig')},reference:{...viewport.paneCamera('reference')},cameraSync:viewport.state.cameraSync,bg:state.bg,alpha:state.alpha,footprints:state.footprints,view:state.view,mesh:state.meshShown.has(item.name)};
|
|
511
|
+
}
|
|
512
|
+
async function restoreStageParts(saved:StagePartsState):Promise<void>{
|
|
513
|
+
if(!state.data||!viewport)return;
|
|
514
|
+
try{
|
|
515
|
+
const index=stagePartsSelectionIndex(state.data,saved);
|
|
516
|
+
viewport.state.cameraRestoring=true;state.bg=saved.bg;state.alpha=saved.alpha;state.footprints=saved.footprints;state.view=saved.view;
|
|
517
|
+
if(saved.mesh)state.meshShown.add(saved.part);else state.meshShown.delete(saved.part);
|
|
518
|
+
select(index);await paint();viewport.writeCamera('rig',saved.rig);if(state.data.painting)viewport.writeCamera('reference',saved.reference);viewport.state.cameraSync=saved.cameraSync;viewport.fitCamera();
|
|
519
|
+
}catch{const status=$('pv-load');status.hidden=false;status.dataset.result='refused';status.textContent=t('STAGE_DRAFT_MISMATCH: separated parts and draft mesh identity differ.');document.querySelector<HTMLElement>('.pv-layout')!.hidden=true;}
|
|
520
|
+
finally{viewport.state.cameraRestoring=false;}
|
|
521
|
+
}
|
|
522
|
+
if(typeof window!=='undefined')window.addEventListener('message',event=>{if(event.source===parent&&event.origin===location.origin&&event.data?.type==='review-stage-restore'&&event.data.state)void restoreStageParts(event.data.state);});
|
|
523
|
+
|
|
524
|
+
if(typeof window!=='undefined')window.addEventListener('message',event=>{if(event.source!==parent||event.origin!==location.origin||event.data?.type!=='review-stage-revalidate')return;void (async()=>{
|
|
525
|
+
try{const response=await fetch(access.route(partsApi),{headers:stageHeaders()}),data=await response.json() as ViewData&{error?:string};if(!response.ok||data.sourceHash!==state.data?.sourceHash)throw new Error(data.error??'STAGE_DRAFT_MISMATCH: separated parts and draft mesh identity differ.');if(event.data.state)await restoreStageParts(event.data.state);}
|
|
526
|
+
catch(error){const status=$('pv-load');status.hidden=false;status.dataset.result='refused';status.textContent=t(error instanceof Error?error.message:String(error));document.querySelector<HTMLElement>('.pv-layout')!.hidden=true;}
|
|
527
|
+
})();});
|
package/web/rebuild-client.ts
CHANGED
|
@@ -27,12 +27,12 @@ export type AnimationSourceView=import('../src/rebuild.ts').AnimationSourceStatu
|
|
|
27
27
|
export interface RebuildStatusView {retarget?:RetargetStatusView;animations?:AnimationSourceView|null;available:boolean;viewOnly?:boolean;handoff:HandoffView|null;baseline:BaselineView|null;inputs:{config:string;parts:string|null;rig:string|null;configHash:string}|null;parts:{name:string;regions:unknown[]}[];contour:Record<string,Record<string,unknown>>;meshes?:Record<string,unknown>;constraints?:unknown[]|null;bones?:unknown[]|null;fields?:Record<string,unknown>|null;cuts?:{config:Record<string,unknown>;build:string|null}|null;inspectedCheck?:InspectedCheckView|null;idle?:import('../src/idle-tracks.ts').IdleStatus|null;cloth?:ClothStatusView|null;producer:{package:string;version:string}|null;compiler:{package:string;version:string}|null;reason:string|null}
|
|
28
28
|
/** #111: the cloth recipe form's status — the reader's tags, the recipes as written, each tag's parts and chains, the keypoints, the route and why Apply cannot run. */
|
|
29
29
|
export interface ClothStatusView {targets:string[];targetsRead:boolean;recipes:Record<string,unknown>|null;tags:import('../src/cloth-recipe.ts').ClothTagView[];keypoints:{path:string;sha256:string}|null;route:'build'|'rig';reason:string|null}
|
|
30
|
-
export interface RebuildJobView {id:string;status:'running'|'built'|'refused'|'failed';reused:boolean;lines:string[];producerLine:string|null;hint?:string;exitCode:number|null;wallMs:{remesh:number|null;compile:number|null};build:{modelUrl:string;modelHash:string;files:Record<string,string>}|null;request:{part:string;regions:RegionEntry[];configHash:string;entrySha256:string;bust?:BustSpec};producer:{package:string;version:string};compiler:{package:string;version:string}}
|
|
30
|
+
export interface RebuildJobView {stageInputHash?:string;files?:FilesDiff|null;remesh?:import('../src/mesh-entry.ts').RemeshCounts|null;check?:CheckSummary|null;id:string;status:'running'|'built'|'refused'|'failed';reused:boolean;lines:string[];producerLine:string|null;hint?:string;exitCode:number|null;wallMs:{remesh:number|null;compile:number|null};build:{modelUrl:string;modelHash:string;files:Record<string,string>}|null;request:{part:string;regions:RegionEntry[];configHash:string;entrySha256:string;bust?:BustSpec};producer:{package:string;version:string};compiler:{package:string;version:string}}
|
|
31
31
|
export interface RebuildRefusal {status:'refused';error:string;producerLine:string|null}
|
|
32
32
|
/** #99 regions or #105 landmarks: exactly one of `regions` and `bust`. */
|
|
33
33
|
export type RebuildRequestBody={part:string;regions:RegionEntry[];configHash:string}|{part:string;bust:BustSpec;configHash:string};
|
|
34
34
|
/** What the draft keeps and the feedback context carries: the exact last applied inputs and the producer's line. */
|
|
35
|
-
export interface AppliedRecord {schema:'rig-review-applied/1';buildId:string;part:string;regions:RegionEntry[];bust?:BustSpec;configHash:string;entrySha256:string;producer:{package:string;version:string};compiler:{package:string;version:string};line:string|null;modelHash:string}
|
|
35
|
+
export interface AppliedRecord {stageInputHash?:string;files?:FilesDiff|null;mesh?:{part:string;before:import('../src/mesh-entry.ts').MeshCounts;after:import('../src/mesh-entry.ts').MeshCounts};check?:CheckSummary|null;schema:'rig-review-applied/1';buildId:string;part:string;regions:RegionEntry[];bust?:BustSpec;configHash:string;entrySha256:string;producer:{package:string;version:string};compiler:{package:string;version:string};line:string|null;modelHash:string}
|
|
36
36
|
|
|
37
37
|
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:Number.NaN;};
|
|
38
38
|
|
|
@@ -132,6 +132,14 @@ function chestPart(status:Pick<RebuildStatusView,'parts'|'contour'>){
|
|
|
132
132
|
const bust=(p:{name:string})=>{const c=status.contour[p.name]?.contour;return !!c&&typeof c==='object'&&'bust' in (c as Record<string,unknown>);};
|
|
133
133
|
return status.parts.find(bust)??status.parts.find(p=>p.regions.some(readable))??status.parts.find(p=>p.regions.length);
|
|
134
134
|
}
|
|
135
|
+
/** The fields and kept-region seed must use the same explicit part as Stage 1's correction request. */
|
|
136
|
+
export function chestStatusForPart<T extends Pick<RebuildStatusView,'parts'|'contour'>>(status:T,part:string|null):T {
|
|
137
|
+
return part?{...status,parts:status.parts.filter(p=>p.name===part),contour:Object.fromEntries(Object.entries(status.contour).filter(([name])=>name===part))}:status;
|
|
138
|
+
}
|
|
139
|
+
export function chestPartFields(status:Pick<RebuildStatusView,'parts'|'contour'>,part:string):{fields:Record<string,string>;mode:'circles'|'landmarks';seed:ChestSeed} {
|
|
140
|
+
const scoped=chestStatusForPart(status,part),empty=()=>undefined,landmarks=seedLandmarks(scoped,empty);
|
|
141
|
+
return {fields:{...(seedFields(scoped,empty)??{}),...(landmarks??{})},mode:landmarks?'landmarks':'circles',seed:chestSeed(scoped)};
|
|
142
|
+
}
|
|
135
143
|
/** The config's regions as chest rows (at most two), read by measurement, never by point count. Pure: Apply recomputes it. */
|
|
136
144
|
export function chestSeed(status:Pick<RebuildStatusView,'parts'|'contour'>):ChestSeed {
|
|
137
145
|
const part=chestPart(status),entry=part?status.contour[part.name]:undefined;if(!part||!entry)return {part:null,rows:[],refusals:[],kept:[]};
|
|
@@ -199,17 +207,17 @@ export function seedLandmarks(status:Pick<RebuildStatusView,'parts'|'contour'>,r
|
|
|
199
207
|
return null;
|
|
200
208
|
}
|
|
201
209
|
|
|
202
|
-
export const appliedRecord=(job:RebuildJobView):AppliedRecord=>({schema:'rig-review-applied/1',buildId:job.id,part:job.request.part,regions:job.request.regions,...(job.request.bust?{bust:job.request.bust}:{}),configHash:job.request.configHash,entrySha256:job.request.entrySha256,producer:job.producer,compiler:job.compiler,line:job.producerLine,modelHash:job.build!.modelHash});
|
|
210
|
+
export const appliedRecord=(job:RebuildJobView):AppliedRecord=>({schema:'rig-review-applied/1',...(job.stageInputHash?{stageInputHash:job.stageInputHash}:{}),...(job.files!==undefined?{files:job.files}:{}),...(job.remesh?{mesh:{part:job.remesh.part,before:job.remesh.before,after:job.remesh.after}}:{}),...(Object.hasOwn(job,'check')?{check:job.check}:{}),buildId:job.id,part:job.request.part,regions:job.request.regions,...(job.request.bust?{bust:job.request.bust}:{}),configHash:job.request.configHash,entrySha256:job.request.entrySha256,producer:job.producer,compiler:job.compiler,line:job.producerLine,modelHash:job.build!.modelHash});
|
|
203
211
|
export function parseApplied(text:string):AppliedRecord|AppliedPatch|AppliedDelta|AppliedRetarget|AppliedAnimation|null {try{const value=JSON.parse(text);return value?.schema==='rig-review-applied/1'||value?.schema===APPLIED_PATCH_SCHEMA||value?.schema===APPLIED_DELTA_SCHEMA||value?.schema===APPLIED_RETARGET_SCHEMA||value?.schema===APPLIED_ANIMATION_SCHEMA?value as AppliedRecord|AppliedPatch|AppliedDelta|AppliedRetarget|AppliedAnimation:null;}catch{return null;}}
|
|
204
212
|
|
|
205
213
|
/** A patch Apply's job (#102): the patch and its hash, the op/compile/check wall clocks, check's summary and the rig.json diff. */
|
|
206
214
|
/** #115: a build job's assemble readout (`AssembledView` in src/rebuild.ts). */
|
|
207
215
|
export type AssembledJobView=import('../src/rebuild.ts').AssembledView;
|
|
208
|
-
export interface PatchJobView {id:string;kind:'patch';op?:'rig'|'retune'|'remesh'|'build'|'cloth';assembled?:AssembledJobView;cloth?:import('../src/rebuild.ts').ClothJob;status:'running'|'built'|'refused'|'failed';reused:boolean;lines:string[];producerLine:string|null;hint?:string;exitCode:number|null;wallMs:{op:number|null;compile:number|null;check:number|null};check:CheckSummary|null;diff:{count:number;paths:string[]}|null;files?:FilesDiff|null;remesh?:import('../src/mesh-entry.ts').RemeshCounts&{modelTriangles:number|null}|null;build:{modelUrl:string;modelHash:string;files:Record<string,string>}|null;request:{patch:ConfigPatch;patchSha256:string;configHash:string};producer:{package:string;version:string};compiler:{package:string;version:string};environment?:{sha256:string;steps:number}}
|
|
216
|
+
export interface PatchJobView {stageInputHash?:string;id:string;kind:'patch';op?:'rig'|'retune'|'remesh'|'build'|'cloth';assembled?:AssembledJobView;cloth?:import('../src/rebuild.ts').ClothJob;status:'running'|'built'|'refused'|'failed';reused:boolean;lines:string[];producerLine:string|null;hint?:string;exitCode:number|null;wallMs:{op:number|null;compile:number|null;check:number|null};check:CheckSummary|null;diff:{count:number;paths:string[]}|null;files?:FilesDiff|null;remesh?:import('../src/mesh-entry.ts').RemeshCounts&{modelTriangles:number|null}|null;build:{modelUrl:string;modelHash:string;files:Record<string,string>}|null;request:{patch:ConfigPatch;patchSha256:string;configHash:string};producer:{package:string;version:string};compiler:{package:string;version:string};environment?:{sha256:string;steps:number}}
|
|
209
217
|
/** #112: `environment` is the exported `rigc-environment/1` schedule Apply's check reads, when "Use for readings" is on. */
|
|
210
218
|
export interface PatchRequestBody {patch:ConfigPatch;environment?:import('../src/environment-schedule.ts').EnvironmentSchedule}
|
|
211
219
|
/** Edit Mesh's delta Apply (#135): `remesh --delta`, the per-file diff and the part's counts; remesh's own gate holds check. */
|
|
212
|
-
export interface DeltaJobView {id:string;kind:'delta';op:'remesh';status:'running'|'built'|'refused'|'failed';reused:boolean;lines:string[];producerLine:string|null;hint?:string;exitCode:number|null;wallMs:{op:number|null;compile:number|null};files:FilesDiff|null;remesh:import('../src/mesh-entry.ts').RemeshCounts&{modelTriangles:number|null}|null;build:{modelUrl:string;modelHash:string;files:Record<string,string>}|null;request:{part:string;delta:Record<string,unknown>;deltaSha256:string;configHash:string};producer:{package:string;version:string};compiler:{package:string;version:string}}
|
|
220
|
+
export interface DeltaJobView {stageInputHash?:string;check?:CheckSummary|null;id:string;kind:'delta';op:'remesh';status:'running'|'built'|'refused'|'failed';reused:boolean;lines:string[];producerLine:string|null;hint?:string;exitCode:number|null;wallMs:{op:number|null;compile:number|null};files:FilesDiff|null;remesh:import('../src/mesh-entry.ts').RemeshCounts&{modelTriangles:number|null}|null;build:{modelUrl:string;modelHash:string;files:Record<string,string>}|null;request:{part:string;delta:Record<string,unknown>;deltaSha256:string;configHash:string};producer:{package:string;version:string};compiler:{package:string;version:string}}
|
|
213
221
|
/** `{part, delta, configHash}`: the server owns every path and flag; the delta is the editor's export as it stands. */
|
|
214
222
|
export interface DeltaRequestBody {part:string;delta:import('../src/mesh-edit.ts').MeshEditDocument;configHash:string}
|
|
215
223
|
/** A retarget Apply's job (#114): clean, retarget, compile; every FAIL line of the step that refused, verbatim; the listed lines. */
|
|
@@ -267,14 +275,14 @@ export function makePatch(status:Pick<RebuildStatusView,'inputs'|'producer'>,ops
|
|
|
267
275
|
return {schema:CONFIG_PATCH_SCHEMA,config_sha256:status.inputs.configHash,ops:ops.map(o=>({...o})),producer:{name:status.producer.package,version:status.producer.version},op:{cmd:op.cmd,args:[...(op.args??[])]}};
|
|
268
276
|
}
|
|
269
277
|
/** What the draft keeps and `context.applied` carries for a patch: the patch, its hash, the producer's line and check's summary. */
|
|
270
|
-
export const patchAppliedRecord=(job:PatchJobView):AppliedPatch=>({schema:APPLIED_PATCH_SCHEMA,buildId:job.id,patch:job.request.patch,patchSha256:job.request.patchSha256,configHash:job.request.configHash,producer:job.producer,compiler:job.compiler,line:job.producerLine,check:job.check,diff:job.diff,...(job.files?{files:job.files}:{}),modelHash:job.build!.modelHash,...(job.op?{op:job.op}:{}),...(job.remesh?{mesh:{part:job.remesh.part,before:{...job.remesh.before},after:{...job.remesh.after}}}:{}),...(job.op==='cloth'&&job.cloth?{cloth:{route:job.cloth.route,keypoints:{...job.cloth.inputs.keypoints},written:{count:job.cloth.written?.count??0,paths:[...(job.cloth.written?.paths??[])]}}}:{}),...(job.op==='build'||(job.op==='cloth'&&job.cloth?.route==='build')?{assembled:assembledRecord(job)}:{}),...(job.environment?{environment:{...job.environment}}:{})});
|
|
278
|
+
export const patchAppliedRecord=(job:PatchJobView):AppliedPatch=>({schema:APPLIED_PATCH_SCHEMA,...(job.stageInputHash?{stageInputHash:job.stageInputHash}:{}),buildId:job.id,patch:job.request.patch,patchSha256:job.request.patchSha256,configHash:job.request.configHash,producer:job.producer,compiler:job.compiler,line:job.producerLine,check:job.check,diff:job.diff,...(job.files?{files:job.files}:{}),modelHash:job.build!.modelHash,...(job.op?{op:job.op}:{}),...(job.remesh?{mesh:{part:job.remesh.part,before:{...job.remesh.before},after:{...job.remesh.after}}}:{}),...(job.op==='cloth'&&job.cloth?{cloth:{route:job.cloth.route,keypoints:{...job.cloth.inputs.keypoints},written:{count:job.cloth.written?.count??0,paths:[...(job.cloth.written?.paths??[])]}}}:{}),...(job.op==='build'||(job.op==='cloth'&&job.cloth?.route==='build')?{assembled:assembledRecord(job)}:{}),...(job.environment?{environment:{...job.environment}}:{})});
|
|
271
279
|
/** #115: what a build Apply records: the build's own wall clock, the recomposite figures, the parts it changed and its `seam pair` lines. */
|
|
272
280
|
export function assembledRecord(job:PatchJobView):AppliedAssembled {
|
|
273
281
|
const a=job.assembled,fig=(f:Record<string,number>|null|undefined)=>f?{...f}:null;
|
|
274
282
|
return {wallMs:job.op==='cloth'?job.cloth?.wallMs.build??null:job.wallMs.op,recomposite:{before:fig(a?.recomposite.before as Record<string,number>|null),after:fig(a?.recomposite.after as Record<string,number>|null)},partsChanged:[...(a?.parts?.changed??[])],seamPairs:(a?.seamPairs??[]).slice(0,64)};
|
|
275
283
|
}
|
|
276
284
|
/** What the draft keeps and `context.applied` carries for a delta: the document and its hash, the producer's line, op "remesh", the diff and the counts. */
|
|
277
|
-
export const deltaAppliedRecord=(job:DeltaJobView):AppliedDelta=>({schema:APPLIED_DELTA_SCHEMA,buildId:job.id,part:job.request.part,delta:JSON.parse(JSON.stringify(job.request.delta)),deltaSha256:job.request.deltaSha256,configHash:job.request.configHash,producer:job.producer,compiler:job.compiler,line:job.producerLine,op:'remesh',files:job.files,...(job.remesh?{mesh:{part:job.remesh.part,before:{...job.remesh.before},after:{...job.remesh.after}}}:{}),modelHash:job.build!.modelHash});
|
|
285
|
+
export const deltaAppliedRecord=(job:DeltaJobView):AppliedDelta=>({schema:APPLIED_DELTA_SCHEMA,...(job.stageInputHash?{stageInputHash:job.stageInputHash}:{}),...(Object.hasOwn(job,'check')?{check:job.check}:{}),buildId:job.id,part:job.request.part,delta:JSON.parse(JSON.stringify(job.request.delta)),deltaSha256:job.request.deltaSha256,configHash:job.request.configHash,producer:job.producer,compiler:job.compiler,line:job.producerLine,op:'remesh',files:job.files,...(job.remesh?{mesh:{part:job.remesh.part,before:{...job.remesh.before},after:{...job.remesh.after}}}:{}),modelHash:job.build!.modelHash});
|
|
278
286
|
/** A delta job's status line: built (wall clocks, counts, the per-file diff) or the producer's line verbatim. */
|
|
279
287
|
export function deltaOutcomeLine(result:DeltaJobView|RebuildRefusal):{text:string;error:boolean} {
|
|
280
288
|
if(!('id' in result))return {text:result.producerLine??result.error,error:true};
|