rig-review 2.6.0 → 2.7.1
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/PANELS.md +1 -1
- package/docs/PARTS_VIEW.md +2 -0
- package/docs/REVIEW_PACKAGE.md +53 -13
- package/docs/STABILITY.md +232 -15
- package/docs/WORKFLOWS.md +2 -0
- package/package.json +2 -2
- package/src/handoff.ts +192 -25
- package/src/interview-project.ts +13 -0
- package/src/job-act.ts +316 -8
- package/src/job-api.ts +821 -8
- package/src/job-contract.ts +299 -0
- package/src/job-front.ts +763 -23
- package/src/job-host.ts +9 -1
- package/src/job-hub.ts +11 -6
- package/src/job-session.ts +68 -9
- package/src/job-source.ts +787 -7
- package/src/job-store.ts +114 -8
- package/src/job-worker.ts +5 -1
- package/src/joined-project.ts +83 -12
- package/src/manifest.ts +5 -3
- package/src/open.ts +5 -4
- package/src/rebuild.ts +445 -51
- package/src/reference.ts +3 -3
- package/src/server.ts +2 -2
- package/src/stage-parts.ts +47 -15
- package/web/catalog-en.ts +5 -0
- package/web/catalog-ko.ts +5 -0
- package/web/main.ts +353 -43
- package/web/part-selection.ts +2 -0
- package/web/parts.ts +22 -4
- package/web/rebuild-client.ts +14 -2
- package/web/stage-nav.ts +20 -12
package/web/main.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {timeOnlyBasis,feedbackTimingLabel,requireFeedbackFrames,isTimeOnlyFeedba
|
|
|
6
6
|
import {bindStageComments,type CommentPose} from './stage-comments.ts';
|
|
7
7
|
import {discoverTurnDials,TurnState} from '../src/turn-pad.ts';
|
|
8
8
|
import {bindTurnPad,type TurnPad} from './turn-pad.ts';
|
|
9
|
-
import {PartExplorer,loadPartModel,partBounds} from './part-selection.ts';
|
|
9
|
+
import {PartExplorer,loadPartModel,partBounds,partCatalog,type PartEntry} from './part-selection.ts';
|
|
10
10
|
import {AnimationInspectionPanel} from './animation-inspection.ts';
|
|
11
11
|
import {PartThumbnails,pageRegionTable} from './part-thumbnails.ts';
|
|
12
12
|
import { CanvasRenderer, loadModel, RigPlayer, type BoneAdjust, type ModelAssets, type PoseBounds } from '@rig-c/play';
|
|
@@ -25,14 +25,14 @@ import {chestOverlayPolygons,chestInputIds,chestRegionRows,chestRowId,evaluateCh
|
|
|
25
25
|
import {bindChestEditor,canvasToCrop,bustLabel,bustSides,chestPoseOffset,LANDMARKS,landmarkInputId,posedChestMapping,rowShape,type ChestEditor,type LandmarkKey} from './chest-editor.ts';
|
|
26
26
|
import {bindMeshEditor,meshEditSource,sha256Hex,type MeshEditor} from './mesh-editor.ts';
|
|
27
27
|
import {bindWeightsView,setupPoseMesh,type WeightsView} from './weights-view.ts';
|
|
28
|
-
import {readSetupPose} from './setup-pose.ts';
|
|
28
|
+
import {readSetupPose,modelBoneNames} from './setup-pose.ts';
|
|
29
29
|
import {bindBonesPanel,type BonesPanel,type BonesCheckView} from './bones-panel.ts';
|
|
30
30
|
import {bindCutsPanel,type CutsPanel} from './cuts-panel.ts';
|
|
31
31
|
import {bindClothPanel,type ClothPanel} from './cloth-panel.ts';
|
|
32
32
|
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';
|
|
33
33
|
import {bindRetargetPanel,type PoseMap,type RetargetPanel} from './retarget-panel.ts';
|
|
34
34
|
import type {RetargetFlags} from '../src/retarget.ts';
|
|
35
|
-
import {appliedCheckState,renderAppliedHistory,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';
|
|
35
|
+
import {appliedCheckState,renderAppliedHistory,isPatchJob,recordFor,refusedText,restoredOutcomeForJob,retargetStage,undoControl,type AppliedHistoryView,type UndoView,type AnyJobView,appliedRecord,deltaAppliedRecord,deltaOutcomeLine,MESH_DELTA_APPLIED_SOURCE,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';
|
|
36
36
|
import {meshEditBinding,meshEditText,type MeshEditDocument} from '../src/mesh-edit.ts';
|
|
37
37
|
import {chestRegionsBinding,cropWorldMapping,type CropWorldMapping} from '../src/chest-regions.ts';
|
|
38
38
|
import {bindWorkspaceUI,selectedInspector,type WorkspaceUI} from './workspace-ui.ts';
|
|
@@ -139,6 +139,9 @@ let cutsPanel:CutsPanel|null=null;
|
|
|
139
139
|
let clothPanel:ClothPanel|null=null;
|
|
140
140
|
/** The hash-verified compiled model document the parts catalog was read from (mesh edit reads attachments from it). */
|
|
141
141
|
let partModel:unknown=null;
|
|
142
|
+
let stageModelBones:string[]|null=null;
|
|
143
|
+
function activeSetupBones():string[]|null{return data?.capabilities?.preRig?stageModelBones:data.feedbackCatalog.bones;}
|
|
144
|
+
function hasStageModel():boolean{return Boolean(data.manifest.model||(data?.capabilities?.preRig&&stageSource&&player));}
|
|
142
145
|
/** Apply · Rebuild (#99): the inspected model's URL, the producer status, and the applied record while its scratch build is on the stage. */
|
|
143
146
|
let inspectedModel:{url:string;prefix:string;sha256:string}|null=null,rebuildStatus:RebuildStatusView|null=null,appliedOnStage:AppliedRecord|AppliedPatch|AppliedDelta|AppliedRetarget|AppliedAnimation|null=null,rebuildBusy=false,stageModelHash:string|null=null;
|
|
144
147
|
let appearance:ReturnType<typeof bindAppearance>|null=null;
|
|
@@ -987,7 +990,7 @@ function bind(): void {
|
|
|
987
990
|
const picker=select('part-set');picker.value=name;picker.dispatchEvent(new Event('change',{bubbles:true}));
|
|
988
991
|
});
|
|
989
992
|
viewDisposers.push(()=>directionPanel?.dispose());
|
|
990
|
-
viewDisposers.push(bindStageNav({access,interview:data.capabilities.interview,preRig:data.capabilities.preRig,model:!!data.manifest.model,direction:active=>directionPanel?.show(active),setup:()=>showInspector('rig'),draftBuild:()=>appliedOnStage?.buildId??'inspected',correction:
|
|
993
|
+
viewDisposers.push(bindStageNav({access,interview:data.capabilities.interview,preRig:data.capabilities.preRig,model:!!data.manifest.model,direction:active=>directionPanel?.show(active),setup:()=>showInspector('rig'),draftBuild:()=>appliedOnStage?.buildId??'inspected',refresh:fn=>{refreshStageParts=fn;},correction:openStageCorrection}));
|
|
991
994
|
workspace=bindWorkspaceUI({changed:fitCamera,defaultTheme:theme=>appearance?.set(theme),currentTheme:()=>appearance?.get()});
|
|
992
995
|
viewport.state.cameraSync=workspace.defaults().defaultCameraSync;input('camera-sync').checked=viewport.state.cameraSync;input('idle-repeat').checked=workspace.defaults().defaultIdleRepeat;
|
|
993
996
|
appearance=bindAppearance(select('settings-theme'),workspace.defaults().theme);
|
|
@@ -995,8 +998,8 @@ function bind(): void {
|
|
|
995
998
|
overlays=new RigOverlays({canvas:el<HTMLCanvasElement>('rig-overlay'),rigRoot:el('rig-root')});
|
|
996
999
|
chestEditor=bindChestEditor({pane:el('rig-pane'),canvas:el('rig-overlay'),project:()=>player?rigProject():null,mapping:()=>activeChestMapping(),changed:renderChest,download:()=>{void exportChest();},apply:()=>{void applyRebuild();},reset:()=>{void resetRebuild();},message,inspector:()=>selectedInspector()});viewDisposers.push(()=>chestEditor?.dispose());
|
|
997
1000
|
meshEditor=bindMeshEditor({pane:el('rig-pane'),canvas:el('rig-overlay'),project:()=>player?rigProject():null,mapping:()=>chestMapping,inspector:()=>selectedInspector(),source:meshSource,pause,changed:()=>redrawOverlay(false),download:doc=>{void exportMesh(doc);},apply:(doc,line)=>applyMeshDelta(doc,line),applied:()=>appliedOnStage?.schema==='rig-review-applied/3',resetBuild:()=>resetRebuild(stageWorld()),message,confirm:text=>window.confirm(tr(text)),token:name=>getComputedStyle(document.documentElement).getPropertyValue(name).trim()});viewDisposers.push(()=>meshEditor?.dispose());
|
|
998
|
-
weightsView=bindWeightsView({pane:el('rig-pane'),canvas:el('rig-overlay'),project:()=>player?rigProject():null,inspector:()=>selectedInspector(),slot:()=>parts?.value()?.slot??null,
|
|
999
|
-
model:()=>
|
|
1001
|
+
weightsView=bindWeightsView({pane:el('rig-pane'),canvas:el('rig-overlay'),project:()=>player?rigProject():null,inspector:()=>selectedInspector(),slot:()=>parts?.value()?.slot??stageDraftSelection?.slot??null,
|
|
1002
|
+
model:()=>hasStageModel()?partModel??undefined:null,setup:slot=>assets?setupPoseMesh(assets,partModel,slot,document.createElement('div')):null,changed:()=>redrawOverlay(false),
|
|
1000
1003
|
token:name=>getComputedStyle(document.documentElement).getPropertyValue(name).trim()});
|
|
1001
1004
|
viewDisposers.push(()=>weightsView?.dispose());weightsView.refresh();
|
|
1002
1005
|
bonesPanel=bindBonesPanel({pane:el('rig-pane'),canvas:el('rig-overlay'),project:()=>player?rigProject():null,mapping:()=>chestMapping,inspector:()=>selectedInspector(),pause,changed:()=>redrawOverlay(false),saved:()=>persistence?.save(),
|
|
@@ -1013,7 +1016,7 @@ function bind(): void {
|
|
|
1013
1016
|
physicsPanel=bindPhysicsPanel({preview:edits=>{const before=JSON.stringify(physicsPreview.read()),next=physicsPreview.sync(player,edits);if(player?.current&&!playing&&before!==JSON.stringify(next)){player.repose();drawRig(()=>player!.draw());}return physicsPreview.read();},previewRead:()=>physicsPreview.read(),apply:async ops=>{await applyPhysics(ops);},reset:resetPhysicsBuild,pane:el('rig-pane'),saved:()=>persistence?.save(),
|
|
1014
1017
|
bonePoints:bones=>{if(!player)return null;const project=rigProject(),pane=el('rig-pane').getBoundingClientRect(),view=el('rig-root').parentElement!.getBoundingClientRect(),out=new Map<string,{x:number;y:number}>();for(const name of bones){try{const b=player.bone(name),p=project(b.x,b.y);out.set(name,{x:p.x+view.left-pane.left,y:p.y+view.top-pane.top});}catch{/* a bone this model lacks is not pickable */}}return out;}});
|
|
1015
1018
|
viewDisposers.push(()=>physicsPanel?.dispose());
|
|
1016
|
-
meshPanel=bindMeshPanel({pane:el('rig-pane'),project:()=>player?rigProject():null,mapping:()=>chestMapping,bones:()=>
|
|
1019
|
+
meshPanel=bindMeshPanel({pane:el('rig-pane'),project:()=>player?rigProject():null,mapping:()=>chestMapping,bones:()=>activeSetupBones()??[],
|
|
1017
1020
|
apply:async(part,entry)=>{await applyMesh(part,entry);},reset:resetMeshBuild,folds:async()=>{await meshFolds();},changed:()=>{redrawOverlay(false);densityStrip?.changed();},saved:()=>persistence?.save(),
|
|
1018
1021
|
token:name=>getComputedStyle(document.documentElement).getPropertyValue(name).trim()});
|
|
1019
1022
|
viewDisposers.push(()=>meshPanel?.dispose());
|
|
@@ -1024,7 +1027,7 @@ function bind(): void {
|
|
|
1024
1027
|
bonePoints:bones=>{if(!player)return null;const project=rigProject(),out=new Map<string,{x:number;y:number}>();for(const name of bones){try{const b=player.bone(name);out.set(name,project(b.x,b.y));}catch{/* a bone this model lacks has no handle */}}return out;}});
|
|
1025
1028
|
viewDisposers.push(()=>idlePanel?.dispose());
|
|
1026
1029
|
rigFieldsPanel=bindRigFieldsPanel({apply:async ops=>{await applyRigFields(ops);},reset:resetRigFieldsBuild,reading:async(bone,relative)=>{await runReadings({readings:[{kind:'angle-range',bone,relative}]});},
|
|
1027
|
-
part:()=>parts?.value()?.slot??null,inspector:()=>selectedInspector(),pause,saved:()=>persistence?.save(),
|
|
1030
|
+
part:()=>parts?.value()?.slot??stageDraftSelection?.slot??null,inspector:()=>selectedInspector(),pause,saved:()=>persistence?.save(),
|
|
1028
1031
|
toPane:(x,y)=>{if(!player||!chestMapping.available)return null;const w=chestMapping.toWorld(x,y);return rigProject()(w.x,w.y);},
|
|
1029
1032
|
toRig:(x,y)=>player&&chestMapping.available?canvasToCrop(rigProject(),chestMapping.toWorld,{x,y}):null,
|
|
1030
1033
|
slotBox:slot=>{const frame=player?.posedFrame();if(!frame)return null;try{const b=partBounds(frame,slot);if(!b)return null;const project=rigProject(),a=project(b.x,b.y),c=project(b.x+b.width,b.y+b.height);return {left:Math.min(a.x,c.x),right:Math.max(a.x,c.x),top:Math.min(a.y,c.y),bottom:Math.max(a.y,c.y)};}catch{return null;}},
|
|
@@ -1033,7 +1036,7 @@ function bind(): void {
|
|
|
1033
1036
|
viewDisposers.push(()=>rigFieldsPanel?.dispose());
|
|
1034
1037
|
readingsPanel=bindReadingsPanel({run:()=>{void runReadings();},seek:seekReading});
|
|
1035
1038
|
retargetPanel=bindRetargetPanel({apply:body=>applyRetarget(body),reset:()=>{void resetRebuild(stageWorld());},seek:seekReading});
|
|
1036
|
-
requirementsPanel=bindRequirementsPanel({check:runRequirements,seek:seekReading,animation:()=>animation,slot:()=>parts?.value()?.slot??null,hash:sha256Hex});
|
|
1039
|
+
requirementsPanel=bindRequirementsPanel({check:runRequirements,seek:seekReading,animation:()=>animation,slot:()=>parts?.value()?.slot??stageDraftSelection?.slot??null,hash:sha256Hex});
|
|
1037
1040
|
const tickResize=new ResizeObserver(()=>renderReadingTicks());tickResize.observe(el('transport'));viewDisposers.push(()=>tickResize.disconnect());
|
|
1038
1041
|
viewDisposers.push(viewport.bindNavigation(rigPanCarry({player:()=>player},viewport.state),()=>!comments?.active()));
|
|
1039
1042
|
for(const [id,key] of [['layer-images','images'],['layer-mesh','mesh'],['layer-bones','bones']] as const)input(id).onchange=()=>{layers[key]=input(id).checked;redrawOverlay(false);};
|
|
@@ -1062,7 +1065,7 @@ async function start(): Promise<void> {
|
|
|
1062
1065
|
// Checkpoints and reference fold away when the package supplies neither.
|
|
1063
1066
|
(el('package-context') as HTMLDetailsElement).open = data.manifest.checkpoints.length > 0 || data.manifest.references.length > 0;
|
|
1064
1067
|
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';
|
|
1065
|
-
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();
|
|
1068
|
+
populateChestBones(); bind(); parts=new PartExplorer(el('workspace-left'),el('selected-part'),previous=>{const part=parts?.value();if(!stageCorrectionRebinding&&(previous?.side!==part?.side||previous?.slot!==part?.slot||previous?.mode!==part?.mode))stageDraftRequestToken++;if(player&&inspectionSourceState==='ready')animationPanel?.capture(player,parts?.frame('single'));else animationPanel?.capture(null,undefined);weightsView?.refresh();redrawOverlay(true);meshEditor?.selectionChanged();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();
|
|
1066
1069
|
const requestedId = new URLSearchParams(location.search).get('checkpoint'),initial=initialReviewSelection(data.manifest,requestedId,data.explicitReference?.id,data.initialAnimation??undefined),first=initial.checkpoint;
|
|
1067
1070
|
rigInput=data.manifest.model?{state:'pending'}:{state:'absent'};renderLayout();
|
|
1068
1071
|
if(initial.referenceId){select('reference-select').value=initial.referenceId;await showReference(initial.referenceId);}
|
|
@@ -1103,7 +1106,7 @@ function redrawOverlay(fresh:boolean):void {
|
|
|
1103
1106
|
if(!overlays||!player)return;
|
|
1104
1107
|
const project=rigProject();
|
|
1105
1108
|
const regions=[...chestRegions(),...(meshPanel?.overlayRegions()??[]),...(cutsPanel?.overlayRegions()??[]),...(clothPanel?.overlayRegions()??[])],circles=[...chestCircles(),...(meshPanel?.overlayCircles()??[])],markers=[...chestMarkers(),...(cutsPanel?.overlayMarkers()??[])];
|
|
1106
|
-
const value=fresh?overlays.refresh({player,frame:parts?.frame('single'),selectedSlot:parts?.value()?.slot,bones:(
|
|
1109
|
+
const value=fresh?overlays.refresh({player,frame:parts?.frame('single'),selectedSlot:parts?.value()?.slot,bones:(activeSetupBones()??[]).map(name=>({name})),project,settings:layers,regions,circles,markers,meshEdit:meshEditor?.overlay(),weights:weightsView?.overlay(),anchors:bonesPanel?.overlay()}):overlays.redraw({project,settings:layers,regions,circles,markers,meshEdit:meshEditor?.overlay(),weights:weightsView?.overlay(),anchors:bonesPanel?.overlay()});
|
|
1107
1110
|
lastOverlay=value;
|
|
1108
1111
|
text('layer-state',value.warnings.join(' · ')||'Actual last-drawn mesh edges / bone points');idlePanel?.place(duration);rigFieldsPanel?.place();if(!fresh&&value.needsCapture&&!playing&&!seekingControl)drawRig(()=>player!.draw());
|
|
1109
1112
|
}
|
|
@@ -1264,7 +1267,7 @@ async function setupPersistence():Promise<boolean> {
|
|
|
1264
1267
|
}
|
|
1265
1268
|
/** Setup's Chest regions tool: designation values, an overlay and a two-file client download. Nothing reaches the session's feedback or the package. */
|
|
1266
1269
|
function chestField(id:string){const node=document.getElementById(id) as HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement|null;return node?{value:node.value,...(node instanceof HTMLInputElement&&node.type==='checkbox'?{checked:node.checked}:{})}:undefined;}
|
|
1267
|
-
function chestEvaluation(){return evaluateChestForm(chestField,chestMapping,
|
|
1270
|
+
function chestEvaluation(){return evaluateChestForm(chestField,chestMapping,activeSetupBones());}
|
|
1268
1271
|
function chestRegions():OverlayRegion[]{
|
|
1269
1272
|
// #345: the chest overlay is drawn only while the Chest regions toggle is on.
|
|
1270
1273
|
if(!chestEditor?.active())return [];
|
|
@@ -1297,12 +1300,21 @@ function chestMarkers():OverlayMarker[]{
|
|
|
1297
1300
|
return [{at:p,tag,active:armed===key,colors:{stroke,fill:stroke,ink:token('--rv-landmark-ink'),labelBg:token('--rv-bust-label-bg')},...(key==='cleavage'?{guideTo:apexes}:{})}];});
|
|
1298
1301
|
}
|
|
1299
1302
|
function populateChestBones():void {
|
|
1300
|
-
const
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
+
const bones=activeSetupBones();
|
|
1304
|
+
const list=document.getElementById('lm-bones');if(list){list.replaceChildren();for(const name of bones??[])list.append(option(name,name));}
|
|
1305
|
+
const part=stageCorrectionPart??chestFormPart,seeded=rebuildStatus&&part?chestSeed(chestStatusForPart(rebuildStatus,part)):null;
|
|
1306
|
+
for(const row of chestRegionRows){
|
|
1307
|
+
const id=chestRowId(row,'bone'),nameId=chestRowId(row,'name'),node=select(id),current=node.value,seededRow=seeded?.rows.find(r=>r.row===row);
|
|
1308
|
+
const rowName=input(nameId).value.trim(),seededName=(seededRow?.fields[nameId]??'').trim();
|
|
1309
|
+
const keep=current||(node.disabled&&rowName&&rowName===seededName?(seededRow?.fields[id]??'').trim():'');
|
|
1310
|
+
node.replaceChildren(option('',bones?'Select bone':'No model bones'));
|
|
1311
|
+
for(const name of bones??[])node.append(option(name,name));
|
|
1312
|
+
if(bones&&keep&&bones.includes(keep))node.value=keep;
|
|
1313
|
+
node.disabled=!bones;
|
|
1314
|
+
}
|
|
1303
1315
|
}
|
|
1304
1316
|
function updateChestMapping():void {
|
|
1305
|
-
const root=
|
|
1317
|
+
const root=activeSetupBones()?.[0];let at:{x:number;y:number}|null=null;
|
|
1306
1318
|
if(player&&root){try{const bone=player.bone(root);at={x:bone.x,y:bone.y};}catch{at=null;}}
|
|
1307
1319
|
chestMapping=player?cropWorldMapping(assets?.stage,at):{available:false,reason:'CHEST_REGION_MAPPING_UNAVAILABLE: no compiled model drawn'};
|
|
1308
1320
|
renderChest();
|
|
@@ -1474,8 +1486,8 @@ function boneSetup(document:unknown):BoneSetup {
|
|
|
1474
1486
|
/** Setup's mesh edit: the selected slot's actual mesh as a typed delta. A two-file client download; nothing reaches the session or the package. */
|
|
1475
1487
|
/** Edit Mesh's source (#100): the selected slot's mesh in the model document at the setup pose (a never-played player's bones). */
|
|
1476
1488
|
function meshSource(){
|
|
1477
|
-
if(
|
|
1478
|
-
return meshEditSource({slot:parts?.value()?.slot??null,model:
|
|
1489
|
+
if(hasStageModel()&&!partModel)return {ok:false as const,code:'MESH_EDIT_RIG_UNAVAILABLE: the compiled model document is still loading'};
|
|
1490
|
+
return meshEditSource({slot:parts?.value()?.slot??stageDraftSelection?.slot??null,model:hasStageModel()?partModel:null,pose:slot=>assets?readSetupPose(assets,slot,document.createElement('div')):null,mapping:chestMapping});
|
|
1479
1491
|
}
|
|
1480
1492
|
async function exportMesh(doc:MeshEditDocument):Promise<void> {
|
|
1481
1493
|
const text=meshEditText(doc),digest=await sha256Hex(text);
|
|
@@ -1525,16 +1537,21 @@ async function applyRetarget(body:{sequence:string;map:PoseMap;flags:RetargetFla
|
|
|
1525
1537
|
async function applyMeshDelta(doc:MeshEditDocument,line:(text:string)=>void):Promise<{built:boolean;text:string;error:boolean}> {
|
|
1526
1538
|
if(rebuildBusy)return {built:false,text:'REBUILD_BUSY: an Apply is still running',error:true};
|
|
1527
1539
|
if(readOnly)return {built:false,text:readOnly,error:true};
|
|
1540
|
+
if(!inspectedModel&&appliedOnStage)return {built:false,text:MESH_DELTA_APPLIED_SOURCE,error:true};
|
|
1528
1541
|
const status=rebuildStatus??await loadRebuildStatus();
|
|
1542
|
+
if(!inspectedModel&&appliedOnStage)return {built:false,text:MESH_DELTA_APPLIED_SOURCE,error:true};
|
|
1529
1543
|
if(!status?.inputs)return {built:false,text:status?.reason??'REBUILD_STATUS_UNAVAILABLE',error:true};
|
|
1530
1544
|
const body:DeltaRequestBody={part:doc.slot,delta:doc,configHash:status.inputs.configHash},world=stageWorld();
|
|
1545
|
+
const priorBuildId=appliedOnStage?.buildId??'inspected',priorPart=stageCorrectionPart??stageDraftSelection?.part??null,token=++stageDraftRequestToken;
|
|
1531
1546
|
rebuildBusy=true;rebuildState();
|
|
1532
1547
|
try{
|
|
1533
1548
|
const result=await runRebuild<DeltaRequestBody,DeltaJobView>(body,{post:value=>api<DeltaJobView|RebuildRefusal>('/api/rebuild',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(value)}),get:id=>api<DeltaJobView>(`/api/rebuild/${id}`),sleep:ms=>new Promise(resolve=>setTimeout(resolve,ms)),onLine:text=>line(text)});
|
|
1534
1549
|
const outcome=deltaOutcomeLine(result),next=stageModel(result,{url:'',hash:stageModelHash??''});
|
|
1535
1550
|
if(next.id===null||!('id' in result)){message(outcome.text,true);return {built:false,text:outcome.text,error:true};}
|
|
1536
|
-
await swapRig(new URL(access.route(next.url),location.href).href,access.route(`/rebuild/${next.id}/`),next.hash,world);
|
|
1551
|
+
if(inspectedModel)await swapRig(new URL(access.route(next.url),location.href).href,access.route(`/rebuild/${next.id}/`),next.hash,world);
|
|
1552
|
+
else{const target=draftScratchTarget(result.id,result.build?.modelUrl,result.build?.modelHash);await prepareStageDraftBuild(target.buildId,target.sha256,{target,transition:{kind:'apply',token,priorBuildId,priorPart},world});}
|
|
1537
1553
|
appliedOnStage=deltaAppliedRecord(result);stageCheck=null;stageChanged({kind:'apply',via:'delta'});
|
|
1554
|
+
if(!inspectedModel)refreshStageParts?.();
|
|
1538
1555
|
meshEditor?.setStatusNote(outcome.text,false);
|
|
1539
1556
|
const draft=el<HTMLTextAreaElement>('rebuild-applied');draft.value=JSON.stringify(appliedOnStage);draft.dispatchEvent(new Event('input',{bubbles:true}));
|
|
1540
1557
|
message(outcome.text);
|
|
@@ -1575,8 +1592,9 @@ async function loadRebuildStatus():Promise<RebuildStatusView|null> {
|
|
|
1575
1592
|
rigFieldsPanel?.load(rebuildStatus.inputs?rebuildStatus.fields??{}:null,rebuildStatus.inputs?null:rebuildStatus.reason??'RIG_FIELDS_UNAVAILABLE: no producer handoff');
|
|
1576
1593
|
clothPanel?.load(rebuildStatus.inputs?rebuildStatus.cloth??null:null,rebuildStatus.inputs?null:rebuildStatus.reason??'CLOTH_UNAVAILABLE: no producer handoff');
|
|
1577
1594
|
cutsPanel?.load(rebuildStatus.inputs&&rebuildStatus.cuts?rebuildStatus.cuts.config:null,rebuildStatus.bones??[],rebuildStatus.inputs?null:rebuildStatus.reason??'CUTS_UNAVAILABLE: no producer handoff',rebuildStatus.cuts?.build??null);
|
|
1578
|
-
meshPanel?.load(rebuildStatus.inputs?rebuildStatus.meshes??{}:null,rebuildStatus.inputs?null:rebuildStatus.reason??'MESH_PANEL_UNAVAILABLE: no producer handoff');meshPanel?.select(parts?.value()?.slot??null);
|
|
1595
|
+
meshPanel?.load(rebuildStatus.inputs?rebuildStatus.meshes??{}:null,rebuildStatus.inputs?null:rebuildStatus.reason??'MESH_PANEL_UNAVAILABLE: no producer handoff');meshPanel?.select(parts?.value()?.slot??stageDraftSelection?.slot??null);
|
|
1579
1596
|
animationPanel?.loadSource(rebuildStatus.animations??null,rebuildStatus.reason);
|
|
1597
|
+
if(!inspectedModel&&canManageApplied())void refreshApplied();
|
|
1580
1598
|
renderDropNotices();
|
|
1581
1599
|
return rebuildStatus;
|
|
1582
1600
|
}
|
|
@@ -1591,7 +1609,7 @@ function rebuildState():void {chestEditor?.rebuildState({busy:rebuildBusy,applie
|
|
|
1591
1609
|
/** #166: the session's applied records (the server's stack), the last one on the stage when the stage shows it. */
|
|
1592
1610
|
let appliedHistory:AppliedHistoryView|null=null;
|
|
1593
1611
|
async function refreshApplied():Promise<void> {
|
|
1594
|
-
if(!
|
|
1612
|
+
if(!canManageApplied())return;
|
|
1595
1613
|
try{appliedHistory=await api<AppliedHistoryView>('/api/rebuild/history');}catch{return;}
|
|
1596
1614
|
renderApplied();
|
|
1597
1615
|
}
|
|
@@ -1605,7 +1623,7 @@ function chestPartForNotice():string|null {
|
|
|
1605
1623
|
return 'regions' in designated?pickPart(rebuildStatus,designated.regions):rebuildStatus.parts.length===1?rebuildStatus.parts[0]!.name:null;
|
|
1606
1624
|
}
|
|
1607
1625
|
function renderDropNotices():void {
|
|
1608
|
-
const slot=parts?.value()?.slot??null,meshPart=meshPanel?.part()??slot,chestPart=chestPartForNotice();
|
|
1626
|
+
const slot=parts?.value()?.slot??stageDraftSelection?.slot??null,meshPart=meshPanel?.part()??slot,chestPart=chestPartForNotice();
|
|
1609
1627
|
for(const node of document.querySelectorAll<HTMLElement>('[data-rebuild-drop]')){
|
|
1610
1628
|
const panel=node.dataset.rebuildDrop as RebuildPanelKind;
|
|
1611
1629
|
const part=panel==='mesh'?meshPart:panel==='mesh-edit'?slot:panel==='chest'?chestPart:null;
|
|
@@ -1697,8 +1715,8 @@ function appliedStatus(text:string,error=false):void {const node=el('applied-sta
|
|
|
1697
1715
|
*/
|
|
1698
1716
|
async function undoApply():Promise<UndoView|null> {
|
|
1699
1717
|
const from=appliedOnStage?.buildId;
|
|
1700
|
-
if(rebuildBusy||readOnly||!from||!
|
|
1701
|
-
const world=stageWorld();
|
|
1718
|
+
if(rebuildBusy||readOnly||!from||!canManageApplied())return null;
|
|
1719
|
+
const world=stageWorld(),priorBuildId=from,priorPart=stageCorrectionPart??stageDraftSelection?.part??null,token=++stageDraftRequestToken;
|
|
1702
1720
|
rebuildBusy=true;rebuildState();appliedStatus('Undoing the last Apply…');
|
|
1703
1721
|
try{
|
|
1704
1722
|
let result=await api<UndoView>('/api/rebuild/undo',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({from})});
|
|
@@ -1710,15 +1728,21 @@ async function undoApply():Promise<UndoView|null> {
|
|
|
1710
1728
|
result={status:'built',undone,job,history:await api<AppliedHistoryView>('/api/rebuild/history')};
|
|
1711
1729
|
}
|
|
1712
1730
|
if(result.status==='refused'){appliedStatus(result.error,true);message(result.error,true);return result;}
|
|
1713
|
-
if(result.status==='inspected'){
|
|
1731
|
+
if(result.status==='inspected'){
|
|
1732
|
+
if(inspectedModel)await swapRig(inspectedModel.url,inspectedModel.prefix,inspectedModel.sha256,world);
|
|
1733
|
+
else{const target=draftInspectedTarget();await prepareStageDraftBuild('inspected',target.sha256,{target,transition:{kind:'undo',token,priorBuildId,priorPart},world});}
|
|
1734
|
+
appliedOnStage=null;stageCheck=null;
|
|
1735
|
+
}
|
|
1714
1736
|
else{
|
|
1715
1737
|
const job=result.job;if(!job.build)throw new Error('the restored job carries no build');
|
|
1716
|
-
await swapRig(new URL(access.route(job.build.modelUrl),location.href).href,access.route(`/rebuild/${job.id}/`),job.build.modelHash,world);
|
|
1738
|
+
if(inspectedModel)await swapRig(new URL(access.route(job.build.modelUrl),location.href).href,access.route(`/rebuild/${job.id}/`),job.build.modelHash,world);
|
|
1739
|
+
else{const target=draftScratchTarget(job.id,job.build.modelUrl,job.build.modelHash);await prepareStageDraftBuild(job.id,target.sha256,{target,transition:{kind:'undo',token,priorBuildId,priorPart},world});}
|
|
1717
1740
|
appliedOnStage=recordFor(job);stageCheck=(job as PatchJobView).kind==='patch'?{lines:[...job.lines],check:(job as PatchJobView).check}:null;
|
|
1718
1741
|
// #186: a restored retarget build gets what its Apply set — its own clock, then its animation selected.
|
|
1719
1742
|
const retarget=retargetStage(job,job.build.modelHash);stageClock=retarget?.clock??null;
|
|
1720
1743
|
if(retarget&&assets?.animations.some(clip=>clip.name===retarget.animation))chooseAnimation(retarget.animation);
|
|
1721
1744
|
}
|
|
1745
|
+
if(!inspectedModel)refreshStageParts?.();
|
|
1722
1746
|
stageChanged({kind:'undo'});
|
|
1723
1747
|
// The panels mark the ops the stage's build applied; the pending edits stay as they are.
|
|
1724
1748
|
renderAppliedBlocks(result.status==='built'?result.job:null);
|
|
@@ -1727,7 +1751,8 @@ async function undoApply():Promise<UndoView|null> {
|
|
|
1727
1751
|
cutsPanel?.shown(block==='cuts'?restored:null);clothPanel?.shown(block==='cloth'?restored:null);
|
|
1728
1752
|
const draft=el<HTMLTextAreaElement>('rebuild-applied');draft.value=appliedOnStage?JSON.stringify(appliedOnStage):'';draft.dispatchEvent(new Event('input',{bubbles:true}));
|
|
1729
1753
|
appliedHistory=result.history;
|
|
1730
|
-
const
|
|
1754
|
+
const inspectedHash=inspectedModel?.sha256??data.reviewedSource.rig?.sha256??data.sourceHash;
|
|
1755
|
+
const text=`Undid ${result.undone.slice(0,12)}… · the stage is ${result.status==='inspected'?`the inspected build (model ${inspectedHash.slice(0,12)}…)`:`record ${result.history.depth} (model ${stageModelHash?.slice(0,12)}…)`} · ${result.history.depth} applied record(s) left`;
|
|
1731
1756
|
appliedStatus(text);message(text);redrawOverlay(true);
|
|
1732
1757
|
return result;
|
|
1733
1758
|
}catch(error){const text=`UNDO_FAILED: ${errorText(error)}`;appliedStatus(text,true);message(text,true);return {status:'refused',error:text,producerLine:null};}
|
|
@@ -1739,7 +1764,8 @@ async function applyRebuild():Promise<void> {
|
|
|
1739
1764
|
if(readOnly){chestEditor?.notify(readOnly,true);return;}
|
|
1740
1765
|
const loadedStatus=rebuildStatus??await loadRebuildStatus();
|
|
1741
1766
|
const status=loadedStatus?chestStatusForPart(loadedStatus,stageCorrectionPart):loadedStatus;
|
|
1742
|
-
|
|
1767
|
+
const selectedSlot=parts?.value()?.slot??stageDraftSelection?.slot??null;
|
|
1768
|
+
if(stageCorrectionPart&&selectedSlot!==stageCorrectionPart){chestEditor?.notify('STAGE_DRAFT_MISMATCH',true);return;}
|
|
1743
1769
|
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;}
|
|
1744
1770
|
let part:string,body:RebuildRequestBody;const lines:string[]=[];
|
|
1745
1771
|
if(chestEditor?.mode()==='landmarks'){
|
|
@@ -1751,6 +1777,7 @@ async function applyRebuild():Promise<void> {
|
|
|
1751
1777
|
const picked=pickPart(status,designated.regions);if(!picked){chestEditor?.notify(`REBUILD_PART_AMBIGUOUS: the config states ${status.parts.length} contour meshes and the designated bones name none of them alone`,true);return;}
|
|
1752
1778
|
part=picked;body={part,regions:designated.regions,configHash:status.inputs.configHash};
|
|
1753
1779
|
}
|
|
1780
|
+
const priorBuildId=appliedOnStage?.buildId??'inspected',priorPart=stageCorrectionPart??stageDraftSelection?.part??null,token=++stageDraftRequestToken;
|
|
1754
1781
|
rebuildBusy=true;rebuildState();chestEditor?.notify(`Rebuilding ${part} with ${status.producer?.package} ${status.producer?.version}…`,false,[]);
|
|
1755
1782
|
try{
|
|
1756
1783
|
const result=await runRebuild(body,{post:value=>api<RebuildJobView|RebuildRefusal>('/api/rebuild',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(value)}),get:id=>api<RebuildJobView>(`/api/rebuild/${id}`),sleep:ms=>new Promise(resolve=>setTimeout(resolve,ms)),
|
|
@@ -1758,8 +1785,10 @@ async function applyRebuild():Promise<void> {
|
|
|
1758
1785
|
const outcome=outcomeLine(result);
|
|
1759
1786
|
// A refusal stays readable in full: the bar's status line is one line, so the log ends with the producer's line verbatim.
|
|
1760
1787
|
if(!('id' in result)||result.status!=='built'||!result.build){chestEditor?.notify(outcome.text,true,[...lines.slice(-5),outcome.text]);message(outcome.text,true);return;}
|
|
1761
|
-
await swapRig(new URL(access.route(result.build.modelUrl),location.href).href,access.route(`/rebuild/${result.id}/`),result.build.modelHash);
|
|
1788
|
+
if(inspectedModel)await swapRig(new URL(access.route(result.build.modelUrl),location.href).href,access.route(`/rebuild/${result.id}/`),result.build.modelHash);
|
|
1789
|
+
else{const target=draftScratchTarget(result.id,result.build.modelUrl,result.build.modelHash);await prepareStageDraftBuild(target.buildId,target.sha256,{target,transition:{kind:'apply',token,priorBuildId,priorPart}});}
|
|
1762
1790
|
appliedOnStage=appliedRecord(result);stageCheck=null;stageChanged({kind:'apply',via:'regions'});
|
|
1791
|
+
if(!inspectedModel)refreshStageParts?.();
|
|
1763
1792
|
const draft=el<HTMLTextAreaElement>('rebuild-applied');draft.value=JSON.stringify(appliedOnStage);draft.dispatchEvent(new Event('input',{bubbles:true}));
|
|
1764
1793
|
// The log closes on success so nothing floats over the rebuilt stage; a refusal keeps it open.
|
|
1765
1794
|
chestEditor?.notify(outcome.text,false,[]);message(outcome.text);
|
|
@@ -1776,7 +1805,7 @@ async function applyRebuild():Promise<void> {
|
|
|
1776
1805
|
async function applyPatch(patch:ConfigPatch,world:StageWorld|null=null):Promise<PatchJobView|RebuildRefusal> {
|
|
1777
1806
|
if(rebuildBusy)return {status:'refused',error:'REBUILD_BUSY: an Apply is still running',producerLine:null};
|
|
1778
1807
|
if(readOnly){chestEditor?.notify(readOnly,true);return {status:'refused',error:readOnly,producerLine:null};}
|
|
1779
|
-
const lines:string[]=[];
|
|
1808
|
+
const lines:string[]=[],priorBuildId=appliedOnStage?.buildId??'inspected',priorPart=stageCorrectionPart??stageDraftSelection?.part??null,token=++stageDraftRequestToken;
|
|
1780
1809
|
rebuildBusy=true;rebuildState();chestEditor?.notify(`Applying patch (${patch.op.cmd}, ${patch.ops.length} op(s))…`,false,[]);
|
|
1781
1810
|
try{
|
|
1782
1811
|
// #112: with "Use for readings" on, Apply's check reads the exported schedule of the clip check renders (its idle).
|
|
@@ -1786,8 +1815,10 @@ async function applyPatch(patch:ConfigPatch,world:StageWorld|null=null):Promise<
|
|
|
1786
1815
|
onLine:line=>{lines.push(line);chestEditor?.notify(line.trim()||'…',false,lines.slice(-6));}});
|
|
1787
1816
|
const outcome=patchOutcomeLine(result),next=stageModel(result,{url:'',hash:stageModelHash??''});
|
|
1788
1817
|
if(next.id===null||!('id' in result)){chestEditor?.notify(outcome.text,true,[...lines.slice(-5),outcome.text]);message(outcome.text,true);return result;}
|
|
1789
|
-
await swapRig(new URL(access.route(next.url),location.href).href,access.route(`/rebuild/${next.id}/`),next.hash,world);
|
|
1818
|
+
if(inspectedModel)await swapRig(new URL(access.route(next.url),location.href).href,access.route(`/rebuild/${next.id}/`),next.hash,world);
|
|
1819
|
+
else{const target=draftScratchTarget(result.id,result.build?.modelUrl,result.build?.modelHash);await prepareStageDraftBuild(target.buildId,target.sha256,{target,transition:{kind:'apply',token,priorBuildId,priorPart},world});}
|
|
1790
1820
|
appliedOnStage=patchAppliedRecord(result);stageCheck={lines:[...result.lines],check:result.check};stageChanged({kind:'apply',via:'patch'});
|
|
1821
|
+
if(!inspectedModel)refreshStageParts?.();
|
|
1791
1822
|
const draft=el<HTMLTextAreaElement>('rebuild-applied');draft.value=JSON.stringify(appliedOnStage);draft.dispatchEvent(new Event('input',{bubbles:true}));
|
|
1792
1823
|
chestEditor?.notify(outcome.text,outcome.error,[]);message(outcome.text,outcome.error);
|
|
1793
1824
|
return result;
|
|
@@ -2224,9 +2255,14 @@ function sampleLocals(bone:string,dt:number,n:number):{t:number;rotation:number;
|
|
|
2224
2255
|
return [...rows.values()].sort((a,b)=>a.t-b.t);
|
|
2225
2256
|
}
|
|
2226
2257
|
async function resetRebuild(world:StageWorld|null=null):Promise<void> {
|
|
2227
|
-
if(rebuildBusy||(!appliedOnStage&&!stripPending)||!
|
|
2258
|
+
if(rebuildBusy||(!appliedOnStage&&!stripPending)||!canManageApplied())return;
|
|
2259
|
+
const priorBuildId=appliedOnStage?.buildId??'inspected',priorPart=stageCorrectionPart??stageDraftSelection?.part??null,token=++stageDraftRequestToken;
|
|
2228
2260
|
rebuildBusy=true;rebuildState();
|
|
2229
|
-
try{
|
|
2261
|
+
try{
|
|
2262
|
+
if(inspectedModel)await swapRig(inspectedModel.url,inspectedModel.prefix,inspectedModel.sha256,world);
|
|
2263
|
+
else{const target=draftInspectedTarget();await prepareStageDraftBuild('inspected',target.sha256,{target,transition:{kind:'reset',token,priorBuildId,priorPart},world});}
|
|
2264
|
+
appliedOnStage=null;stageCheck=null;stageChanged({kind:'reset'});if(!inspectedModel)refreshStageParts?.();animationPanel?.reconcileStageApplied(null);chestEditor?.notify('Reset: the inspected build is on the stage. The draft keeps the last applied state.',false);message('Reset to the inspected build.');
|
|
2265
|
+
}
|
|
2230
2266
|
catch(error){chestEditor?.notify(`REBUILD_RESET_FAILED: ${errorText(error)}`,true);}
|
|
2231
2267
|
finally{rebuildBusy=false;rebuildState();}
|
|
2232
2268
|
}
|
|
@@ -2435,23 +2471,297 @@ function setupComments():void {
|
|
|
2435
2471
|
}
|
|
2436
2472
|
|
|
2437
2473
|
/** Open the existing precision instruments only after re-reading the same displayed draft binding. */
|
|
2438
|
-
|
|
2474
|
+
interface StageDraftModelTarget {buildId:string;url:string;prefix:string;sha256:string}
|
|
2475
|
+
interface StageDraftTransition {
|
|
2476
|
+
kind:'open'|'apply'|'undo'|'reset';
|
|
2477
|
+
token:number;
|
|
2478
|
+
priorBuildId:string;
|
|
2479
|
+
priorPart:string|null;
|
|
2480
|
+
expectedPart?:string|null;
|
|
2481
|
+
expectedSourceHash?:string;
|
|
2482
|
+
instrument?:string;
|
|
2483
|
+
}
|
|
2484
|
+
let stageCorrectionPart:string|null=null,stageCorrectionRebinding=0,stageDraftRequestToken=0;
|
|
2485
|
+
let stageDraftSelection:{part:string;slot:string;skin:string;attachment:string;sourceHash:string;buildId:string}|null=null;
|
|
2486
|
+
let stageCommittedEntries:PartEntry[]|null=null;
|
|
2487
|
+
let stageDraftTarget:StageDraftModelTarget|null=null;
|
|
2488
|
+
let refreshStageParts:(()=>void)|null=null;
|
|
2489
|
+
function canManageApplied():boolean{return Boolean(inspectedModel||data?.capabilities?.preRig||rebuildStatus?.draft);}
|
|
2490
|
+
function draftInspectedTarget():StageDraftModelTarget{
|
|
2491
|
+
const rig=data?.reviewedSource?.rig;
|
|
2492
|
+
if(!rig||typeof rig.path!=='string'||!rig.path||typeof rig.sha256!=='string'||!rig.sha256)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2493
|
+
return {buildId:'inspected',url:new URL(assetUrl(rig.path),location.href).href,prefix:access.route('/assets/'),sha256:rig.sha256};
|
|
2494
|
+
}
|
|
2495
|
+
function draftScratchTarget(buildId:unknown,modelUrl:unknown,modelHash:unknown):StageDraftModelTarget{
|
|
2496
|
+
if(typeof buildId!=='string'||!buildId||buildId==='inspected'||typeof modelUrl!=='string'||!modelUrl||typeof modelHash!=='string'||!modelHash)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2497
|
+
return {buildId,url:new URL(access.route(modelUrl),location.href).href,prefix:access.route(`/rebuild/${buildId}/`),sha256:modelHash};
|
|
2498
|
+
}
|
|
2499
|
+
async function resolveStageDraftTarget(buildId:string):Promise<StageDraftModelTarget>{
|
|
2500
|
+
if(buildId==='inspected')return draftInspectedTarget();
|
|
2501
|
+
if(!appliedOnStage||appliedOnStage.buildId!==buildId||typeof appliedOnStage.modelHash!=='string'||!appliedOnStage.modelHash)throw new Error('STAGE_DRAFT_STALE');
|
|
2502
|
+
if(stageDraftTarget&&stageDraftTarget.buildId===buildId&&stageDraftTarget.sha256===appliedOnStage.modelHash)return stageDraftTarget;
|
|
2503
|
+
const job=await api<AnyJobView>(`/api/rebuild/${buildId}`);
|
|
2504
|
+
if(!job||job.id!==buildId||job.status!=='built'||!job.build||job.build.modelHash!==appliedOnStage.modelHash)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2505
|
+
return draftScratchTarget(job.id,job.build.modelUrl,job.build.modelHash);
|
|
2506
|
+
}
|
|
2507
|
+
async function prepareStageDraftBuild(
|
|
2508
|
+
buildId:string,
|
|
2509
|
+
nextModelHash:string|null,
|
|
2510
|
+
options?:{target?:StageDraftModelTarget;transition?:StageDraftTransition;world?:StageWorld|null},
|
|
2511
|
+
):Promise<{status:RebuildStatusView|null;mapping:{part:string;slot:string;skin:string;attachment:string}}>{
|
|
2512
|
+
if(readOnly)throw new Error(readOnly);
|
|
2513
|
+
const transition=options?.transition;
|
|
2514
|
+
if(transition){
|
|
2515
|
+
if(transition.token!==stageDraftRequestToken)throw new Error('STAGE_DRAFT_STALE');
|
|
2516
|
+
if(transition.kind==='open'){
|
|
2517
|
+
if(rebuildBusy||(appliedOnStage?.buildId??'inspected')!==buildId)throw new Error('STAGE_DRAFT_STALE');
|
|
2518
|
+
}else{
|
|
2519
|
+
if(!rebuildBusy||(appliedOnStage?.buildId??'inspected')!==transition.priorBuildId||(stageCorrectionPart??stageDraftSelection?.part??null)!==transition.priorPart)throw new Error('STAGE_DRAFT_STALE');
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
let nextAssets:ModelAssets|null=null;
|
|
2524
|
+
let target:StageDraftModelTarget;
|
|
2525
|
+
let verifiedDoc:unknown=null;
|
|
2526
|
+
let verifiedEntries:PartEntry[]=[];
|
|
2527
|
+
let verifiedBones:string[]=[];
|
|
2528
|
+
let verifiedRegions:ReturnType<typeof pageRegionTable>|null=null;
|
|
2529
|
+
let stageData:{sourceHash:string;draft?:{inspectionOnly?:boolean;buildId:string;mappings:{part:string;slot:string;skin:string;attachment:string;vertices:number;triangles:number}[]};draftUnavailable?:string};
|
|
2530
|
+
let mapping:{part:string;slot:string;skin:string;attachment:string}|undefined;
|
|
2531
|
+
let status:RebuildStatusView|null=rebuildStatus;
|
|
2532
|
+
try{
|
|
2533
|
+
stageData=await api<{sourceHash:string;draft?:{inspectionOnly?:boolean;buildId:string;mappings:{part:string;slot:string;skin:string;attachment:string;vertices:number;triangles:number}[]};draftUnavailable?:string}>('/api/stage-parts',{headers:{'X-Review-Stage-Build':buildId}});
|
|
2534
|
+
if(!stageData.draft||stageData.draft.buildId!==buildId)throw new Error(stageData.draftUnavailable??'STAGE_DRAFT_MISMATCH');
|
|
2535
|
+
if(stageData.draft.inspectionOnly)throw new Error('PARTS_VERDICT_READ_ONLY: Stage 1 draft is inspection-only');
|
|
2536
|
+
if(transition?.expectedSourceHash!==undefined&&stageData.sourceHash!==transition.expectedSourceHash)throw new Error(stageData.draftUnavailable??'STAGE_DRAFT_MISMATCH');
|
|
2537
|
+
const targetPart=transition?.expectedPart??stageCorrectionPart??stageDraftSelection?.part??null;
|
|
2538
|
+
mapping=targetPart?stageData.draft.mappings.find(m=>m.part===targetPart):stageData.draft.mappings[0];
|
|
2539
|
+
if(!mapping||mapping.slot!==mapping.part)throw new Error(stageData.draftUnavailable??'STAGE_DRAFT_MISMATCH');
|
|
2540
|
+
if(transition?.kind==='open'){
|
|
2541
|
+
status=rebuildStatus??await loadRebuildStatus();
|
|
2542
|
+
if(!status)throw new Error('REBUILD_STATUS_UNAVAILABLE');
|
|
2543
|
+
if(transition.instrument==='chest'&&!status.parts.some(part=>part.name===mapping!.part))throw new Error(`REBUILD_PART_NOT_CONTOUR: ${mapping.part}`);
|
|
2544
|
+
}
|
|
2545
|
+
if(!nextModelHash)throw new Error(buildId==='inspected'?'STAGE_DRAFT_MISMATCH':'STAGE_DRAFT_STALE');
|
|
2546
|
+
target=options?.target??await resolveStageDraftTarget(buildId);
|
|
2547
|
+
if(target.buildId!==buildId||target.sha256!==nextModelHash||!target.url||!target.prefix)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2548
|
+
nextAssets=await loadModel({modelUrl:target.url,...stageLoadInputs(target.url,target.sha256),resolvePage:(name,url)=>{const pageUrl=new URL(name,url);if(pageUrl.origin!==location.origin||!pageUrl.pathname.startsWith(target.prefix))throw new Error(`Model page escapes its build: ${name}`);return pageUrl.href;}});
|
|
2549
|
+
const loadedDoc=await loadModelDocument(target.url,target.sha256);
|
|
2550
|
+
if(!loadedDoc.ok)throw new Error('PART_SOURCE_CHANGED: model bytes differ from reviewed SHA-256');
|
|
2551
|
+
verifiedDoc=loadedDoc.document;
|
|
2552
|
+
const rawSlots=verifiedDoc&&typeof verifiedDoc==='object'&&!Array.isArray(verifiedDoc)?(verifiedDoc as {slots?:unknown}).slots:null;
|
|
2553
|
+
if(!Array.isArray(rawSlots))throw new Error('Part catalog requires bounded model slots and skins');
|
|
2554
|
+
const slotNames=rawSlots.map(s=>s&&typeof s==='object'&&typeof (s as {name?:unknown}).name==='string'?(s as {name:string}).name:'');
|
|
2555
|
+
verifiedEntries=partCatalog(verifiedDoc,slotNames);
|
|
2556
|
+
verifiedBones=modelBoneNames(verifiedDoc);
|
|
2557
|
+
verifiedRegions=pageRegionTable(verifiedDoc);
|
|
2558
|
+
const slotEntry=verifiedEntries.find(e=>e.slot===mapping!.slot);
|
|
2559
|
+
if(!slotEntry||!slotEntry.declarations.some(d=>d.skin===mapping!.skin&&d.attachment===mapping!.attachment&&d.kind==='mesh'))throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2560
|
+
const setupPose=readSetupPose(nextAssets,mapping.slot,document.createElement('div'));
|
|
2561
|
+
if(!setupPose.identity||setupPose.identity.skin!==mapping.skin||setupPose.identity.attachment!==mapping.attachment||!setupPose.readMesh())throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2562
|
+
if(!verifiedBones.length)throw new Error('CHEST_REGION_MAPPING_UNAVAILABLE: no compiled model drawn');
|
|
2563
|
+
|
|
2564
|
+
const finalStage=await api<{sourceHash:string;draft?:{inspectionOnly?:boolean;buildId:string;mappings:{part:string;slot:string;skin:string;attachment:string}[]};draftUnavailable?:string}>('/api/stage-parts',{headers:{'X-Review-Stage-Build':buildId}});
|
|
2565
|
+
if(!finalStage.draft||finalStage.draft.buildId!==buildId||finalStage.sourceHash!==stageData.sourceHash)throw new Error(finalStage.draftUnavailable??'STAGE_DRAFT_STALE');
|
|
2566
|
+
if(finalStage.draft.inspectionOnly)throw new Error('PARTS_VERDICT_READ_ONLY: Stage 1 draft is inspection-only');
|
|
2567
|
+
const finalMapping=finalStage.draft.mappings.find(m=>m.part===mapping!.part);
|
|
2568
|
+
if(!finalMapping||finalMapping.slot!==mapping.slot||finalMapping.skin!==mapping.skin||finalMapping.attachment!==mapping.attachment)throw new Error(finalStage.draftUnavailable??'STAGE_DRAFT_MISMATCH');
|
|
2569
|
+
|
|
2570
|
+
if(readOnly)throw new Error(readOnly);
|
|
2571
|
+
if(transition){
|
|
2572
|
+
if(transition.token!==stageDraftRequestToken)throw new Error('STAGE_DRAFT_STALE');
|
|
2573
|
+
if(transition.kind==='open'){
|
|
2574
|
+
if(rebuildBusy||(appliedOnStage?.buildId??'inspected')!==buildId)throw new Error('STAGE_DRAFT_STALE');
|
|
2575
|
+
}else{
|
|
2576
|
+
if(!rebuildBusy||(appliedOnStage?.buildId??'inspected')!==transition.priorBuildId||(stageCorrectionPart??stageDraftSelection?.part??null)!==transition.priorPart)throw new Error('STAGE_DRAFT_STALE');
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
}catch(error){
|
|
2580
|
+
try{nextAssets?.dispose();}catch{/* ignore */}
|
|
2581
|
+
throw error;
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
const rigRoot=el('rig-root');
|
|
2585
|
+
const prevNodes=[...rigRoot.childNodes];
|
|
2586
|
+
const prevRootStyle={left:rigRoot.style.left,top:rigRoot.style.top,transform:rigRoot.style.transform,transformOrigin:rigRoot.style.transformOrigin,clipPath:rigRoot.style.clipPath};
|
|
2587
|
+
const prevPlayer=player,prevAssets=assets,prevPartModel=partModel,prevStageModelBones=stageModelBones,prevCommittedEntries=stageCommittedEntries;
|
|
2588
|
+
const prevInspectionSourceState=inspectionSourceState,prevStageModelHash=stageModelHash,prevStageSource=stageSource,prevSetupChestWorld=setupChestWorld,prevChestMapping=chestMapping,prevRigInput=rigInput,prevSelection=stageDraftSelection,prevStageDraftTarget=stageDraftTarget;
|
|
2589
|
+
const prevPartValue=parts?.value()??null,prevPartRefusal=parts?.refusal('single')??null;
|
|
2590
|
+
const prevView=view,prevEffectiveView=effectiveView,prevViewportState=structuredClone(viewport.state),prevInspector=selectedInspector(document);
|
|
2591
|
+
const prevInspectorStates=[...document.querySelectorAll<HTMLElement>('[data-inspector]')].map(node=>({node,pressed:node.getAttribute('aria-pressed'),selected:node.getAttribute('aria-selected')}));
|
|
2592
|
+
const prevAnimation=animation,prevTime=time,prevDuration=duration,prevWasPlaying=playing;
|
|
2593
|
+
const partSetNode=document.getElementById('part-set') as HTMLSelectElement|null;
|
|
2594
|
+
const keepSet=!partSetNode||partSetNode.disabled?'':partSetNode.value;
|
|
2595
|
+
const animSelect=document.getElementById('animation-select') as HTMLSelectElement|null;
|
|
2596
|
+
const prevAnimationOptions=animSelect?[...animSelect.childNodes]:[];
|
|
2597
|
+
const prevAnimationControl=animSelect?{disabled:animSelect.disabled,value:animSelect.value}:null;
|
|
2598
|
+
const prevSetOptions=partSetNode?[...partSetNode.childNodes]:[];
|
|
2599
|
+
const prevSetControl=partSetNode?{disabled:partSetNode.disabled,value:partSetNode.value}:null;
|
|
2600
|
+
const prevStageControls=['rig-empty','player-state','renderer-state','layer-images','layer-mesh','layer-bones'].map(id=>{
|
|
2601
|
+
const node=document.getElementById(id) as HTMLInputElement|null;
|
|
2602
|
+
return {node,hidden:node?.hidden,disabled:node?.disabled,text:node?.textContent};
|
|
2603
|
+
});
|
|
2604
|
+
let nextPlayer:RigPlayer|null=null;
|
|
2605
|
+
stageCorrectionRebinding++;
|
|
2606
|
+
try{
|
|
2607
|
+
pause();
|
|
2608
|
+
// Release the previous renderer's root clip while retaining its pose and views for rollback.
|
|
2609
|
+
prevPlayer?.renderer.render({order:[]});
|
|
2610
|
+
rigRoot.replaceChildren();
|
|
2611
|
+
nextPlayer=new RigPlayer(rigRoot,nextAssets);
|
|
2612
|
+
// A fresh player's draw has no held pose. Clearing track 0 publicly poses Setup.
|
|
2613
|
+
nextPlayer.clear();
|
|
2614
|
+
const nextSetupChest=readSetupChest(nextPlayer);
|
|
2615
|
+
let rootAt:{x:number;y:number}|null=null;
|
|
2616
|
+
try{const b=nextPlayer.bone(verifiedBones[0]!);rootAt={x:b.x,y:b.y};}catch{rootAt=null;}
|
|
2617
|
+
const nextMapping=cropWorldMapping(nextAssets.stage,rootAt);
|
|
2618
|
+
if(!nextMapping.available)throw new Error(nextMapping.reason);
|
|
2619
|
+
|
|
2620
|
+
assets=nextAssets;
|
|
2621
|
+
player=nextPlayer;
|
|
2622
|
+
partModel=verifiedDoc;
|
|
2623
|
+
stageModelBones=verifiedBones;
|
|
2624
|
+
stageCommittedEntries=verifiedEntries;
|
|
2625
|
+
inspectionSourceState='ready';
|
|
2626
|
+
stageModelHash=target.sha256;
|
|
2627
|
+
stageSource={url:target.url,prefix:target.prefix,hash:target.sha256};
|
|
2628
|
+
setupChestWorld=nextSetupChest;
|
|
2629
|
+
chestMapping=nextMapping;
|
|
2630
|
+
rigInput={state:'loaded'};
|
|
2631
|
+
|
|
2632
|
+
parts?.register('single',verifiedEntries,nextPlayer,new PartThumbnails(verifiedRegions!,nextAssets.pageImages));
|
|
2633
|
+
drawRig(()=>nextPlayer!.draw());
|
|
2634
|
+
parts?.select({side:'single',slot:mapping.slot,mode:prevPartValue?.slot===mapping.slot?prevPartValue.mode:'context'});
|
|
2635
|
+
if(parts){
|
|
2636
|
+
const liveIdentity=parts.value()?.identity;
|
|
2637
|
+
if(!liveIdentity||liveIdentity.skin!==mapping.skin||liveIdentity.attachment!==mapping.attachment)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2638
|
+
}
|
|
2639
|
+
renderLayout();
|
|
2640
|
+
updateChestMapping();
|
|
2641
|
+
fitCamera();
|
|
2642
|
+
|
|
2643
|
+
if(animSelect){
|
|
2644
|
+
animSelect.replaceChildren(...nextAssets.animations.map(item=>option(item.name,data.manifest?.animations?.find(a=>a.id===item.name)?.label??item.name)));
|
|
2645
|
+
animSelect.disabled=nextAssets.animations.length===0;
|
|
2646
|
+
animSelect.value='';
|
|
2647
|
+
}
|
|
2648
|
+
nextPlayer.on('event',event=>{text('event-log',`Runtime event: ${event.name} · ${event.time.toFixed(2)} s`);});
|
|
2649
|
+
if(partSetNode)configurePartSets(keepSet);
|
|
2650
|
+
if(options?.world){
|
|
2651
|
+
wind.resume(options.world.wind);
|
|
2652
|
+
joltQueue=options.world.jolts.map(step=>({...step}));
|
|
2653
|
+
const envApplied=document.getElementById('environment-applied') as HTMLInputElement|null;if(envApplied)envApplied.checked=options.world.applied;
|
|
2654
|
+
const grav=document.getElementById('gravity') as HTMLInputElement|null;if(grav)grav.value=String(options.world.gravity);
|
|
2655
|
+
syncEnvironmentInputs();
|
|
2656
|
+
}
|
|
2657
|
+
if(document.getElementById('environment-applied')&&environmentApplied()){
|
|
2658
|
+
nextPlayer.environment(environmentFor(wind.read(),gravityValue()));
|
|
2659
|
+
applyEnvironment();
|
|
2660
|
+
}
|
|
2661
|
+
animation='';duration=0;time=0;
|
|
2662
|
+
renderTransport();renderCues();renderIdle();
|
|
2663
|
+
stageDraftSelection={part:mapping.part,slot:mapping.slot,skin:mapping.skin,attachment:mapping.attachment,sourceHash:stageData.sourceHash,buildId};
|
|
2664
|
+
stageDraftTarget=target;
|
|
2665
|
+
const rigEmpty=document.getElementById('rig-empty');if(rigEmpty)rigEmpty.hidden=true;
|
|
2666
|
+
if(document.getElementById('player-state'))text('player-state','Draft rig · structure evidence only');
|
|
2667
|
+
for(const id of ['layer-images','layer-mesh','layer-bones']){const node=document.getElementById(id) as HTMLInputElement|null;if(node)node.disabled=false;}
|
|
2668
|
+
populateChestBones();
|
|
2669
|
+
configureTurnPad(verifiedDoc);
|
|
2670
|
+
refreshAnimationInspection();
|
|
2671
|
+
weightsView?.refresh();
|
|
2672
|
+
meshEditor?.selectionChanged();
|
|
2673
|
+
renderChest();
|
|
2674
|
+
idlePanel?.model(boneSetup(verifiedDoc));
|
|
2675
|
+
physicsPanel?.clearPreview();
|
|
2676
|
+
stageDocumentSet=true;
|
|
2677
|
+
if(prevWasPlaying)void playPreview();
|
|
2678
|
+
}catch(commitError){
|
|
2679
|
+
try{nextPlayer?.dispose();}catch{/* ignore */}
|
|
2680
|
+
try{nextAssets.dispose();}catch{/* ignore */}
|
|
2681
|
+
rigRoot.replaceChildren(...prevNodes);
|
|
2682
|
+
assets=prevAssets;player=prevPlayer;partModel=prevPartModel;stageModelBones=prevStageModelBones;stageCommittedEntries=prevCommittedEntries;
|
|
2683
|
+
inspectionSourceState=prevInspectionSourceState;stageModelHash=prevStageModelHash;stageSource=prevStageSource;setupChestWorld=prevSetupChestWorld;chestMapping=prevChestMapping;rigInput=prevRigInput;stageDraftSelection=prevSelection;stageDraftTarget=prevStageDraftTarget;
|
|
2684
|
+
animation=prevAnimation;time=prevTime;duration=prevDuration;
|
|
2685
|
+
// nextPlayer.dispose() has returned the caller's clip. Redraw before restoring
|
|
2686
|
+
// the saved styles so the previous renderer borrows that baseline again.
|
|
2687
|
+
if(prevPlayer&&prevAssets&&prevPartModel&&prevCommittedEntries){
|
|
2688
|
+
parts?.register('single',prevCommittedEntries,prevPlayer,new PartThumbnails(pageRegionTable(prevPartModel),prevAssets.pageImages));
|
|
2689
|
+
try{drawRig(()=>prevPlayer.draw());}catch{/* ignore */}
|
|
2690
|
+
try{parts?.select(prevPartValue?{side:prevPartValue.side,slot:prevPartValue.slot,mode:prevPartValue.mode}:null);}catch{/* ignore */}
|
|
2691
|
+
}else{
|
|
2692
|
+
if(prevPartRefusal)parts?.refuseCatalog('single',prevPartRefusal.message);
|
|
2693
|
+
else parts?.clear('single');
|
|
2694
|
+
}
|
|
2695
|
+
view=prevView;effectiveView=prevEffectiveView;
|
|
2696
|
+
if(prevInspector)showInspector(prevInspector,false);
|
|
2697
|
+
for(const {node,pressed,selected} of prevInspectorStates){
|
|
2698
|
+
if(pressed===null)node.removeAttribute('aria-pressed');else node.setAttribute('aria-pressed',pressed);
|
|
2699
|
+
if(selected===null)node.removeAttribute('aria-selected');else node.setAttribute('aria-selected',selected);
|
|
2700
|
+
}
|
|
2701
|
+
try{renderLayout();}catch{/* ignore */}
|
|
2702
|
+
Object.assign(viewport.state,structuredClone(prevViewportState));
|
|
2703
|
+
renderCameraControls();
|
|
2704
|
+
Object.assign(rigRoot.style,{left:prevRootStyle.left,top:prevRootStyle.top,transform:prevRootStyle.transform,transformOrigin:prevRootStyle.transformOrigin,clipPath:prevRootStyle.clipPath});
|
|
2705
|
+
if(animSelect&&prevAnimationControl){animSelect.replaceChildren(...prevAnimationOptions);Object.assign(animSelect,prevAnimationControl);}
|
|
2706
|
+
if(partSetNode&&prevSetControl){partSetNode.replaceChildren(...prevSetOptions);Object.assign(partSetNode,prevSetControl);}
|
|
2707
|
+
for(const {node,hidden,disabled,text:priorText} of prevStageControls){
|
|
2708
|
+
if(!node)continue;
|
|
2709
|
+
node.hidden=hidden!;node.disabled=disabled!;
|
|
2710
|
+
if(node.id==='player-state'||node.id==='renderer-state')node.textContent=priorText!;
|
|
2711
|
+
}
|
|
2712
|
+
populateChestBones();
|
|
2713
|
+
renderChest();
|
|
2714
|
+
if(prevWasPlaying)void playPreview();
|
|
2715
|
+
throw commitError;
|
|
2716
|
+
}finally{
|
|
2717
|
+
stageCorrectionRebinding--;
|
|
2718
|
+
directionPanel?.refresh();
|
|
2719
|
+
}
|
|
2720
|
+
try{prevPlayer?.dispose();}catch{/* ignore */}
|
|
2721
|
+
try{prevAssets?.dispose();}catch{/* ignore */}
|
|
2722
|
+
return {status,mapping};
|
|
2723
|
+
}
|
|
2439
2724
|
async function openStageCorrection(request:{part:string;sourceHash:string;buildId:string;instrument:string}):Promise<void>{
|
|
2725
|
+
if(readOnly)throw new Error(readOnly);
|
|
2726
|
+
if(rebuildBusy)throw new Error('STAGE_DRAFT_STALE');
|
|
2440
2727
|
const buildId=appliedOnStage?.buildId??'inspected';
|
|
2441
2728
|
if(request.buildId!==buildId)throw new Error('STAGE_DRAFT_STALE');
|
|
2442
|
-
const
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2729
|
+
const priorPart=stageCorrectionPart??stageDraftSelection?.part??null,token=++stageDraftRequestToken;
|
|
2730
|
+
let status:RebuildStatusView|null=null;
|
|
2731
|
+
let mapping:{part:string;slot:string;skin:string;attachment:string}|undefined;
|
|
2732
|
+
if(inspectedModel){
|
|
2733
|
+
const stageData=await api<{sourceHash:string;draft?:{inspectionOnly?:boolean;buildId:string;mappings:{part:string;slot:string;skin:string;attachment:string}[]};draftUnavailable?:string}>('/api/stage-parts',{headers:{'X-Review-Stage-Build':buildId}});
|
|
2734
|
+
if(stageData.draft?.inspectionOnly)throw new Error('PARTS_VERDICT_READ_ONLY: Stage 1 draft is inspection-only');
|
|
2735
|
+
mapping=stageData.draft?.mappings.find(m=>m.part===request.part);
|
|
2736
|
+
if(!mapping||stageData.sourceHash!==request.sourceHash||stageData.draft?.buildId!==buildId||mapping.slot!==mapping.part)throw new Error(stageData.draftUnavailable??'STAGE_DRAFT_MISMATCH');
|
|
2737
|
+
status=rebuildStatus??await loadRebuildStatus();
|
|
2738
|
+
if(!status)throw new Error('REBUILD_STATUS_UNAVAILABLE');
|
|
2739
|
+
if(request.instrument==='chest'&&!status.parts.some(part=>part.name===mapping!.part))throw new Error(`REBUILD_PART_NOT_CONTOUR: ${mapping.part}`);
|
|
2740
|
+
if(token!==stageDraftRequestToken||rebuildBusy||(appliedOnStage?.buildId??'inspected')!==buildId)throw new Error('STAGE_DRAFT_STALE');
|
|
2741
|
+
pause();seek(0);showInspector('rig');
|
|
2742
|
+
parts?.select({side:'single',slot:mapping.slot,mode:'context'});
|
|
2743
|
+
const identity=parts?.value()?.identity;if(!identity||identity.skin!==mapping.skin||identity.attachment!==mapping.attachment)throw new Error('STAGE_DRAFT_MISMATCH');
|
|
2744
|
+
stageDraftSelection={part:mapping.part,slot:mapping.slot,skin:mapping.skin,attachment:mapping.attachment,sourceHash:stageData.sourceHash,buildId};
|
|
2745
|
+
}else{
|
|
2746
|
+
const expectedHash=buildId==='inspected'?data?.reviewedSource?.rig?.sha256??null:appliedOnStage?.buildId===buildId&&typeof appliedOnStage.modelHash==='string'?appliedOnStage.modelHash:null;
|
|
2747
|
+
const prepared=await prepareStageDraftBuild(buildId,expectedHash,{
|
|
2748
|
+
transition:{kind:'open',token,priorBuildId:buildId,priorPart,expectedPart:request.part,expectedSourceHash:request.sourceHash,instrument:request.instrument},
|
|
2749
|
+
});
|
|
2750
|
+
status=prepared.status;
|
|
2751
|
+
mapping=prepared.mapping;
|
|
2752
|
+
showInspector('rig');
|
|
2753
|
+
}
|
|
2754
|
+
if(request.instrument==='mesh'&&!layers.mesh){
|
|
2755
|
+
layers.mesh=true;
|
|
2756
|
+
const layerMesh=document.getElementById('layer-mesh') as HTMLInputElement|null;if(layerMesh)layerMesh.checked=true;
|
|
2757
|
+
}
|
|
2758
|
+
meshPanel?.select(mapping.part);
|
|
2759
|
+
rebindChestPart(status!,mapping.part);
|
|
2451
2760
|
stageCorrectionPart=mapping.part;
|
|
2452
2761
|
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');
|
|
2453
2762
|
inspectorBlocks?.select('rig',request.instrument==='chest'?'chest-regions':request.instrument==='mesh'?'mesh-panel':'modeling-tools');
|
|
2454
2763
|
if(request.instrument==='chest'&&button('chest-edit').getAttribute('aria-pressed')!=='true')button('chest-edit').click();
|
|
2455
2764
|
if(request.instrument==='delta'&&button('mesh-edit').getAttribute('aria-pressed')!=='true')button('mesh-edit').click();
|
|
2765
|
+
redrawOverlay(true);
|
|
2456
2766
|
message(tr('Draft rig · structure evidence only')+tr(` · ${mapping.part} · rig-parts remesh ${request.instrument==='delta'?'--delta':'--mesh'}`));
|
|
2457
2767
|
}
|