rig-review 3.7.0 → 4.0.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/README.md +1 -1
- package/docs/DESIGN.md +145 -74
- package/docs/PANELS.md +20 -12
- package/docs/PARTS_VIEW.md +133 -76
- package/docs/REVIEW_PACKAGE.md +445 -99
- package/docs/STABILITY.md +132 -198
- package/docs/WORKFLOWS.md +41 -120
- package/package.json +4 -3
- package/skills/rig-review/SKILL.md +41 -27
- package/src/build.ts +10 -2
- package/src/cli.ts +17 -16
- package/src/comment-crops.ts +6 -1
- package/src/compare-html.ts +22 -24
- package/src/compare-server.ts +1 -1
- package/src/compare-session.ts +41 -3
- package/src/correction-handoff.ts +27 -4
- package/src/create-pin-gate.ts +3 -0
- package/src/direction-inspection.ts +6 -2
- package/src/feedback-export.ts +68 -1
- package/src/front.ts +5 -200
- package/src/handoff.ts +1 -1
- package/src/interview-routes.ts +1 -1
- package/src/interview-scene.ts +3 -3
- package/src/job-act.ts +77 -73
- package/src/job-api.ts +326 -13
- package/src/job-checkpoint-evidence.ts +113 -0
- package/src/job-cli.ts +27 -14
- package/src/job-contract.ts +284 -62
- package/src/job-front.ts +157 -58
- package/src/job-host.ts +23 -4
- package/src/job-session.ts +109 -24
- package/src/job-source.ts +209 -57
- package/src/job-store.ts +80 -6
- package/src/job-worker.ts +1 -47
- package/src/joined-project.ts +61 -4
- package/src/manifest.ts +32 -4
- package/src/open-workspace.ts +12 -12
- package/src/open.ts +19 -12
- package/src/parts-comment-crops.ts +126 -31
- package/src/parts-comment.ts +351 -28
- package/src/parts-server.ts +19 -7
- package/src/parts-view.ts +588 -109
- package/src/scene-inspection.ts +50 -0
- package/src/server.ts +31 -22
- package/src/session.ts +58 -0
- package/src/stage-comment.ts +48 -1
- package/src/stage-parts.ts +23 -11
- package/web/animation-inspection.ts +1 -1
- package/web/bones-panel.ts +1 -3
- package/web/catalog-en.ts +175 -39
- package/web/catalog-ko.ts +175 -39
- package/web/cloth-panel.ts +1 -2
- package/web/compare.css +3 -13
- package/web/compare.html +3 -3
- package/web/compare.ts +69 -64
- package/web/cuts-panel.ts +1 -3
- package/web/density-strip-panel.ts +1 -2
- package/web/direction-panel.ts +22 -6
- package/web/i18n.ts +13 -1
- package/web/idle-panel.ts +1 -2
- package/web/index.html +1 -5
- package/web/inspection-persistence.ts +2 -1
- package/web/inspector-blocks.ts +149 -40
- package/web/instance-access.ts +24 -5
- package/web/interview-panel.ts +224 -175
- package/web/job-rig-capture.ts +164 -21
- package/web/job-rig-screen.ts +337 -0
- package/web/job-session.ts +611 -1437
- package/web/main.ts +614 -151
- package/web/mesh-panel.ts +1 -2
- package/web/owner-workspace.ts +88 -109
- package/web/part-selection.ts +47 -6
- package/web/part-thumbnails.ts +20 -6
- package/web/parts-render.ts +26 -19
- package/web/parts-viewport-provider.ts +181 -7
- package/web/physics-panel.ts +1 -2
- package/web/readings-panel.ts +1 -2
- package/web/requirements-panel.ts +1 -3
- package/web/retained-frame-stage.ts +105 -0
- package/web/retarget-panel.ts +2 -3
- package/web/rig-fields-panel.ts +1 -2
- package/web/rig-host.ts +64 -0
- package/web/rig-viewport-provider.ts +65 -16
- package/web/scene-plates.ts +57 -4
- package/web/stage-comments.ts +103 -46
- package/web/styles.css +117 -63
- package/web/view-controls.ts +201 -12
- package/web/viewport-capture.ts +12 -2
- package/web/viewport-controller.ts +107 -27
- package/web/viewport-pair.ts +2 -1
- package/web/workspace-preferences.ts +5 -4
- package/web/workspace-ui.ts +151 -19
- package/src/front-worker.ts +0 -2
- package/src/interview-server.ts +0 -54
- package/src/job-hub.ts +0 -304
- package/src/job-image-set.ts +0 -50
- package/web/interview.css +0 -28
- package/web/interview.html +0 -17
- package/web/interview.ts +0 -40
- package/web/job-hub.css +0 -14
- package/web/job-hub.html +0 -5
- package/web/job-hub.ts +0 -179
- package/web/owner-workspace.css +0 -14
- package/web/owner-workspace.html +0 -5
- package/web/parts-flags.ts +0 -48
- package/web/parts.css +0 -104
- package/web/parts.html +0 -49
- package/web/parts.ts +0 -604
- package/web/stage-nav.ts +0 -136
package/web/mesh-panel.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* op at `/meshes/<part>`), Reset, the counts and `TEXTURE_STRETCH` after a build and the folds reading on the
|
|
7
7
|
* revision. The draft (`#mesh-pending`) keeps the part and its pending entry; nothing reaches the package.
|
|
8
8
|
*/
|
|
9
|
+
import {panelNode as node,panelMake as make} from './view-controls.ts';
|
|
9
10
|
import {
|
|
10
11
|
addSegment,entryChanges,entryRegions,entrySegments,entryValue,freeRegionName,hitRegionPoint,meshDraftText,meshMode,modeNotEditable,moveRegionPoint,
|
|
11
12
|
paramsFor,parseMeshDraft,polygonRegion,precheckEntry,removeSegment,segmentChoices,setEntryValue,setRibs,snapPoint,withRegions,FLOORS,RULES,MESH_PANEL_SCHEMA,
|
|
@@ -49,8 +50,6 @@ export interface MeshPanel {
|
|
|
49
50
|
dispose():void;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
const node=<T extends HTMLElement>(id:string)=>{const found=document.getElementById(id);if(!found)throw new Error(`Missing UI element: ${id}`);return found as T;};
|
|
53
|
-
const make=<K extends keyof HTMLElementTagNameMap>(tag:K,props:Record<string,unknown>={},...children:(Node|string)[]):HTMLElementTagNameMap[K]=>{const item=document.createElement(tag);Object.assign(item,props);item.append(...children);return item;};
|
|
54
53
|
const shown=(v:JsonValue|undefined)=>v===undefined?'(absent)':JSON.stringify(v);
|
|
55
54
|
const isObject=(v:unknown):v is Record<string,JsonValue>=>!!v&&typeof v==='object'&&!Array.isArray(v);
|
|
56
55
|
|
package/web/owner-workspace.ts
CHANGED
|
@@ -1,124 +1,103 @@
|
|
|
1
|
+
import {createRetainedFrameStage, mountRetainedWorkspace} from './retained-frame-stage.ts';
|
|
2
|
+
import {hashCapabilityAccess} from './instance-access.ts';
|
|
1
3
|
import {WORKSPACE_TARGET_LIMIT, WORKSPACE_READY_SCHEMA, WORKSPACE_SCHEMA, WORKSPACE_TARGET_DOMAIN, WORKSPACE_VISIBILITY_SCHEMA,
|
|
2
4
|
type WorkspaceList, type WorkspaceTargetView} from '../src/open-workspace-contract.ts';
|
|
3
5
|
import {getLanguage, onLanguageChange, setLanguagePreference, setLinkLanguage, tr} from './i18n.ts';
|
|
4
6
|
import {connectLiveWindow} from './live-connection.ts';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const cancellation = new AbortController();
|
|
21
|
-
const frames = new Map<string, {frame: HTMLIFrameElement; target: WorkspaceTargetView}>();
|
|
22
|
-
const locationURL = new URL(location.href);
|
|
23
|
-
let capability = locationURL.hash.startsWith('#cap=') ? locationURL.hash.slice(5) : '';
|
|
24
|
-
const storageKey = 'rig-review-owner-workspace/1:' + location.origin;
|
|
25
|
-
if (!/^[a-f0-9]{64}$/.test(capability)) capability = '';
|
|
26
|
-
try {
|
|
27
|
-
if (capability) sessionStorage.setItem(storageKey, capability);
|
|
28
|
-
else capability = sessionStorage.getItem(storageKey) ?? '';
|
|
29
|
-
} catch {}
|
|
30
|
-
locationURL.hash = '';
|
|
31
|
-
history.replaceState(history.state, '', locationURL);
|
|
32
|
-
|
|
33
|
-
function text() {
|
|
34
|
-
document.documentElement.lang = getLanguage();
|
|
35
|
-
heading.textContent = tr('Review workspace'); document.title = tr('Review workspace');
|
|
36
|
-
list.setAttribute('aria-label', tr('Review targets'));
|
|
37
|
-
language.setAttribute('aria-label', tr('Language'));
|
|
38
|
-
language.options[0]!.textContent = tr('English'); language.options[1]!.textContent = tr('Korean');
|
|
39
|
-
language.value = getLanguage();
|
|
40
|
-
}
|
|
8
|
+
export function mountOwnerWorkspace(root: HTMLElement): () => void {
|
|
9
|
+
const workspace = mountRetainedWorkspace({root, kind: 'owner'});
|
|
10
|
+
const {stage, language, message: status} = workspace;
|
|
11
|
+
let current: WorkspaceList | null = null, disposed = false;
|
|
12
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
13
|
+
const cancellation = new AbortController();
|
|
14
|
+
const retained = createRetainedFrameStage<{frame: HTMLIFrameElement; target: WorkspaceTargetView}>({
|
|
15
|
+
stage, limit: () => WORKSPACE_TARGET_LIMIT, key: entry => entry.target.key,
|
|
16
|
+
message: entry => ({schema: WORKSPACE_VISIBILITY_SCHEMA,
|
|
17
|
+
incarnation: current?.incarnation, key: entry.target.key, sourceHash: entry.target.contentHash}),
|
|
18
|
+
language: getLanguage, origin: location.origin, visibilityOrder: 'before-state', languageChange: 'visibility',
|
|
19
|
+
});
|
|
20
|
+
const capability = hashCapabilityAccess(new URL(location.href), 'rig-review-owner-workspace/1:' + location.origin,
|
|
21
|
+
() => sessionStorage, href => history.replaceState(history.state, '', href), {strip: 'always-after-storage', storedValue: 'preserve', fallback: ''});
|
|
41
22
|
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
async function grant(key: string) {
|
|
24
|
+
const encoder = new TextEncoder();
|
|
25
|
+
const secret = await crypto.subtle.importKey('raw', encoder.encode(capability), {name: 'HMAC', hash: 'SHA-256'}, false, ['sign']);
|
|
26
|
+
const bytes = await crypto.subtle.sign('HMAC', secret, encoder.encode(WORKSPACE_TARGET_DOMAIN + '\0' + current!.incarnation + '\0' + key));
|
|
27
|
+
return [...new Uint8Array(bytes)].map(value => value.toString(16).padStart(2, '0')).join('');
|
|
28
|
+
}
|
|
47
29
|
|
|
48
|
-
async function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
30
|
+
async function select(target: WorkspaceTargetView) {
|
|
31
|
+
const intent = retained.beginSelection();
|
|
32
|
+
if (target.unavailable) {status.textContent = tr(target.unavailable); return;}
|
|
33
|
+
let entry = retained.get(target.key);
|
|
34
|
+
if (!entry) {
|
|
35
|
+
if (retained.atLimit()) {status.textContent = tr('WORKSPACE_TARGET_LIMIT'); return;}
|
|
36
|
+
const token = await grant(target.key);
|
|
37
|
+
if (!retained.isCurrent(intent)) return;
|
|
38
|
+
const frame = retained.createFrame(target.title, target.entry + '&lang=' + getLanguage() + '#cap=' + token);
|
|
39
|
+
entry = {frame, target}; retained.retain(entry);
|
|
40
|
+
}
|
|
41
|
+
retained.select(target.key);
|
|
42
|
+
render();
|
|
43
|
+
}
|
|
54
44
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
entry = {frame, target}; frames.set(target.key, entry); stage.append(frame);
|
|
45
|
+
function render() {
|
|
46
|
+
workspace.render({
|
|
47
|
+
lang: getLanguage(), heading: tr('Review workspace'), listLabel: tr('Review targets'),
|
|
48
|
+
languageLabel: tr('Language'), englishLabel: tr('English'), koreanLabel: tr('Korean'),
|
|
49
|
+
selected: retained.selected,
|
|
50
|
+
items: (current?.targets ?? []).map(target => ({
|
|
51
|
+
key: target.key, dataset: {targetKey: target.key}, label: target.title,
|
|
52
|
+
state: tr(target.unavailable ?? (target.viewOnly ? 'Inspection only' : 'Review target')),
|
|
53
|
+
detail: target.animation,
|
|
54
|
+
onSelect: () => {void select(target).catch(() => {status.textContent = tr('WORKSPACE_REQUEST_REFUSED');});},
|
|
55
|
+
})),
|
|
56
|
+
});
|
|
68
57
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
|
|
59
|
+
async function refresh() {
|
|
60
|
+
try {
|
|
61
|
+
if (!capability) {status.textContent = tr('WORKSPACE_CAPABILITY_REQUIRED'); return;}
|
|
62
|
+
const response = await fetch('/workspace/api/targets', {
|
|
63
|
+
headers: {'X-Review-Capability': capability}, signal: AbortSignal.any([cancellation.signal, AbortSignal.timeout(5000)]),
|
|
64
|
+
});
|
|
65
|
+
const value = await response.json() as WorkspaceList & {error?: string};
|
|
66
|
+
if (!response.ok) {status.textContent = tr(value.error ?? 'WORKSPACE_REQUEST_REFUSED'); return;}
|
|
67
|
+
if (value.schema !== WORKSPACE_SCHEMA || !Array.isArray(value.targets) || value.targets.length > WORKSPACE_TARGET_LIMIT ||
|
|
68
|
+
current && current.incarnation !== value.incarnation) {status.textContent = tr('WORKSPACE_HOST_MISMATCH'); return;}
|
|
69
|
+
const changed = JSON.stringify(value) !== JSON.stringify(current);
|
|
70
|
+
if (!current) status.textContent = tr('Select a target. Drafts stay with their original source.');
|
|
71
|
+
current = value;
|
|
72
|
+
if (changed) render();
|
|
73
|
+
if (!retained.selected && value.targets[0]) await select(value.targets[0]);
|
|
74
|
+
} catch {if (!disposed) status.textContent = tr('WORKSPACE_REQUEST_REFUSED');}
|
|
75
|
+
finally {if (!disposed) timer = setTimeout(() => {void refresh();}, 1000);}
|
|
75
76
|
}
|
|
76
|
-
render();
|
|
77
|
-
}
|
|
78
77
|
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const state = document.createElement('span'); state.className = 'owner-target-status';
|
|
86
|
-
state.textContent = tr(target.unavailable ?? (target.viewOnly ? 'Inspection only' : 'Review target'));
|
|
87
|
-
const animation = document.createElement('span'); animation.className = 'owner-target-animation'; animation.textContent = target.animation;
|
|
88
|
-
button.append(title, state, animation); button.onclick = () => {void select(target).catch(() => {status.textContent = tr('WORKSPACE_REQUEST_REFUSED');});};
|
|
89
|
-
list.append(button);
|
|
78
|
+
function ready(event: MessageEvent) {
|
|
79
|
+
if (event.origin !== location.origin || !current || !event.data || typeof event.data !== 'object') return;
|
|
80
|
+
const value = event.data;
|
|
81
|
+
if (value.schema !== WORKSPACE_READY_SCHEMA || value.incarnation !== current.incarnation) return;
|
|
82
|
+
const entry = retained.get(value.key);
|
|
83
|
+
if (entry && entry.frame.contentWindow === event.source && entry.target.contentHash === value.sourceHash) retained.visibility(entry);
|
|
90
84
|
}
|
|
85
|
+
window.addEventListener('message', ready);
|
|
86
|
+
language.onchange = () => {setLinkLanguage(null); setLanguagePreference(language.value === 'ko' ? 'ko' : 'en');};
|
|
87
|
+
const unlocalize = onLanguageChange(() => {render(); retained.languageChanged();});
|
|
88
|
+
const disconnect = connectLiveWindow({route: () => '/workspace/live'});
|
|
89
|
+
const stop = () => {
|
|
90
|
+
if (disposed) return;
|
|
91
|
+
disposed = true; retained.dispose(); clearTimeout(timer); cancellation.abort(); disconnect(); unlocalize();
|
|
92
|
+
window.removeEventListener('message', ready); window.removeEventListener('pagehide', stop);
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener('pagehide', stop, {once: true});
|
|
95
|
+
render();
|
|
96
|
+
void refresh();
|
|
97
|
+
return stop;
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const response = await fetch('/workspace/api/targets', {
|
|
97
|
-
headers: {'X-Review-Capability': capability}, signal: AbortSignal.any([cancellation.signal, AbortSignal.timeout(5000)]),
|
|
98
|
-
});
|
|
99
|
-
const value = await response.json() as WorkspaceList & {error?: string};
|
|
100
|
-
if (!response.ok) {status.textContent = tr(value.error ?? 'WORKSPACE_REQUEST_REFUSED'); return;}
|
|
101
|
-
if (value.schema !== WORKSPACE_SCHEMA || !Array.isArray(value.targets) || value.targets.length > WORKSPACE_TARGET_LIMIT ||
|
|
102
|
-
current && current.incarnation !== value.incarnation) {status.textContent = tr('WORKSPACE_HOST_MISMATCH'); return;}
|
|
103
|
-
const changed = JSON.stringify(value) !== JSON.stringify(current);
|
|
104
|
-
if (!current) status.textContent = tr('Select a target. Drafts stay with their original source.');
|
|
105
|
-
current = value;
|
|
106
|
-
if (changed) render();
|
|
107
|
-
if (!selected && value.targets[0]) await select(value.targets[0]);
|
|
108
|
-
} catch {if (!disposed) status.textContent = tr('WORKSPACE_REQUEST_REFUSED');}
|
|
109
|
-
finally {if (!disposed) timer = setTimeout(() => {void refresh();}, 1000);}
|
|
100
|
+
if (typeof document !== 'undefined' && typeof location !== 'undefined' && location.pathname === '/') {
|
|
101
|
+
const root = document.getElementById('app');
|
|
102
|
+
if (root && !root.childElementCount) mountOwnerWorkspace(root);
|
|
110
103
|
}
|
|
111
|
-
|
|
112
|
-
window.addEventListener('message', event => {
|
|
113
|
-
if (event.origin !== location.origin || !current || !event.data || typeof event.data !== 'object') return;
|
|
114
|
-
const value = event.data;
|
|
115
|
-
if (value.schema !== WORKSPACE_READY_SCHEMA || value.incarnation !== current.incarnation) return;
|
|
116
|
-
const entry = frames.get(value.key);
|
|
117
|
-
if (entry && entry.frame.contentWindow === event.source && entry.target.contentHash === value.sourceHash) visibility(entry);
|
|
118
|
-
});
|
|
119
|
-
language.onchange = () => {setLinkLanguage(null); setLanguagePreference(language.value === 'ko' ? 'ko' : 'en');};
|
|
120
|
-
onLanguageChange(() => {render(); for (const entry of frames.values()) visibility(entry);});
|
|
121
|
-
const disconnect = connectLiveWindow({route: () => '/workspace/live'});
|
|
122
|
-
window.addEventListener('pagehide', () => {disposed = true; clearTimeout(timer); cancellation.abort(); disconnect();}, {once: true});
|
|
123
|
-
text();
|
|
124
|
-
void refresh();
|
package/web/part-selection.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type {Json} from '../src/manifest.ts';
|
|
3
3
|
import type {PosedFrame,RigPlayer,PoseBounds,SlotIdentitySnapshot} from '@rig-c/play';
|
|
4
4
|
import {parseControlPart,parsePartIdentity,type ControlPart,type ControlPartIdentity,type PartIdentityReason} from '../src/control.ts';
|
|
5
|
-
import {setSourceAttribute,setSourceText,sourceAttribute} from './i18n.ts';
|
|
5
|
+
import {t,setSourceAttribute,setSourceText,sourceAttribute} from './i18n.ts';
|
|
6
6
|
export interface PartDeclaration {skin:string;attachment:string;kind:string;path:string|null}
|
|
7
7
|
export interface PartEntry {slot:string;bone:string;setup:string|null;declarations:PartDeclaration[]}
|
|
8
8
|
export interface PartObservation {side:ControlPart['side'];slot:string;mode:ControlPart['mode'];identity:ControlPartIdentity|null;generation:number|null;reason:PartIdentityReason|null;drawn:boolean;kind:string|null;page:string|null;region:string|null;sequence:number|null;vertices:number|null;triangles:number|null;z:number|null;skin:string|null;set:string|null;activeAttachment:{skin:string;attachment:string}|null;identityUnavailable:string|null;bounds:PoseBounds|null;declarations:PartDeclaration[]}
|
|
@@ -98,7 +98,17 @@ export class PartInspection {
|
|
|
98
98
|
}
|
|
99
99
|
/** Draws a row's thumbnail into its icon element, or leaves the type glyph; returns the tooltip note naming which and why. */
|
|
100
100
|
export interface PartThumbnailSource {show(icon:HTMLElement,entry:PartEntry,identity:ControlPartIdentity|null,glyph:string):string}
|
|
101
|
+
export interface PartsListItem {name:string;index:number;imageHash?:string;mesh?:unknown}
|
|
102
|
+
export interface PartsListSource {
|
|
103
|
+
items:readonly PartsListItem[];selected:()=>string|null;solo:()=>boolean;visible:(name:string)=>boolean;
|
|
104
|
+
thumbnail?:(icon:HTMLElement,item:PartsListItem,glyph:string)=>void;
|
|
105
|
+
select:(name:string|null)=>void;isolate:(solo:boolean)=>void;show:(name:string,visible:boolean)=>void;
|
|
106
|
+
}
|
|
101
107
|
export class PartExplorer extends PartInspection {
|
|
108
|
+
private images:PartsListSource|null=null;
|
|
109
|
+
/** Parts-only subjects use these same rows; they carry no slot, bone or runtime identity. */
|
|
110
|
+
registerImages(source:PartsListSource):void {this.images=source;this.whole.onclick=()=>source.select(null);this.solo.onchange=()=>source.isolate(this.solo.checked);this.renderList();this.renderDetail();}
|
|
111
|
+
refreshImages():void {if(this.images){this.renderSelection(true);this.renderDetail();}}
|
|
102
112
|
private highlightedBone:string|null=null;
|
|
103
113
|
/** Page-local bone relation highlight; it never invents a selected slot or changes held identity. */
|
|
104
114
|
highlightBone(name:string|null):void {this.highlightedBone=name;for(const [row,entry]of this.rowEntries)row.dataset.boneSelected=String(name!==null&&entry.bone===name);}
|
|
@@ -125,15 +135,37 @@ export class PartExplorer extends PartInspection {
|
|
|
125
135
|
/** Everything the rows and Solo control display: selection, per-side drawn slots in order, and identity. Generation is excluded. */
|
|
126
136
|
private viewKey():string {let key=JSON.stringify([this.selected,this.visibleSide,[...this.refused]]);for(const [side,state]of this.shownSides()){key+='\u0001'+side+'\u0002'+(state.frame?state.frame.order.map(row=>row.slot).join('\u0000'):'\u0003');for(const row of state.identity?.slots??[])key+='\u0002'+row.slot+'\u0000'+row.z+'\u0000'+row.skin+'\u0000'+row.attachment+'\u0000'+row.reason;}return key;}
|
|
127
137
|
private action(run:()=>void){try{run();}catch(error){this.renderSelection(true);this.host.querySelector<HTMLElement>('[data-part-status]')!.textContent=`Part selection refused: ${error instanceof Error?error.message:String(error)}`;}}
|
|
128
|
-
private renderList(){
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
private renderList(){
|
|
139
|
+
this.rows.clear();this.rowEntries.clear();this.rowParts.clear();this.list.replaceChildren();
|
|
140
|
+
const query=this.search.value;
|
|
141
|
+
const entries=this.images?this.images.items.map(image=>({side:'single' as const,name:image.name,image,entry:null as PartEntry|null})):
|
|
142
|
+
this.shownSides().flatMap(([side,state])=>orderedParts(state.entries,state.frame,state.identity).map(entry=>({side,name:entry.slot,image:null,entry})));
|
|
143
|
+
for(const {side,name,image,entry}of entries){
|
|
144
|
+
if(!name.includes(query))continue;
|
|
145
|
+
const row=document.createElement('button');row.type='button';row.dataset.side=side;row.dataset.slot=name;row.title=entry?`${name} · bone ${entry.bone}`:name;
|
|
146
|
+
const icon=document.createElement('span'),label=document.createElement('span');icon.className='part-thumb';icon.setAttribute('aria-hidden','true');
|
|
147
|
+
icon.textContent=(entry?.declarations.some(d=>d.kind==='mesh')||image?.mesh)?'◈':'◇';label.className='part-label';label.textContent=`${side==='single'?'':side.toUpperCase()+' · '}${name}`;row.append(icon,label);this.rowParts.set(row,{icon,label});if(image)this.images?.thumbnail?.(icon,image,icon.textContent??'◇');
|
|
148
|
+
row.onclick=()=>this.action(()=>{if(this.images){this.images.select(this.images.selected()===name?null:name);this.renderSelection(true);return;}const live=this.live();this.select(live?.side===side&&live.slot===name?null:{side,slot:name,mode:this.selected?.mode??'context'});});
|
|
149
|
+
const item=document.createElement('li');item.append(row);this.list.append(item);this.rows.set(JSON.stringify([side,name]),row);if(entry)this.rowEntries.set(row,entry);
|
|
150
|
+
if(image&&this.images){
|
|
151
|
+
const visible=document.createElement('input');visible.type='checkbox';visible.checked=this.images.visible(name);visible.dataset.pvVisible=name;setSourceAttribute(visible,'aria-label',t('Show {name} in assembly',{name}));
|
|
152
|
+
visible.onchange=()=>this.images?.show(name,visible.checked);const label=document.createElement('label');label.append(visible);item.append(label);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
this.orderKey='';if(!this.images)this.reorder();this.renderSelection(true);this.highlightBone(this.highlightedBone);
|
|
156
|
+
}
|
|
131
157
|
private statusText():string {const refused=[...this.refused].filter(([side])=>this.visibleSide===null||side===this.visibleSide).map(([side,r])=>`${side==='single'?'':side.toUpperCase()+' '}${r.code}`);if(refused.length)return `Parts unavailable · ${refused.join(' · ')}. The rig keeps drawing whole; selection, Solo and feedback targeting are off ${[...this.refused.values()].some(r=>r.catalog)?'until the package reloads with a matching catalog':'until a frame with a valid identity snapshot'}.`;const shown=this.shownSides();return shown.length?`${shown.reduce((n,[,s])=>n+s.entries.length,0)} declared slots · ${this.rows.size} results`:'No compiled rig catalog available';}
|
|
132
158
|
private reorder(){const keys=this.shownSides().flatMap(([side,state])=>orderedParts(state.entries,state.frame,state.identity).map(entry=>JSON.stringify([side,entry.slot]))).filter(key=>this.rows.has(key)),key=JSON.stringify(keys);if(key===this.orderKey)return;this.orderKey=key;const active=document.activeElement;for(const item of keys){const row=this.rows.get(item)!;this.list.append(row.parentElement!);}if(active instanceof HTMLElement&&this.list.contains(active)&&document.activeElement!==active)active.focus({preventScroll:true});}
|
|
133
|
-
private renderSelection(force=false){
|
|
159
|
+
private renderSelection(force=false){
|
|
160
|
+
if(this.images){
|
|
161
|
+
const name=this.images.selected();this.whole.setAttribute('aria-pressed',String(name===null));this.solo.disabled=name===null;this.solo.checked=this.images.solo();
|
|
162
|
+
for(const row of this.rows.values())row.setAttribute('aria-pressed',String(row.dataset.slot===name));
|
|
163
|
+
setSourceText(this.host.querySelector<HTMLElement>('[data-part-status]')!,t('{count} parts',{count:this.images.items.length}));return;
|
|
164
|
+
}
|
|
165
|
+
const key=this.viewKey();if(!force&&key===this.selectionKey)return;this.selectionKey=key;const status=this.host.querySelector<HTMLElement>('[data-part-status]')!;setSourceText(status,this.statusText());if(this.refused.size)this.host.dataset.parts='unavailable';else delete this.host.dataset.parts;const drawnBySide=new Map([...this.sides].map(([side,state])=>[side,new Set(state.frame?.order.map(row=>row.slot)??[])]));this.whole.setAttribute('aria-pressed',String(!this.selected));this.solo.disabled=!this.live();this.solo.checked=this.live()?.mode==='solo';for(const [key,row]of this.rows){row.setAttribute('aria-pressed',String(key===JSON.stringify([this.live()?.side,this.live()?.slot])));const refusal=this.refused.get(row.dataset.side as ControlPart['side']);row.disabled=!!refusal;const parts=this.rowParts.get(row)!;if(refusal){const label=`${row.dataset.side==='single'?'':row.dataset.side!.toUpperCase()+' · '}${row.dataset.slot} · parts unavailable · ${refusal.code}`;if(parts.label.textContent!==label){parts.label.textContent=label;parts.icon.textContent='';delete parts.icon.dataset.thumbnailPlan;}row.title=label;row.setAttribute('aria-label',label);row.dataset.drawn='false';continue;}const state=this.sides.get(row.dataset.side as ControlPart['side']);const drawn=drawnBySide.get(row.dataset.side as ControlPart['side'])?.has(row.dataset.slot!);row.dataset.drawn=String(!!drawn);const entry=this.rowEntries.get(row),identity=entry?partIdentity(state?.identity??null,row.dataset.slot!):null;const glyph=entry?.declarations.some(d=>d.kind==='mesh')?'◈':'◇',source=this.thumbnails.get(row.dataset.side as ControlPart['side']),note=entry&&source?source.show(parts.icon,entry,identity,glyph):null;if(!note&&parts.icon.textContent!==glyph){parts.icon.textContent=glyph;delete parts.icon.dataset.thumbnailPlan;}
|
|
134
166
|
const title=`${row.dataset.slot} · ${state?.frame?drawn?'drawn':'not drawn':'awaiting draw'}${identity?identity.reason?' · '+identity.reason:' · '+identity.skin+' / '+identity.attachment:' · awaiting identity snapshot'}${note?' · '+note:''}`;if(sourceAttribute(row,'title')!==title)row.title=title;const label=`${row.dataset.side==='single'?'':row.dataset.side!.toUpperCase()+' · '}${row.dataset.slot} · ${state?.frame?drawn?'drawn':'not drawn':'awaiting draw'} · ${identity?identity.reason?'no active attachment · '+identity.reason:identity.skin+' / '+identity.attachment:'awaiting identity snapshot'}`;setSourceText(parts.label,label);setSourceAttribute(row,'aria-label',`${glyph} ${label} · ${state?.frame?drawn?'drawn':'not drawn':'awaiting draw'}`);}}
|
|
135
167
|
private renderDetail(){
|
|
136
|
-
const observation=this.observation(),refusal=this.selected?this.refused.get(this.selected.side):[...this.refused.values()][0],key=JSON.stringify([observation,refusal??null,this.statusHint]);if(key===this.detailKey)return;this.detailKey=key;
|
|
168
|
+
const observation=this.observation(),refusal=this.selected?this.refused.get(this.selected.side):[...this.refused.values()][0],key=JSON.stringify([observation,refusal??null,this.statusHint,!!this.images,this.images?.selected()]);if(key===this.detailKey)return;this.detailKey=key;
|
|
137
169
|
// Keep focused controls connected while the selected pose's bounds animate.
|
|
138
170
|
const nodes=this.detailNodes??=(()=>{
|
|
139
171
|
const title=document.createElement('h3'),info=document.createElement('p'),declarations=document.createElement('p'),bounds=document.createElement('p'),unavailable=document.createElement('p'),feedback=document.createElement('button'),status=document.createElement('p');
|
|
@@ -144,6 +176,15 @@ export class PartExplorer extends PartInspection {
|
|
|
144
176
|
this.detail.replaceChildren(title,info,declarations,bounds,unavailable,feedback,status);
|
|
145
177
|
return {title,info,declarations,bounds,unavailable,feedback,status};
|
|
146
178
|
})();
|
|
179
|
+
if(this.images){
|
|
180
|
+
const selected=this.images.items.find(item=>item.name===this.images!.selected());
|
|
181
|
+
setSourceText(nodes.title,selected?.name??'Assembled parts');
|
|
182
|
+
setSourceText(nodes.info,selected?t('Original part image · {name}',{name:selected.name}):'Select a part to inspect its original image source.');
|
|
183
|
+
setSourceText(nodes.declarations,selected?.imageHash?t('Source image SHA-256 · {hash}',{hash:selected.imageHash}):'');
|
|
184
|
+
nodes.declarations.hidden=!selected?.imageHash;
|
|
185
|
+
for(const node of [nodes.bounds,nodes.unavailable,nodes.feedback,nodes.status])node.hidden=true;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
147
188
|
nodes.status.textContent=this.statusHint??'Mesh optimization requires an eligible producer handoff. This inspection changes no source art, geometry or motion.';
|
|
148
189
|
nodes.title.textContent=observation?`${observation.side==='single'?'':observation.side.toUpperCase()+' · '}${observation.slot}`:'Whole rig';
|
|
149
190
|
nodes.info.textContent=observation?`${observation.mode==='solo'?'Solo':'In context'} · ${observation.drawn?observation.kind==='mesh'?`${observation.vertices} posed vertices · ${observation.triangles} triangles`:'Region · four posed corners':'Not drawn at current pose'} · Skin: ${observation.skin??'not set'} · Set: ${observation.set??'not set'}`:refusal?`Parts unavailable · ${refusal.message}. The whole rig stays drawn; no slot is selected, soloed or targeted from stale data.`:'Select an actual slot in the parts explorer. Selection preserves animation, time and physics history.';
|
package/web/part-thumbnails.ts
CHANGED
|
@@ -49,28 +49,42 @@ export function thumbnailPlan(table:PageRegionTable,entry:PartEntry,identity:Con
|
|
|
49
49
|
export function thumbnailFit(sw:number,sh:number,size=thumbnailBox*thumbnailScale):{dx:number;dy:number;dw:number;dh:number} {
|
|
50
50
|
const scale=Math.min(size/sw,size/sh),dw=sw*scale,dh=sh*scale;return {dx:(size-dw)/2,dy:(size-dh)/2,dw,dh};
|
|
51
51
|
}
|
|
52
|
-
type PageImage=CanvasImageSource&{complete?:boolean;naturalWidth?:number};
|
|
52
|
+
type PageImage=CanvasImageSource&{complete?:boolean;naturalWidth?:number;naturalHeight?:number};
|
|
53
53
|
/** Lazy (IntersectionObserver) drawing, one cached bitmap per attachment key. */
|
|
54
54
|
export class PartThumbnails implements PartThumbnailSource {
|
|
55
|
-
private cache=new Map<string,HTMLCanvasElement>();private pending=new Map<Element,ThumbnailCrop>();private observer:IntersectionObserver|null=null;
|
|
56
|
-
constructor(private table:PageRegionTable,private images:ReadonlyMap<string,PageImage
|
|
55
|
+
private cache=new Map<string,HTMLCanvasElement>();private pending=new Map<Element,ThumbnailCrop>();private observer:IntersectionObserver|null=null;private disposed=false;private originals=new Map<string,PageImage>();
|
|
56
|
+
constructor(private table:PageRegionTable={pages:new Map(),regions:new Map(),absent:null},private images:ReadonlyMap<string,PageImage>=new Map()){
|
|
57
57
|
if(typeof IntersectionObserver==='function')this.observer=new IntersectionObserver(items=>{for(const item of items)if(item.isIntersecting){const plan=this.pending.get(item.target);this.observer?.unobserve(item.target);this.pending.delete(item.target);if(plan)this.paint(item.target as HTMLCanvasElement,plan);}});
|
|
58
58
|
}
|
|
59
59
|
show(icon:HTMLElement,entry:PartEntry,identity:ControlPartIdentity|null,glyph:string):string {
|
|
60
60
|
const plan=thumbnailPlan(this.table,entry,identity),image=plan.kind==='crop'?this.images.get(plan.page):undefined;
|
|
61
61
|
const shown:ThumbnailPlan=plan.kind==='crop'&&!image?{kind:'icon',key:plan.key,reason:`THUMBNAIL_PAGE_UNAVAILABLE: page ${plan.page} is not loaded`}:plan;
|
|
62
|
+
this.showPlan(icon,shown,glyph);
|
|
63
|
+
return shown.kind==='crop'?`thumbnail: region ${shown.region} on ${shown.page}`:`type icon: ${shown.reason}`;
|
|
64
|
+
}
|
|
65
|
+
/** Whole original part rasters use the same fit, cache, lazy canvas and disposal as compiled regions. */
|
|
66
|
+
showOriginal(icon:HTMLElement,item:{name:string;index:number;imageHash?:string},load:()=>Promise<HTMLImageElement>,glyph:string):void {
|
|
67
|
+
const key=JSON.stringify(['original',item.name,item.imageHash]);if(icon.dataset.originalThumbnail===key)return;
|
|
68
|
+
icon.dataset.originalThumbnail=key;
|
|
69
|
+
this.showPlan(icon,{kind:'icon',key,reason:'awaiting original image'},glyph);
|
|
70
|
+
void load().then(image=>{
|
|
71
|
+
if(this.disposed||icon.dataset.originalThumbnail!==key)return;
|
|
72
|
+
this.originals.set(key,image);
|
|
73
|
+
this.showPlan(icon,{kind:'crop',key,page:key,region:item.name,u0:0,v0:0,u1:1,v1:1,sx:0,sy:0,sw:image.naturalWidth,sh:image.naturalHeight},glyph);
|
|
74
|
+
}).catch(()=>{if(!this.disposed&&icon.dataset.originalThumbnail===key)this.showPlan(icon,{kind:'icon',key,reason:'original image unavailable'},glyph);});
|
|
75
|
+
}
|
|
76
|
+
private showPlan(icon:HTMLElement,shown:ThumbnailPlan,glyph:string):void {
|
|
62
77
|
const stamp=JSON.stringify(shown);
|
|
63
78
|
if(icon.dataset.thumbnailPlan!==stamp){
|
|
64
79
|
icon.dataset.thumbnailPlan=stamp;for(const child of icon.querySelectorAll('canvas')){this.observer?.unobserve(child);this.pending.delete(child);}
|
|
65
80
|
if(shown.kind==='crop'){const canvas=document.createElement('canvas');canvas.width=canvas.height=thumbnailBox*thumbnailScale;canvas.setAttribute('aria-hidden','true');icon.replaceChildren(canvas);icon.dataset.thumbnail='image';if(this.observer){this.pending.set(canvas,shown);this.observer.observe(canvas);}else this.paint(canvas,shown);}
|
|
66
81
|
else{icon.textContent=glyph;icon.dataset.thumbnail='icon';}
|
|
67
82
|
}
|
|
68
|
-
return shown.kind==='crop'?`thumbnail: region ${shown.region} on ${shown.page}`:`type icon: ${shown.reason}`;
|
|
69
83
|
}
|
|
70
84
|
private paint(canvas:HTMLCanvasElement,plan:ThumbnailCrop):void {
|
|
71
85
|
let source=this.cache.get(plan.key);
|
|
72
|
-
if(!source){const image=this.images.get(plan.page);if(!image)return;source=document.createElement('canvas');source.width=source.height=thumbnailBox*thumbnailScale;const fit=thumbnailFit(plan.sw,plan.sh);source.getContext('2d')?.drawImage(image,plan.sx,plan.sy,plan.sw,plan.sh,fit.dx,fit.dy,fit.dw,fit.dh);this.cache.set(plan.key,source);}
|
|
86
|
+
if(!source){const image=this.images.get(plan.page)??this.originals.get(plan.page);if(!image)return;source=document.createElement('canvas');source.width=source.height=thumbnailBox*thumbnailScale;const fit=thumbnailFit(plan.sw,plan.sh);source.getContext('2d')?.drawImage(image,plan.sx,plan.sy,plan.sw,plan.sh,fit.dx,fit.dy,fit.dw,fit.dh);this.cache.set(plan.key,source);}
|
|
73
87
|
const context=canvas.getContext('2d');if(!context)return;context.clearRect(0,0,canvas.width,canvas.height);context.drawImage(source,0,0);
|
|
74
88
|
}
|
|
75
|
-
dispose():void {this.observer?.disconnect();this.pending.clear();this.cache.clear();}
|
|
89
|
+
dispose():void {this.disposed=true;this.observer?.disconnect();this.pending.clear();this.cache.clear();this.originals.clear();}
|
|
76
90
|
}
|
package/web/parts-render.ts
CHANGED
|
@@ -91,29 +91,36 @@ export function meshCoverage(w: number, h: number, mesh: MeshGeometry): Uint8Arr
|
|
|
91
91
|
return mask;
|
|
92
92
|
}
|
|
93
93
|
/** Tint only nontransparent source-art pixels outside the triangle union, before drawing diagnostic edges. */
|
|
94
|
-
export function paintMesh(ctx: Ctx, source: Source, w: number, h: number, mesh: MeshGeometry, makeCanvas: (w: number, h: number) => HTMLCanvasElement): void {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
94
|
+
export function paintMesh(ctx: Ctx, source: Source, w: number, h: number, mesh: MeshGeometry, makeCanvas: (w: number, h: number) => HTMLCanvasElement, options: {tint?: boolean; alpha?: number} = {}): void {
|
|
95
|
+
const tintEnabled = options.tint !== false;
|
|
96
|
+
ctx.save();
|
|
97
|
+
try {
|
|
98
|
+
ctx.globalAlpha *= options.alpha ?? 1;
|
|
99
|
+
if (tintEnabled) {
|
|
100
|
+
const scratch = makeCanvas(w, h), s = scratch.getContext('2d')!;
|
|
101
|
+
s.drawImage(source, 0, 0);
|
|
102
|
+
const art = s.getImageData(0, 0, w, h), tint = s.createImageData(w, h), mask = meshCoverage(w, h, mesh);
|
|
103
|
+
for (let i = 0; i < mask.length; i++) if (!mask[i] && art.data[i * 4 + 3]) {
|
|
104
|
+
tint.data[i * 4] = 255; tint.data[i * 4 + 2] = 80; tint.data[i * 4 + 3] = 160;
|
|
105
|
+
}
|
|
106
|
+
s.putImageData(tint, 0, 0); ctx.drawImage(scratch, 0, 0);
|
|
107
|
+
}
|
|
108
|
+
ctx.strokeStyle = '#00bfff'; ctx.fillStyle = '#ffffff'; ctx.lineWidth = .5;
|
|
109
|
+
ctx.beginPath();
|
|
110
|
+
const v = mesh.vertices;
|
|
111
|
+
for (let i = 0; i < mesh.triangles.length; i += 3) {
|
|
112
|
+
for (let j = 0; j < 3; j++) { const a = mesh.triangles[i + j]! * 2; if (!j) ctx.moveTo(v[a]!, v[a + 1]!); else ctx.lineTo(v[a]!, v[a + 1]!); }
|
|
113
|
+
ctx.closePath();
|
|
114
|
+
}
|
|
115
|
+
ctx.stroke();
|
|
116
|
+
if (tintEnabled) for (let i = 0; i < v.length; i += 2) { ctx.beginPath(); ctx.arc(v[i]!, v[i + 1]!, .8, 0, Math.PI * 2); ctx.fill(); }
|
|
117
|
+
} finally {ctx.restore();}
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
/** Package order is back to front. Placements remain continuous rig pixels. */
|
|
114
|
-
export function paintAssembly(ctx:Ctx,w:number,h:number,layers:readonly {box:Box;image:Source}[],options:{bg:string;alpha:boolean}):void {
|
|
121
|
+
export function paintAssembly(ctx:Ctx,w:number,h:number,layers:readonly {box:Box;image:Source}[],options:{bg:string;alpha:boolean;transparent?:boolean}):void {
|
|
115
122
|
ctx.imageSmoothingEnabled=false;
|
|
116
|
-
if(
|
|
123
|
+
if(options.alpha||options.transparent)ctx.clearRect(0,0,w,h);else paintBackground(ctx,w,h,options.bg);
|
|
117
124
|
for(const {box,image} of layers)ctx.drawImage(image,box.x,box.y);
|
|
118
125
|
if(options.alpha){const data=ctx.getImageData(0,0,w,h),px=data.data;for(let i=0;i<px.length;i+=4){px[i]=px[i+1]=px[i+2]=px[i+3]!;px[i+3]=255;}ctx.putImageData(data,0,0);}
|
|
119
126
|
}
|