@rig-c/review 2.4.6 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/PARTS_VIEW.md +82 -3
- package/docs/REVIEW_PACKAGE.md +16 -1
- package/docs/STABILITY.md +2 -0
- package/docs/WORKFLOWS.md +37 -1
- package/package.json +1 -1
- package/src/cli.ts +52 -7
- package/src/comment-crops.ts +48 -3
- package/src/entry.ts +1 -0
- package/src/job-act.ts +59 -4
- package/src/job-api.ts +21 -6
- package/src/job-cli.ts +391 -28
- package/src/job-contract.ts +57 -1
- package/src/job-host.ts +4 -0
- package/src/job-session.ts +31 -4
- package/src/job-store.ts +28 -0
- package/src/parts-server.ts +46 -7
- package/src/parts-view.ts +76 -14
- package/web/catalog-en.ts +15 -0
- package/web/catalog-ko.ts +15 -0
- package/web/job-rig-capture.ts +211 -0
- package/web/job-session.ts +357 -23
- package/web/parts.ts +6 -1
- package/web/styles.css +14 -0
- package/web/viewport-capture.ts +119 -17
package/web/job-session.ts
CHANGED
|
@@ -4,6 +4,11 @@ import {enCatalog} from './catalog-en.ts';
|
|
|
4
4
|
import {koCatalog} from './catalog-ko.ts';
|
|
5
5
|
import {t} from './i18n.ts';
|
|
6
6
|
import {JOB_HUB_READY, jobHubMessageMatches, type JobHubBinding} from './job-hub.ts';
|
|
7
|
+
import {recordJobRigDraw, freezeJobRigCapture, copyJobRigViewport, createJobRigSubmission, jobRigPixelPlacement,
|
|
8
|
+
type JobRigDraw, type JobRigDrawState} from './job-rig-capture.ts';
|
|
9
|
+
import {advancePlayback} from './playback-clock.ts';
|
|
10
|
+
import {presentJobRigViewport, type JobRigPresentation} from './viewport-capture.ts';
|
|
11
|
+
import {CanvasRenderer} from '@rig-c/play';
|
|
7
12
|
|
|
8
13
|
/** Imported runtimes may throw arbitrary prose. Only registered refusal copy reaches the window. */
|
|
9
14
|
export function jobWindowRefusal(error: unknown, fallback = 'JOB_WINDOW_FAILED'): string {
|
|
@@ -125,6 +130,7 @@ export function createJobWindow<Prepared>(options: {
|
|
|
125
130
|
}) {
|
|
126
131
|
const { transport, adapter, pageId } = options;
|
|
127
132
|
const pending = new Map<string, JobPendingAsk>();
|
|
133
|
+
const rigAttempts = new WeakSet<JobUISubmission>();
|
|
128
134
|
const retainedDrafts: JobRetainedDraft[] = [];
|
|
129
135
|
let generation = 0;
|
|
130
136
|
let displayed: JobDisplayPublication | null = null;
|
|
@@ -256,14 +262,16 @@ export function createJobWindow<Prepared>(options: {
|
|
|
256
262
|
if (closed)
|
|
257
263
|
return { ok: false, error: { code: 'JOB_CLOSED', message: 'JOB_CLOSED' } };
|
|
258
264
|
const ask = pending.get(input.askId);
|
|
265
|
+
const retry = input.capture !== undefined && rigAttempts.has(input);
|
|
259
266
|
if (preparing || !displayed || !receipt ||
|
|
260
267
|
input.publicationId !== displayed.publication.publicationId ||
|
|
261
268
|
input.pageId !== pageId || input.displayedNonce !== receipt.displayedNonce ||
|
|
262
269
|
input.expectedGeneration > generation ||
|
|
263
|
-
ask && (ask.status !== 'pending' || ask.publicationId !== input.publicationId || ask.subject.kind !== input.kind)) {
|
|
270
|
+
ask && (ask.status !== 'pending' && !retry || ask.publicationId !== input.publicationId || ask.subject.kind !== input.kind)) {
|
|
264
271
|
return { ok: false, error: { code: 'JOB_ACT_SOURCE_STALE', message: 'JOB_ACT_SOURCE_STALE' } };
|
|
265
272
|
}
|
|
266
273
|
// The backend authenticates the actual Request and validates the semantic value.
|
|
274
|
+
if (input.capture !== undefined) rigAttempts.add(input);
|
|
267
275
|
return transport.submit(input);
|
|
268
276
|
}
|
|
269
277
|
return {
|
|
@@ -609,8 +617,9 @@ export interface JobPreparedInspection {
|
|
|
609
617
|
assets: ModelAssets | null;
|
|
610
618
|
player: RigPlayer | null;
|
|
611
619
|
rigRoot: HTMLElement;
|
|
620
|
+
rigPresentation?: JobRigPresentation;
|
|
612
621
|
inspection: PartInspection | null;
|
|
613
|
-
setupPose(): void;
|
|
622
|
+
setupPose(setup?: boolean): void;
|
|
614
623
|
dispose(): void;
|
|
615
624
|
}
|
|
616
625
|
async function jobBytes(url: string, signal: AbortSignal, maximum: number): Promise<Uint8Array<ArrayBuffer>> {
|
|
@@ -689,12 +698,19 @@ export async function prepareJobInspection(display: JobDisplayPublication, signa
|
|
|
689
698
|
let assets: ModelAssets | null = null;
|
|
690
699
|
let player: RigPlayer | null = null;
|
|
691
700
|
let inspection: PartInspection | null = null;
|
|
692
|
-
let resetToSetup = () => {};
|
|
701
|
+
let resetToSetup: (setup?: boolean) => void = () => {};
|
|
702
|
+
let rigPresentation: JobRigPresentation | undefined;
|
|
703
|
+
function clearRigPresentation(): void {
|
|
704
|
+
rigPresentation?.canvas.parentElement?.removeAttribute('data-job-rig-canonical');
|
|
705
|
+
rigPresentation?.canvas.remove();
|
|
706
|
+
rigPresentation = undefined;
|
|
707
|
+
}
|
|
693
708
|
let disposed = false;
|
|
694
709
|
const dispose = () => {
|
|
695
710
|
if (disposed)
|
|
696
711
|
return;
|
|
697
712
|
disposed = true;
|
|
713
|
+
clearRigPresentation();
|
|
698
714
|
for (const video of media) {
|
|
699
715
|
video.pause();
|
|
700
716
|
video.removeAttribute('src');
|
|
@@ -879,13 +895,17 @@ export async function prepareJobInspection(display: JobDisplayPublication, signa
|
|
|
879
895
|
const loadedAssets = assets;
|
|
880
896
|
const parts = await import('./part-selection.ts');
|
|
881
897
|
const catalog = await parts.loadPartModel(modelUrl, modelHash, metadata.feedbackCatalog.slots ?? [], checkedFetch);
|
|
882
|
-
resetToSetup = () => {
|
|
898
|
+
resetToSetup = (setup = true) => {
|
|
899
|
+
clearRigPresentation();
|
|
883
900
|
player?.dispose();
|
|
884
901
|
player = new runtime.RigPlayer(rigRoot, loadedAssets);
|
|
885
|
-
player.draw();
|
|
886
902
|
inspection = new parts.PartInspection();
|
|
887
903
|
inspection.register('single', catalog.entries, player);
|
|
888
|
-
|
|
904
|
+
if (setup) {
|
|
905
|
+
player.clear(0, {mix: 0});
|
|
906
|
+
player.draw();
|
|
907
|
+
inspection.present('single');
|
|
908
|
+
}
|
|
889
909
|
};
|
|
890
910
|
resetToSetup();
|
|
891
911
|
}
|
|
@@ -898,9 +918,14 @@ export async function prepareJobInspection(display: JobDisplayPublication, signa
|
|
|
898
918
|
references.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
|
|
899
919
|
return {
|
|
900
920
|
display, metadata, interview, parts, partImages, interviewImages, imageSetImages, references, assets, rigRoot,
|
|
921
|
+
get rigPresentation() { return rigPresentation; },
|
|
922
|
+
set rigPresentation(value) {
|
|
923
|
+
clearRigPresentation();
|
|
924
|
+
rigPresentation = value;
|
|
925
|
+
},
|
|
901
926
|
get player() { return player; },
|
|
902
927
|
get inspection() { return inspection; },
|
|
903
|
-
setupPose: () => resetToSetup(),
|
|
928
|
+
setupPose: (setup = true) => resetToSetup(setup),
|
|
904
929
|
dispose,
|
|
905
930
|
};
|
|
906
931
|
}
|
|
@@ -963,6 +988,11 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
963
988
|
let currentElement: HTMLElement | null = null;
|
|
964
989
|
let animation = '';
|
|
965
990
|
let time = 0;
|
|
991
|
+
let playing = false;
|
|
992
|
+
let loop = true;
|
|
993
|
+
let playbackCarry = 0;
|
|
994
|
+
let rafHandle = 0;
|
|
995
|
+
let lastFrameTime = 0;
|
|
966
996
|
let selectedPart = '';
|
|
967
997
|
let partMode: 'context' | 'solo' = 'context';
|
|
968
998
|
let selectedReference = '';
|
|
@@ -974,12 +1004,15 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
974
1004
|
read: () => JobUISubmission['value'];
|
|
975
1005
|
submissionId: string;
|
|
976
1006
|
dirty: boolean;
|
|
1007
|
+
rigSubmission: ReturnType<typeof createJobRigSubmission>;
|
|
977
1008
|
};
|
|
978
1009
|
type PreparedWindow = JobPreparedInspection & {
|
|
979
1010
|
element: HTMLElement;
|
|
980
1011
|
forms: Map<string, JobForm>;
|
|
981
1012
|
};
|
|
982
1013
|
const forms = new Map<string, JobForm>();
|
|
1014
|
+
const drawn = new WeakMap<JobPreparedInspection, JobRigDraw>();
|
|
1015
|
+
let drawGeneration = 0;
|
|
983
1016
|
const viewportState = createViewportState();
|
|
984
1017
|
const el = <Element extends HTMLElement = HTMLElement>(id: string): Element => {
|
|
985
1018
|
const element = workspace.querySelector<HTMLElement>('#' + id);
|
|
@@ -1003,6 +1036,178 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1003
1036
|
fit.textContent = t(fit.textContent ?? 'Fit');
|
|
1004
1037
|
};
|
|
1005
1038
|
const viewport = createViewportController(provider, viewportState);
|
|
1039
|
+
const renderViewport = provider.render;
|
|
1040
|
+
provider.render = controller => {
|
|
1041
|
+
try {renderViewport(controller); rememberDraw();}
|
|
1042
|
+
catch (error) {
|
|
1043
|
+
if (current) {
|
|
1044
|
+
drawn.delete(current);
|
|
1045
|
+
current.rigPresentation = undefined;
|
|
1046
|
+
}
|
|
1047
|
+
throw error;
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
function rigDrawState(): JobRigDrawState {
|
|
1051
|
+
const owner = current, player = owner?.player;
|
|
1052
|
+
if (!owner || !player || !hubVisible) throw new Error('JOB_STILL_CAPTURE_FAILED');
|
|
1053
|
+
const pane = el('rig-viewport'), root = owner.rigRoot, rect = pane.getBoundingClientRect();
|
|
1054
|
+
const ratio = globalThis.devicePixelRatio || 1;
|
|
1055
|
+
const frame = viewport.paneFrame('rig'), camera = viewport.numericView().cameras.rig;
|
|
1056
|
+
if (!frame || !camera || !pane.isConnected || !root.isConnected || el('rig-pane').hidden ||
|
|
1057
|
+
rect.width <= 0 || rect.height <= 0) throw new Error('JOB_STILL_CAPTURE_FAILED');
|
|
1058
|
+
const style = getComputedStyle(root), paneStyle = getComputedStyle(pane);
|
|
1059
|
+
const plain = style.filter === 'none' && style.perspective === 'none' && style.opacity === '1' &&
|
|
1060
|
+
paneStyle.filter === 'none' && paneStyle.transform === 'none' && paneStyle.perspective === 'none' && paneStyle.opacity === '1';
|
|
1061
|
+
const presentation = owner.rigPresentation;
|
|
1062
|
+
const canvas = presentation?.canvas;
|
|
1063
|
+
const pixels = canvas?.getBoundingClientRect();
|
|
1064
|
+
const canvasStyle = canvas ? getComputedStyle(canvas) : null;
|
|
1065
|
+
if (canvas && (!canvas.isConnected || canvasStyle?.visibility !== 'visible' ||
|
|
1066
|
+
canvasStyle.display === 'none' || canvasStyle.opacity !== '1' || canvasStyle.filter !== 'none' ||
|
|
1067
|
+
canvasStyle.transform !== 'none')) throw new Error('JOB_STILL_CAPTURE_FAILED');
|
|
1068
|
+
return {player, presentation, frameGeneration: owner.inspection?.frame('single')?.generation,
|
|
1069
|
+
source: {pageId, publicationId: owner.display.publication.publicationId,
|
|
1070
|
+
instanceKey: owner.display.publication.instanceKey, sourceHash: owner.display.publication.source.sourceHash},
|
|
1071
|
+
layout: JSON.stringify([
|
|
1072
|
+
pane.clientWidth, pane.clientHeight, rect.width, rect.height, ratio,
|
|
1073
|
+
root.getAttribute('style'), style.transform, camera, presentation?.area, presentation?.ratio,
|
|
1074
|
+
pixels ? jobRigPixelPlacement(rect, pixels, ratio) : null,
|
|
1075
|
+
pixels?.width, pixels?.height, canvas?.width, canvas?.height, canvas?.getAttribute('style'),
|
|
1076
|
+
]),
|
|
1077
|
+
defaultCamera: plain && camera.zoom === 1 && camera.center.x === frame.center.x && camera.center.y === frame.center.y,
|
|
1078
|
+
wholeRig: !selectedPart && !owner.inspection?.value() && player.slots === null,
|
|
1079
|
+
playing};
|
|
1080
|
+
}
|
|
1081
|
+
function rememberDraw(): void {
|
|
1082
|
+
const owner = current;
|
|
1083
|
+
if (!owner) return;
|
|
1084
|
+
try {
|
|
1085
|
+
const player = owner.player;
|
|
1086
|
+
const posed = owner.inspection?.frame('single');
|
|
1087
|
+
const camera = viewport.numericView().cameras.rig;
|
|
1088
|
+
if (!hubVisible || !player || !owner.assets || !posed || !camera) {
|
|
1089
|
+
throw new Error('JOB_STILL_CAPTURE_FAILED');
|
|
1090
|
+
}
|
|
1091
|
+
const renderer = player.renderer;
|
|
1092
|
+
const pane = el('rig-viewport');
|
|
1093
|
+
const presentation = presentJobRigViewport({pane, root: owner.rigRoot, images: true,
|
|
1094
|
+
canvas: renderer instanceof CanvasRenderer ? renderer.canvas : undefined,
|
|
1095
|
+
backend: renderer instanceof CanvasRenderer ? renderer.backendActive : renderer.meshBackendActive},
|
|
1096
|
+
{camera, posed, assets: owner.assets});
|
|
1097
|
+
pane.append(presentation.canvas);
|
|
1098
|
+
owner.rigPresentation = presentation;
|
|
1099
|
+
pane.dataset.jobRigCanonical = '';
|
|
1100
|
+
drawn.set(owner, recordJobRigDraw(rigDrawState(), ++drawGeneration));
|
|
1101
|
+
} catch {
|
|
1102
|
+
drawn.delete(owner);
|
|
1103
|
+
owner.rigPresentation = undefined;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function drawInspection(owner: JobPreparedInspection): void {
|
|
1107
|
+
drawn.delete(owner);
|
|
1108
|
+
owner.rigPresentation = undefined;
|
|
1109
|
+
owner.player?.draw();
|
|
1110
|
+
owner.inspection?.present('single');
|
|
1111
|
+
}
|
|
1112
|
+
function syncTransportControls(): void {
|
|
1113
|
+
const playBtn = workspace.querySelector<HTMLButtonElement>('#job-play');
|
|
1114
|
+
if (playBtn) {
|
|
1115
|
+
const clip = current?.assets?.animations.find(item => item.name === animation);
|
|
1116
|
+
playBtn.disabled = !animation || !clip || !(clip.duration > 0) || !current?.player;
|
|
1117
|
+
const key = playing ? 'Pause' : 'Play';
|
|
1118
|
+
playBtn.dataset.jobText = key;
|
|
1119
|
+
playBtn.textContent = t(key);
|
|
1120
|
+
playBtn.setAttribute('aria-pressed', String(playing));
|
|
1121
|
+
}
|
|
1122
|
+
const loopInput = workspace.querySelector<HTMLInputElement>('#job-loop');
|
|
1123
|
+
if (loopInput) loopInput.checked = loop;
|
|
1124
|
+
}
|
|
1125
|
+
function stopPlayback(targetPlayer = current?.player): void {
|
|
1126
|
+
if (rafHandle) {
|
|
1127
|
+
cancelAnimationFrame(rafHandle);
|
|
1128
|
+
rafHandle = 0;
|
|
1129
|
+
}
|
|
1130
|
+
playing = false;
|
|
1131
|
+
playbackCarry = 0;
|
|
1132
|
+
lastFrameTime = 0;
|
|
1133
|
+
targetPlayer?.pause();
|
|
1134
|
+
syncTransportControls();
|
|
1135
|
+
}
|
|
1136
|
+
function presentCurrentFrame(owner: JobPreparedInspection): void {
|
|
1137
|
+
if (!owner.player) return;
|
|
1138
|
+
drawInspection(owner);
|
|
1139
|
+
owner.inspection?.select(selectedPart ? { side: 'single', slot: selectedPart, mode: partMode } : null);
|
|
1140
|
+
setText('job-part-observation', selectedPart ? JSON.stringify(owner.inspection?.observation(), null, 2) : '');
|
|
1141
|
+
viewport.fitCamera();
|
|
1142
|
+
}
|
|
1143
|
+
function armPlayback(expectedOwner: JobPreparedInspection, expectedPlayer: RigPlayer): void {
|
|
1144
|
+
if (rafHandle) {
|
|
1145
|
+
cancelAnimationFrame(rafHandle);
|
|
1146
|
+
rafHandle = 0;
|
|
1147
|
+
}
|
|
1148
|
+
const handle = requestAnimationFrame(now => stepPlayback(handle, expectedOwner, expectedPlayer, now));
|
|
1149
|
+
rafHandle = handle;
|
|
1150
|
+
}
|
|
1151
|
+
function playbackTimeLabel(duration: number, trackTime: number): string {
|
|
1152
|
+
// A one-second 1/60 replay leaves six epsilons after modulo. Limit display snapping
|
|
1153
|
+
// to eight duration-scaled epsilons. The public time and captured frame stay raw.
|
|
1154
|
+
if (trackTime < duration) return String(time);
|
|
1155
|
+
const residue = 8 * Number.EPSILON * duration;
|
|
1156
|
+
if (time <= residue) return '0';
|
|
1157
|
+
if (duration - time <= residue) return String(duration);
|
|
1158
|
+
return String(time);
|
|
1159
|
+
}
|
|
1160
|
+
function stepPlayback(handle: number, expectedOwner: JobPreparedInspection, expectedPlayer: RigPlayer, now: number): void {
|
|
1161
|
+
if (current !== expectedOwner || current?.player !== expectedPlayer) {
|
|
1162
|
+
expectedPlayer.pause();
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
if (handle !== rafHandle) return;
|
|
1166
|
+
rafHandle = 0;
|
|
1167
|
+
const clip = expectedOwner.assets?.animations.find(item => item.name === animation);
|
|
1168
|
+
if (!playing || !hubVisible || !animation || !clip || !(clip.duration > 0)) {
|
|
1169
|
+
stopPlayback(expectedPlayer);
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
const dt = lastFrameTime > 0 ? Math.min(Math.max(0, (now - lastFrameTime) / 1000), 0.1) : 0;
|
|
1173
|
+
lastFrameTime = now;
|
|
1174
|
+
const next = advancePlayback({ time, duration: clip.duration, carry: playbackCarry, elapsed: dt, repeat: loop });
|
|
1175
|
+
for (const step of next.steps) expectedPlayer.advance(step);
|
|
1176
|
+
const activeEntry = expectedPlayer.entry(0);
|
|
1177
|
+
if (!activeEntry || activeEntry.animation !== animation || activeEntry.loop !== loop ||
|
|
1178
|
+
!Number.isFinite(activeEntry.animationTime) || activeEntry.animationTime < 0 ||
|
|
1179
|
+
activeEntry.animationTime > activeEntry.duration) {
|
|
1180
|
+
stopPlayback(expectedPlayer);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
playbackCarry = next.carry;
|
|
1184
|
+
if (next.ended) {
|
|
1185
|
+
playing = false;
|
|
1186
|
+
playbackCarry = 0;
|
|
1187
|
+
lastFrameTime = 0;
|
|
1188
|
+
expectedPlayer.pause();
|
|
1189
|
+
time = clip.duration;
|
|
1190
|
+
} else {
|
|
1191
|
+
time = activeEntry.animationTime;
|
|
1192
|
+
}
|
|
1193
|
+
const clock = workspace.querySelector<HTMLInputElement>('#job-time');
|
|
1194
|
+
if (clock) clock.value = playbackTimeLabel(clip.duration, activeEntry.trackTime);
|
|
1195
|
+
syncTransportControls();
|
|
1196
|
+
presentCurrentFrame(expectedOwner);
|
|
1197
|
+
if (playing && current === expectedOwner && current.player === expectedPlayer && hubVisible) {
|
|
1198
|
+
armPlayback(expectedOwner, expectedPlayer);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
function copyRigVerdict(ask: JobPendingAsk, owner: JobPreparedInspection) {
|
|
1202
|
+
if (owner !== current || ask.publicationId !== owner.display.publication.publicationId) {
|
|
1203
|
+
throw new Error('JOB_STILL_BINDING_MISMATCH');
|
|
1204
|
+
}
|
|
1205
|
+
assertJobAskSource(ask, owner.display);
|
|
1206
|
+
return freezeJobRigCapture(drawn.get(owner), rigDrawState(), ask.askId, () => {
|
|
1207
|
+
if (!owner.rigPresentation) throw new Error('JOB_STILL_CAPTURE_FAILED');
|
|
1208
|
+
return copyJobRigViewport(owner.rigPresentation);
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1006
1211
|
const referenceSelection = createJobReferenceSelection<JobReferenceView>({
|
|
1007
1212
|
current: () => ({owner: current, time}),
|
|
1008
1213
|
present(value) {
|
|
@@ -1225,7 +1430,8 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1225
1430
|
const status = node('p');
|
|
1226
1431
|
status.setAttribute('role', 'status');
|
|
1227
1432
|
form.append(status);
|
|
1228
|
-
const entry = { form, fieldset: fields, read, submissionId: crypto.randomUUID(), dirty: false
|
|
1433
|
+
const entry: JobForm = { form, fieldset: fields, read, submissionId: crypto.randomUUID(), dirty: false,
|
|
1434
|
+
rigSubmission: createJobRigSubmission() };
|
|
1229
1435
|
try {
|
|
1230
1436
|
const saved = JSON.parse(localStorage.getItem(localDraftKey(prepared.display)) ?? 'null');
|
|
1231
1437
|
if (saved?.publicationId === prepared.display.publication.publicationId &&
|
|
@@ -1248,25 +1454,36 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1248
1454
|
}
|
|
1249
1455
|
}
|
|
1250
1456
|
catch { /* Invalid or unavailable local drafts grant no submission authority. */ }
|
|
1251
|
-
form.oninput = () => { entry.dirty = true; entry.submissionId = crypto.randomUUID(); saveDraft(); };
|
|
1457
|
+
form.oninput = () => { entry.dirty = true; entry.submissionId = crypto.randomUUID(); entry.rigSubmission.reset(); saveDraft(); };
|
|
1252
1458
|
form.onsubmit = async (event) => {
|
|
1253
1459
|
event.preventDefault();
|
|
1254
1460
|
const state = window.state();
|
|
1255
1461
|
const receipt = state.receipt;
|
|
1256
1462
|
if (!receipt || state.preparing || state.closed || !access.capability || !form.reportValidity())
|
|
1257
1463
|
return;
|
|
1258
|
-
fields.disabled = true;
|
|
1259
1464
|
try {
|
|
1260
|
-
const
|
|
1465
|
+
const input = { kind: subject.kind, publicationId: ask.publicationId,
|
|
1261
1466
|
askId: ask.askId, pageId, displayedNonce: receipt.displayedNonce,
|
|
1262
|
-
expectedGeneration: state.generation, submissionId: entry.submissionId, value: read() } as JobUISubmission
|
|
1467
|
+
expectedGeneration: state.generation, submissionId: entry.submissionId, value: read() } as JobUISubmission;
|
|
1468
|
+
const activeAsk = state.pending.find(item => item.askId === ask.askId);
|
|
1469
|
+
if (!activeAsk) throw new Error('JOB_ASK_INVALID');
|
|
1470
|
+
const pending = subject.kind === 'review-verdict' && subject.stage === 'rig-review'
|
|
1471
|
+
? entry.rigSubmission.prepare(input, () => copyRigVerdict(activeAsk, prepared)) : Promise.resolve(input);
|
|
1472
|
+
fields.disabled = true;
|
|
1473
|
+
const frozen = await pending;
|
|
1474
|
+
if (entry.submissionId !== frozen.submissionId) throw new Error('JOB_STILL_BINDING_MISMATCH');
|
|
1475
|
+
const result = await window.submit(frozen);
|
|
1263
1476
|
if (!result.ok)
|
|
1264
1477
|
throw new Error(result.error.code);
|
|
1265
1478
|
entry.dirty = false;
|
|
1479
|
+
entry.rigSubmission.reset();
|
|
1480
|
+
status.dataset.jobText = 'job.saved';
|
|
1266
1481
|
status.textContent = t('job.saved');
|
|
1267
1482
|
saveDraft();
|
|
1268
1483
|
}
|
|
1269
1484
|
catch (error) {
|
|
1485
|
+
status.dataset.jobText = error instanceof Error && Object.hasOwn(enCatalog, error.message) && Object.hasOwn(koCatalog, error.message)
|
|
1486
|
+
? error.message : 'JOB_ACT_INVALID';
|
|
1270
1487
|
status.textContent = jobWindowRefusal(error, 'JOB_ACT_INVALID');
|
|
1271
1488
|
fields.disabled = false;
|
|
1272
1489
|
}
|
|
@@ -1407,12 +1624,83 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1407
1624
|
option.textContent = clip.name;
|
|
1408
1625
|
clips.append(option);
|
|
1409
1626
|
}
|
|
1410
|
-
clips.onchange = () => { animation = clips.value; time = 0; pose(); };
|
|
1627
|
+
clips.onchange = () => { stopPlayback(); animation = clips.value; time = 0; pose(); };
|
|
1628
|
+
const playButton = node('button', 'Play');
|
|
1629
|
+
playButton.id = 'job-play';
|
|
1630
|
+
playButton.type = 'button';
|
|
1631
|
+
playButton.setAttribute('aria-pressed', 'false');
|
|
1632
|
+
playButton.disabled = true;
|
|
1633
|
+
playButton.onclick = () => {
|
|
1634
|
+
const clip = current?.assets?.animations.find(item => item.name === animation);
|
|
1635
|
+
if (!current?.player || !animation || !clip || !(clip.duration > 0)) {
|
|
1636
|
+
stopPlayback();
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1639
|
+
if (playing) {
|
|
1640
|
+
stopPlayback();
|
|
1641
|
+
presentCurrentFrame(current);
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
if (current.player.composed) current.setupPose(false);
|
|
1645
|
+
if (!loop && time >= clip.duration) {
|
|
1646
|
+
time = 0;
|
|
1647
|
+
current.player.play(animation, { loop });
|
|
1648
|
+
} else if (current.player.current !== animation) {
|
|
1649
|
+
current.player.play(animation, { loop });
|
|
1650
|
+
if (time > 0) current.player.seek(time);
|
|
1651
|
+
} else {
|
|
1652
|
+
current.player.resume();
|
|
1653
|
+
}
|
|
1654
|
+
playing = true;
|
|
1655
|
+
playbackCarry = 0;
|
|
1656
|
+
lastFrameTime = 0;
|
|
1657
|
+
const clockInput = workspace.querySelector<HTMLInputElement>('#job-time');
|
|
1658
|
+
if (clockInput) clockInput.value = playbackTimeLabel(clip.duration, current.player.time);
|
|
1659
|
+
syncTransportControls();
|
|
1660
|
+
presentCurrentFrame(current);
|
|
1661
|
+
if (hubVisible) armPlayback(current, current.player);
|
|
1662
|
+
};
|
|
1663
|
+
const loopInput = node('input');
|
|
1664
|
+
loopInput.id = 'job-loop';
|
|
1665
|
+
loopInput.type = 'checkbox';
|
|
1666
|
+
loopInput.checked = loop;
|
|
1667
|
+
loopInput.onchange = () => {
|
|
1668
|
+
loop = loopInput.checked;
|
|
1669
|
+
playbackCarry = 0;
|
|
1670
|
+
lastFrameTime = 0;
|
|
1671
|
+
const clip = current?.assets?.animations.find(item => item.name === animation);
|
|
1672
|
+
if (current?.player && animation && clip) {
|
|
1673
|
+
if (current.player.composed) current.setupPose(false);
|
|
1674
|
+
current.player.play(animation, { loop });
|
|
1675
|
+
if (time > 0) current.player.seek(time);
|
|
1676
|
+
const activeEntry = current.player.entry(0);
|
|
1677
|
+
if (!activeEntry || activeEntry.animation !== animation || activeEntry.loop !== loop ||
|
|
1678
|
+
!Number.isFinite(activeEntry.animationTime) || activeEntry.animationTime < 0 ||
|
|
1679
|
+
activeEntry.animationTime > activeEntry.duration) {
|
|
1680
|
+
stopPlayback(current.player);
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
time = activeEntry.animationTime;
|
|
1684
|
+
const clockInput = workspace.querySelector<HTMLInputElement>('#job-time');
|
|
1685
|
+
if (clockInput) clockInput.value = playbackTimeLabel(clip.duration, activeEntry.trackTime);
|
|
1686
|
+
if (!playing) current.player.pause();
|
|
1687
|
+
syncTransportControls();
|
|
1688
|
+
presentCurrentFrame(current);
|
|
1689
|
+
if (playing && hubVisible) armPlayback(current, current.player);
|
|
1690
|
+
} else {
|
|
1691
|
+
syncTransportControls();
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1411
1694
|
const clock = node('input');
|
|
1412
1695
|
clock.id = 'job-time';
|
|
1413
1696
|
clock.type = 'number';
|
|
1414
1697
|
clock.min = '0';
|
|
1415
1698
|
clock.step = '0.001';
|
|
1699
|
+
clock.oninput = () => {
|
|
1700
|
+
if (!playing) return;
|
|
1701
|
+
stopPlayback();
|
|
1702
|
+
if (current) presentCurrentFrame(current);
|
|
1703
|
+
};
|
|
1416
1704
|
clock.onchange = () => {
|
|
1417
1705
|
const value = Number(clock.value);
|
|
1418
1706
|
const duration = current?.assets?.animations.find(clip => clip.name === animation)?.duration;
|
|
@@ -1421,13 +1709,14 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1421
1709
|
notice.textContent = t('KEY_TIME_OUT_OF_DOMAIN');
|
|
1422
1710
|
return;
|
|
1423
1711
|
}
|
|
1712
|
+
stopPlayback();
|
|
1424
1713
|
time = value;
|
|
1425
1714
|
pose();
|
|
1426
1715
|
};
|
|
1427
1716
|
const panels = selectValues(['1', '2', '3', '4'], ['1 Parts + mesh', '2 Interview', '3 Rig + animation', '4 Direction']);
|
|
1428
1717
|
panels.id = 'job-panel';
|
|
1429
1718
|
panels.onchange = () => { panel = panels.value; showPanel(); };
|
|
1430
|
-
transport.append(clips, inputLabel('job.time', clock), panels);
|
|
1719
|
+
transport.append(clips, playButton, inputLabel('Repeat', loopInput), inputLabel('job.time', clock), panels);
|
|
1431
1720
|
const numeric = node('pre');
|
|
1432
1721
|
numeric.id = 'view-coordinates';
|
|
1433
1722
|
numeric.hidden = true;
|
|
@@ -1506,7 +1795,10 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1506
1795
|
function selectPart(): void {
|
|
1507
1796
|
if (!current?.inspection)
|
|
1508
1797
|
return;
|
|
1798
|
+
drawn.delete(current);
|
|
1799
|
+
current.rigPresentation = undefined;
|
|
1509
1800
|
current.inspection.select(selectedPart ? { side: 'single', slot: selectedPart, mode: partMode } : null);
|
|
1801
|
+
rememberDraw();
|
|
1510
1802
|
setText('job-part-observation', selectedPart ? JSON.stringify(current.inspection.observation(), null, 2) : '');
|
|
1511
1803
|
viewport.renderCameraControls();
|
|
1512
1804
|
}
|
|
@@ -1536,17 +1828,33 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1536
1828
|
return;
|
|
1537
1829
|
}
|
|
1538
1830
|
if (!animation && current.player?.current) current.setupPose();
|
|
1831
|
+
// Setup uses an empty composed track. Animation seek needs a fresh single track.
|
|
1832
|
+
if (animation && current.player?.composed) current.setupPose(false);
|
|
1539
1833
|
if (current.player) {
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
if (animation)
|
|
1834
|
+
drawn.delete(current);
|
|
1835
|
+
current.rigPresentation = undefined;
|
|
1836
|
+
if (animation && (current.player.current !== animation || current.player.entry(0)?.loop !== loop))
|
|
1837
|
+
current.player.play(animation, { loop });
|
|
1838
|
+
if (animation) {
|
|
1839
|
+
const seekAtLoopEnd = loop && time === clip?.duration;
|
|
1543
1840
|
current.player.seek(time);
|
|
1841
|
+
const activeEntry = current.player.entry(0);
|
|
1842
|
+
if (!activeEntry || activeEntry.animation !== animation || activeEntry.loop !== loop ||
|
|
1843
|
+
!Number.isFinite(activeEntry.animationTime) || activeEntry.animationTime < 0 ||
|
|
1844
|
+
activeEntry.animationTime > activeEntry.duration) {
|
|
1845
|
+
current.player.pause();
|
|
1846
|
+
notice.textContent = t('JOB_VISUAL_UNAVAILABLE');
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
time = activeEntry.animationTime;
|
|
1850
|
+
clock.value = seekAtLoopEnd ? '0' : String(time);
|
|
1851
|
+
}
|
|
1544
1852
|
current.player.pause();
|
|
1545
|
-
current
|
|
1546
|
-
current.inspection?.present('single');
|
|
1853
|
+
drawInspection(current);
|
|
1547
1854
|
current.inspection?.select(selectedPart ? { side: 'single', slot: selectedPart, mode: partMode } : null);
|
|
1548
1855
|
setText('job-part-observation', selectedPart ? JSON.stringify(current.inspection?.observation(), null, 2) : '');
|
|
1549
1856
|
}
|
|
1857
|
+
syncTransportControls();
|
|
1550
1858
|
if (seekReference) {
|
|
1551
1859
|
const value = reference();
|
|
1552
1860
|
const owner = current;
|
|
@@ -1565,7 +1873,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1565
1873
|
}
|
|
1566
1874
|
function pauseHiddenHubFrame(): void {
|
|
1567
1875
|
if (hubVisible) return;
|
|
1568
|
-
|
|
1876
|
+
stopPlayback();
|
|
1569
1877
|
for (const video of workspace.querySelectorAll('video')) video.pause();
|
|
1570
1878
|
}
|
|
1571
1879
|
function announceHubFrame(): void {
|
|
@@ -1595,6 +1903,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1595
1903
|
for (const entry of nextForms.values()) formHost.append(entry.form);
|
|
1596
1904
|
referenceSelection.cancel();
|
|
1597
1905
|
const previous = current;
|
|
1906
|
+
stopPlayback(previous?.player);
|
|
1598
1907
|
const previousElement = currentElement;
|
|
1599
1908
|
const previousForms = new Map(forms);
|
|
1600
1909
|
const navigation = { animation, time, selectedPart, partMode, selectedReference, panel,
|
|
@@ -1614,6 +1923,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1614
1923
|
let nextUnbind: (() => void) | null = null;
|
|
1615
1924
|
let nextResize: ResizeObserver | null = null;
|
|
1616
1925
|
const rollback = () => {
|
|
1926
|
+
stopPlayback(prepared.player);
|
|
1617
1927
|
nextUnbind?.();
|
|
1618
1928
|
nextResize?.disconnect();
|
|
1619
1929
|
current = previous;
|
|
@@ -1631,6 +1941,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1631
1941
|
Object.assign(viewportState, navigation.camera);
|
|
1632
1942
|
if (current) {
|
|
1633
1943
|
el<HTMLSelectElement>('job-reference').value = selectedReference;
|
|
1944
|
+
syncTransportControls();
|
|
1634
1945
|
viewport.fitCamera();
|
|
1635
1946
|
}
|
|
1636
1947
|
};
|
|
@@ -1690,8 +2001,8 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1690
2001
|
}
|
|
1691
2002
|
await reference()?.seek(time, signal);
|
|
1692
2003
|
if (prepared.player) {
|
|
1693
|
-
prepared
|
|
1694
|
-
|
|
2004
|
+
drawInspection(prepared);
|
|
2005
|
+
rememberDraw();
|
|
1695
2006
|
}
|
|
1696
2007
|
await new Promise<void>(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
|
1697
2008
|
if (signal.aborted)
|
|
@@ -1712,6 +2023,11 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1712
2023
|
? t('job.updated', [state.previousLabel, state.displayed.publication.label]) : state.displayed.publication.label;
|
|
1713
2024
|
if (compatibilityNotice)
|
|
1714
2025
|
notice.textContent += ' · ' + t('job.incompatible');
|
|
2026
|
+
if (state.closed) {
|
|
2027
|
+
const wasPlaying = playing;
|
|
2028
|
+
stopPlayback();
|
|
2029
|
+
if (wasPlaying && current) presentCurrentFrame(current);
|
|
2030
|
+
}
|
|
1715
2031
|
updateForms(state);
|
|
1716
2032
|
if (current)
|
|
1717
2033
|
showPanel();
|
|
@@ -1757,14 +2073,32 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1757
2073
|
i18n.setLinkLanguage(null); i18n.setLanguagePreference(event.data.language);
|
|
1758
2074
|
}
|
|
1759
2075
|
pauseHiddenHubFrame();
|
|
1760
|
-
if (hubVisible)
|
|
2076
|
+
if (current && !hubVisible) {
|
|
2077
|
+
drawn.delete(current);
|
|
2078
|
+
current.rigPresentation = undefined;
|
|
2079
|
+
}
|
|
2080
|
+
if (hubVisible && current?.player) {drawInspection(current); rememberDraw();}
|
|
1761
2081
|
};
|
|
1762
2082
|
if (hubIncarnation) {globalThis.addEventListener('message', hubVisibility); announceHubFrame();}
|
|
1763
2083
|
events = startJobWindowEvents({access, signal: abort.signal, member: !!hubIncarnation,
|
|
1764
2084
|
event: event => window.event(event),
|
|
1765
2085
|
refused: error => {notice.textContent = jobWindowRefusal(error, 'JOB_STREAM_FAILED');},
|
|
1766
2086
|
});
|
|
2087
|
+
let resolution: MediaQueryList | undefined;
|
|
2088
|
+
const resolutionChanged = () => {
|
|
2089
|
+
resolution?.removeEventListener('change', resolutionChanged);
|
|
2090
|
+
resolution = globalThis.matchMedia(`(resolution:${globalThis.devicePixelRatio || 1}dppx)`);
|
|
2091
|
+
resolution.addEventListener('change', resolutionChanged);
|
|
2092
|
+
if (current) {
|
|
2093
|
+
drawn.delete(current);
|
|
2094
|
+
current.rigPresentation = undefined;
|
|
2095
|
+
viewport.fitCamera();
|
|
2096
|
+
}
|
|
2097
|
+
};
|
|
2098
|
+
resolutionChanged();
|
|
1767
2099
|
const stop = () => {
|
|
2100
|
+
stopPlayback();
|
|
2101
|
+
resolution?.removeEventListener('change', resolutionChanged);
|
|
1768
2102
|
globalThis.removeEventListener('message', hubVisibility);
|
|
1769
2103
|
saveDraft();
|
|
1770
2104
|
referenceSelection.cancel();
|
package/web/parts.ts
CHANGED
|
@@ -546,8 +546,13 @@ function setupPartsComments():void {
|
|
|
546
546
|
if (typeof document !== 'undefined' && document.getElementById('parts-app')) void boot();
|
|
547
547
|
|
|
548
548
|
function renderCorrections():void {
|
|
549
|
+
const data = state.data;
|
|
550
|
+
if (!stageEmbedded && (!data || (!Object.hasOwn(data, 'draft') && !Object.hasOwn(data, 'draftUnavailable')))) {
|
|
551
|
+
document.getElementById('pv-corrections')?.remove();
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
549
554
|
let host=document.getElementById('pv-corrections');if(!host){host=document.createElement('section');host.id='pv-corrections';document.querySelector('.pv-toolbar')!.after(host);}
|
|
550
|
-
host.replaceChildren();const
|
|
555
|
+
host.replaceChildren();const item=data?.items[state.selected],mapping=data?.draft?.mappings.find(m=>m.part===item?.name);
|
|
551
556
|
const label=document.createElement('p');label.textContent=t(data?.draft&&!mapping?'STAGE_DRAFT_NO_MESH: this part has no mesh attachment; direct correction is unavailable.':data?.draft?.label??data?.draftUnavailable??'STAGE_DRAFT_UNAVAILABLE: no producer-compatible draft is supplied.');host.append(label);
|
|
552
557
|
if(!mapping||!data?.draft)return;
|
|
553
558
|
label.textContent+=` · ${mapping.part} · ${mapping.skin}/${mapping.slot}/${mapping.attachment} · v ${mapping.vertices} t ${mapping.triangles} · ${data.draft.buildId}`;
|
package/web/styles.css
CHANGED
|
@@ -462,3 +462,17 @@ body.job-window{display:grid;grid-template-rows:auto auto minmax(0,1fr);height:1
|
|
|
462
462
|
.job-window .job-part-images{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
|
|
463
463
|
.job-window .job-part-images img{width:100%;height:auto;background:var(--rv-media-bg)}
|
|
464
464
|
@media(max-width:780px){.job-window .job-inspection{grid-template-columns:160px minmax(0,1fr)}.job-window .job-stage #stage-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:repeat(2,minmax(0,1fr))}}
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
.job-window #rig-viewport[data-job-rig-canonical] > #rig-root {
|
|
468
|
+
visibility: hidden;
|
|
469
|
+
}
|
|
470
|
+
.job-window #rig-viewport > .job-rig-presentation {
|
|
471
|
+
position: absolute;
|
|
472
|
+
z-index: 0;
|
|
473
|
+
visibility: visible;
|
|
474
|
+
pointer-events: none;
|
|
475
|
+
user-select: none;
|
|
476
|
+
transform: none;
|
|
477
|
+
opacity: 1;
|
|
478
|
+
}
|