@rig-c/review 2.5.0 → 2.7.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 +50 -12
- package/docs/STABILITY.md +232 -15
- package/docs/WORKFLOWS.md +37 -1
- package/package.json +1 -1
- package/src/cli.ts +52 -7
- package/src/job-act.ts +316 -8
- package/src/job-api.ts +821 -8
- package/src/job-cli.ts +219 -52
- 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/parts-server.ts +46 -7
- package/src/parts-view.ts +76 -14
- package/web/catalog-en.ts +9 -0
- package/web/catalog-ko.ts +9 -0
- package/web/job-rig-capture.ts +53 -11
- package/web/job-session.ts +196 -7
package/web/job-session.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {t} from './i18n.ts';
|
|
|
6
6
|
import {JOB_HUB_READY, jobHubMessageMatches, type JobHubBinding} from './job-hub.ts';
|
|
7
7
|
import {recordJobRigDraw, freezeJobRigCapture, copyJobRigViewport, createJobRigSubmission, jobRigPixelPlacement,
|
|
8
8
|
type JobRigDraw, type JobRigDrawState} from './job-rig-capture.ts';
|
|
9
|
+
import {advancePlayback} from './playback-clock.ts';
|
|
9
10
|
import {presentJobRigViewport, type JobRigPresentation} from './viewport-capture.ts';
|
|
10
11
|
import {CanvasRenderer} from '@rig-c/play';
|
|
11
12
|
|
|
@@ -987,6 +988,11 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
987
988
|
let currentElement: HTMLElement | null = null;
|
|
988
989
|
let animation = '';
|
|
989
990
|
let time = 0;
|
|
991
|
+
let playing = false;
|
|
992
|
+
let loop = true;
|
|
993
|
+
let playbackCarry = 0;
|
|
994
|
+
let rafHandle = 0;
|
|
995
|
+
let lastFrameTime = 0;
|
|
990
996
|
let selectedPart = '';
|
|
991
997
|
let partMode: 'context' | 'solo' = 'context';
|
|
992
998
|
let selectedReference = '';
|
|
@@ -1070,7 +1076,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1070
1076
|
]),
|
|
1071
1077
|
defaultCamera: plain && camera.zoom === 1 && camera.center.x === frame.center.x && camera.center.y === frame.center.y,
|
|
1072
1078
|
wholeRig: !selectedPart && !owner.inspection?.value() && player.slots === null,
|
|
1073
|
-
playing
|
|
1079
|
+
playing};
|
|
1074
1080
|
}
|
|
1075
1081
|
function rememberDraw(): void {
|
|
1076
1082
|
const owner = current;
|
|
@@ -1103,6 +1109,95 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1103
1109
|
owner.player?.draw();
|
|
1104
1110
|
owner.inspection?.present('single');
|
|
1105
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
|
+
}
|
|
1106
1201
|
function copyRigVerdict(ask: JobPendingAsk, owner: JobPreparedInspection) {
|
|
1107
1202
|
if (owner !== current || ask.publicationId !== owner.display.publication.publicationId) {
|
|
1108
1203
|
throw new Error('JOB_STILL_BINDING_MISMATCH');
|
|
@@ -1529,12 +1624,83 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1529
1624
|
option.textContent = clip.name;
|
|
1530
1625
|
clips.append(option);
|
|
1531
1626
|
}
|
|
1532
|
-
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
|
+
};
|
|
1533
1694
|
const clock = node('input');
|
|
1534
1695
|
clock.id = 'job-time';
|
|
1535
1696
|
clock.type = 'number';
|
|
1536
1697
|
clock.min = '0';
|
|
1537
1698
|
clock.step = '0.001';
|
|
1699
|
+
clock.oninput = () => {
|
|
1700
|
+
if (!playing) return;
|
|
1701
|
+
stopPlayback();
|
|
1702
|
+
if (current) presentCurrentFrame(current);
|
|
1703
|
+
};
|
|
1538
1704
|
clock.onchange = () => {
|
|
1539
1705
|
const value = Number(clock.value);
|
|
1540
1706
|
const duration = current?.assets?.animations.find(clip => clip.name === animation)?.duration;
|
|
@@ -1543,13 +1709,14 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1543
1709
|
notice.textContent = t('KEY_TIME_OUT_OF_DOMAIN');
|
|
1544
1710
|
return;
|
|
1545
1711
|
}
|
|
1712
|
+
stopPlayback();
|
|
1546
1713
|
time = value;
|
|
1547
1714
|
pose();
|
|
1548
1715
|
};
|
|
1549
1716
|
const panels = selectValues(['1', '2', '3', '4'], ['1 Parts + mesh', '2 Interview', '3 Rig + animation', '4 Direction']);
|
|
1550
1717
|
panels.id = 'job-panel';
|
|
1551
1718
|
panels.onchange = () => { panel = panels.value; showPanel(); };
|
|
1552
|
-
transport.append(clips, inputLabel('job.time', clock), panels);
|
|
1719
|
+
transport.append(clips, playButton, inputLabel('Repeat', loopInput), inputLabel('job.time', clock), panels);
|
|
1553
1720
|
const numeric = node('pre');
|
|
1554
1721
|
numeric.id = 'view-coordinates';
|
|
1555
1722
|
numeric.hidden = true;
|
|
@@ -1666,15 +1833,28 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1666
1833
|
if (current.player) {
|
|
1667
1834
|
drawn.delete(current);
|
|
1668
1835
|
current.rigPresentation = undefined;
|
|
1669
|
-
if (animation && current.player.current !== animation)
|
|
1670
|
-
current.player.play(animation, { loop
|
|
1671
|
-
if (animation)
|
|
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;
|
|
1672
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
|
+
}
|
|
1673
1852
|
current.player.pause();
|
|
1674
1853
|
drawInspection(current);
|
|
1675
1854
|
current.inspection?.select(selectedPart ? { side: 'single', slot: selectedPart, mode: partMode } : null);
|
|
1676
1855
|
setText('job-part-observation', selectedPart ? JSON.stringify(current.inspection?.observation(), null, 2) : '');
|
|
1677
1856
|
}
|
|
1857
|
+
syncTransportControls();
|
|
1678
1858
|
if (seekReference) {
|
|
1679
1859
|
const value = reference();
|
|
1680
1860
|
const owner = current;
|
|
@@ -1693,7 +1873,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1693
1873
|
}
|
|
1694
1874
|
function pauseHiddenHubFrame(): void {
|
|
1695
1875
|
if (hubVisible) return;
|
|
1696
|
-
|
|
1876
|
+
stopPlayback();
|
|
1697
1877
|
for (const video of workspace.querySelectorAll('video')) video.pause();
|
|
1698
1878
|
}
|
|
1699
1879
|
function announceHubFrame(): void {
|
|
@@ -1723,6 +1903,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1723
1903
|
for (const entry of nextForms.values()) formHost.append(entry.form);
|
|
1724
1904
|
referenceSelection.cancel();
|
|
1725
1905
|
const previous = current;
|
|
1906
|
+
stopPlayback(previous?.player);
|
|
1726
1907
|
const previousElement = currentElement;
|
|
1727
1908
|
const previousForms = new Map(forms);
|
|
1728
1909
|
const navigation = { animation, time, selectedPart, partMode, selectedReference, panel,
|
|
@@ -1742,6 +1923,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1742
1923
|
let nextUnbind: (() => void) | null = null;
|
|
1743
1924
|
let nextResize: ResizeObserver | null = null;
|
|
1744
1925
|
const rollback = () => {
|
|
1926
|
+
stopPlayback(prepared.player);
|
|
1745
1927
|
nextUnbind?.();
|
|
1746
1928
|
nextResize?.disconnect();
|
|
1747
1929
|
current = previous;
|
|
@@ -1759,6 +1941,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1759
1941
|
Object.assign(viewportState, navigation.camera);
|
|
1760
1942
|
if (current) {
|
|
1761
1943
|
el<HTMLSelectElement>('job-reference').value = selectedReference;
|
|
1944
|
+
syncTransportControls();
|
|
1762
1945
|
viewport.fitCamera();
|
|
1763
1946
|
}
|
|
1764
1947
|
};
|
|
@@ -1840,6 +2023,11 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1840
2023
|
? t('job.updated', [state.previousLabel, state.displayed.publication.label]) : state.displayed.publication.label;
|
|
1841
2024
|
if (compatibilityNotice)
|
|
1842
2025
|
notice.textContent += ' · ' + t('job.incompatible');
|
|
2026
|
+
if (state.closed) {
|
|
2027
|
+
const wasPlaying = playing;
|
|
2028
|
+
stopPlayback();
|
|
2029
|
+
if (wasPlaying && current) presentCurrentFrame(current);
|
|
2030
|
+
}
|
|
1843
2031
|
updateForms(state);
|
|
1844
2032
|
if (current)
|
|
1845
2033
|
showPanel();
|
|
@@ -1909,6 +2097,7 @@ export async function mountJobSession(host: HTMLElement): Promise<() => void> {
|
|
|
1909
2097
|
};
|
|
1910
2098
|
resolutionChanged();
|
|
1911
2099
|
const stop = () => {
|
|
2100
|
+
stopPlayback();
|
|
1912
2101
|
resolution?.removeEventListener('change', resolutionChanged);
|
|
1913
2102
|
globalThis.removeEventListener('message', hubVisibility);
|
|
1914
2103
|
saveDraft();
|