rig-review 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/PANELS.md CHANGED
@@ -30,6 +30,12 @@ body. A drawer keeps its title and close button in place while its body
30
30
  scrolls. The per-inspection **Repeat idle** toggle sits in the Animate
31
31
  transport row.
32
32
 
33
+ Animate plays in fixed 1/60 s steps taken from wall-clock time
34
+ (`web/playback-clock.ts`), so the clip and its physics advance the same way at
35
+ any display refresh rate; a frame with less than one step's worth of time draws
36
+ nothing new. A repeating clip wraps without a seek, so physics carries across
37
+ the loop seam; only **Reset physics**, a seek or choosing a clip restarts it.
38
+
33
39
  **Settings** (`#workspace-settings`) stores workspace-level preferences across
34
40
  tabs under `rig-review.workspace.v1` (`web/workspace-preferences.ts`):
35
41
  **Appearance** (`system`, `dark`, `light`), **Language** (`system`, `en`, `ko`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rig-review",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "type": "module",
5
5
  "description": "Local human rig inspection and structured feedback export",
6
6
  "license": "MIT",
package/web/main.ts CHANGED
@@ -62,6 +62,7 @@ import {appliedBuildOwner,appliedPanelOps,dropNoticeForPanel,reconcilePanelStatu
62
62
  import {bindPhysicsPanel,type PhysicsPanel} from './physics-panel.ts';
63
63
  import {bindIdlePanel,type BoneSetup,type IdlePanel} from './idle-panel.ts';
64
64
  import {composeAdjust,PhysicsPreview} from './preview.ts';
65
+ import {advancePlayback,cueDue} from './playback-clock.ts';
65
66
  import {bindRigFieldsPanel,type RigFieldsPanel} from './rig-fields-panel.ts';
66
67
  import {assertRigFieldOps,RIG_FIELDS_READOUT_BARS,TURN_BONE} from '../src/rig-fields.ts';
67
68
  import {IDLE_READOUT_BARS,type LocalChannel} from '../src/idle-tracks.ts';
@@ -103,6 +104,8 @@ let time = 0;
103
104
  let stageClock: StageClock | null = null;
104
105
  let duration = 0;
105
106
  let lastFrame = 0;
107
+ /** #346: wall-clock seconds accumulated toward the next fixed playback step. */
108
+ let playbackCarry = 0;
106
109
  type CameraTarget='rig'|'reference';
107
110
  let cameraSync=true,activeCamera:CameraTarget='rig',cameraRestoring=false,cameraLayout='';
108
111
  const cameraFrames:Partial<Record<CameraTarget,CameraFrame>>={};
@@ -505,7 +508,7 @@ function chooseAnimation(name: string, move: ClipMove = { kind: 'choose' }): voi
505
508
  select('animation-select').value = name;
506
509
  // #191: the wind restarts before the clip's first frame is drawn, so the paused stage shows the schedule's t=0 world.
507
510
  time = 0; clipMoved(move);
508
- if (player && runtimeAnimation) { drawRig(()=>{player!.play(name,{loop:false});player!.pause();refreshAnimationInspection();player!.draw();}); }
511
+ if (player && runtimeAnimation) { drawRig(()=>{player!.play(name,{loop:canRepeatIdle()});player!.pause();refreshAnimationInspection();player!.draw();}); }
509
512
  else if (player && name){text('renderer-state',rendererStatus(null,'failed').label);message(`Animation "${name}" is not present in the rig.`, true);}
510
513
  renderTransport(); renderCues();renderIdle();
511
514
  }
@@ -519,7 +522,7 @@ function seek(value: number, move?: ClipMove): void {
519
522
  }
520
523
 
521
524
  function stopAudio(): void { for (const audio of audioPlaying) audio.pause(); audioPlaying.clear(); }
522
- function pause(): void { ++playbackIntent;desiredPlay=false;suspendedPreview=false;idleHeld=true; playing = false; lastFrame = 0; player?.pause(); video?.pause(); stopAudio(); button('play').textContent = '▶'; button('play').setAttribute('aria-label', 'Play'); }
525
+ function pause(): void { ++playbackIntent;desiredPlay=false;suspendedPreview=false;idleHeld=true; playing = false; lastFrame = 0; playbackCarry = 0; player?.pause(); video?.pause(); stopAudio(); button('play').textContent = '▶'; button('play').setAttribute('aria-label', 'Play'); }
523
526
 
524
527
  async function audition(clipId: string): Promise<void> {
525
528
  const clip = data.manifest.audio.clips.find(item => item.id === clipId); if (!clip) return;
@@ -646,11 +649,16 @@ function seekReading(clip: string, frame: number, exact: number | null, label: s
646
649
  function tick(now: number): void {
647
650
  if (playing) {
648
651
  const dt = lastFrame ? Math.min((now - lastFrame) / 1000, .1) : 0;
649
- const previous = time; time = Math.min(duration, time + dt);
650
- if (player && player.current) { try { stepEnvironment(dt); drawRig(()=>player!.frame(dt)); } catch (error) { pause(); message(errorText(error), true); } }
652
+ // #346: fixed PLAYBACK_STEP steps from wall-clock time; a repeating clip wraps here with no seek, so physics carries across the loop.
653
+ const previous = time, next = advancePlayback({ time, duration, carry: playbackCarry, elapsed: dt, repeat: canRepeatIdle() && !idleHeld });
654
+ playbackCarry = next.carry; time = next.time;
655
+ const stepped = next.steps.reduce((sum, step) => sum + step, 0);
656
+ // The wrap does what the replaced seek(0) did besides the player: restart the wind clock and re-hold the reference at the wrapped time.
657
+ if (next.wrapped) { stopAudio(); clipMoved({ kind: 'replay' }); if (video) { if (video.readyState >= 1) holdVideoReference(video, referenceGeneration); void video.play().catch(error => { pause(); message(errorText(error), true); }); } }
658
+ if (player && player.current && next.steps.length) { try { stepEnvironment(stepped); drawRig(()=>{ for (const step of next.steps) player!.advance(step); player!.draw(); }); } catch (error) { pause(); message(errorText(error), true); } }
651
659
  if (video && video.readyState >= 1 && time > video.duration) { if (referenceInput.state !== 'out-of-domain') holdVideoReference(video, referenceGeneration); } else if (video && referenceInput.state === 'loaded' && Math.abs(video.currentTime - time) > .15) video.currentTime = time;
652
- if (input('sync-audio').checked) for (const cue of activeCues()) if ((previous < cue.time && cue.time <= time) || (previous === 0 && cue.time === 0 && dt > 0)) void audition(cue.clip);
653
- renderSequenceFrame(); renderTransport(); if(time>=duration){if(canRepeatIdle()&&!idleHeld){stopAudio();seek(0,{kind:'replay'});player?.resume();if(video)void video.play().catch(error=>{pause();message(errorText(error),true);});}else pause();} lastFrame = now;
660
+ if (input('sync-audio').checked) for (const cue of activeCues()) if (cueDue(cue.time, previous, next, duration)) void audition(cue.clip);
661
+ renderSequenceFrame(); renderTransport(); if (next.ended) pause(); lastFrame = now;
654
662
  }
655
663
  requestAnimationFrame(tick);
656
664
  }
@@ -700,7 +708,7 @@ async function initPlayer(initialCheckpoint?:Checkpoint): Promise<void> {
700
708
  function chooseAxis(): void {
701
709
  const axis = data.manifest.axes.find(item => item.id === select('axis-select').value);
702
710
  const clip = assets?.animations.find(item => item.name === axis?.animation); if (!axis || !clip || !player) return;
703
- pause(); chooseAnimation(clip.name); axisInspection = true; el('angle-panel').hidden = false;
711
+ pause(); chooseAnimation(clip.name); axisInspection = true; syncPlayerLoop(); el('angle-panel').hidden = false;
704
712
  input('axis-value').min = String(axis.min); input('axis-value').max = String(axis.max); input('axis-value').step = String((axis.max - axis.min) / 200); input('axis-value').value = String((axis.max + axis.min) / 2); text('axis-label', axis.label); applyAxis();
705
713
  }
706
714
 
@@ -963,7 +971,7 @@ function bind(): void {
963
971
  for(const target of ['rig','reference'] as const)viewDisposers.push(bindPan(el(target+'-viewport'),(dx,dy)=>cameraAction(()=>panCamera(target,dx,dy)),()=>!comments?.active(),target==='rig'?carryRig:undefined));
964
972
  for(const [id,key] of [['layer-images','images'],['layer-mesh','mesh'],['layer-bones','bones']] as const)input(id).onchange=()=>{layers[key]=input(id).checked;redrawOverlay(false);};
965
973
  viewDisposers.push(bindLayerShortcuts(document));describeLayerToggles(document,el('layer-state').textContent??'');
966
- input('idle-repeat').onchange=()=>{renderIdle();if(canRepeatIdle())void playPreview();};
974
+ input('idle-repeat').onchange=()=>{syncPlayerLoop();renderIdle();if(canRepeatIdle())void playPreview();};
967
975
  bindEnvironment();
968
976
  for(const id of ['proposal-panel','checkpoint-detail'])el(id).addEventListener('focusin',pause);
969
977
  bindInspector();bindReviewDialog();
@@ -1029,11 +1037,21 @@ function redrawOverlay(fresh:boolean):void {
1029
1037
  lastOverlay=value;
1030
1038
  text('layer-state',value.warnings.join(' · ')||'Actual last-drawn mesh edges / bone points');idlePanel?.place(duration);rigFieldsPanel?.place();if(!fresh&&value.needsCapture&&!playing&&!seekingControl)drawRig(()=>player!.draw());
1031
1039
  }
1040
+ /**
1041
+ * #346: the player loops exactly when Animate repeats, so a repeating clip wraps inside the track and its physics
1042
+ * carries across the seam. Changing the mode reopens the track at the current time, as a seek does.
1043
+ */
1044
+ function syncPlayerLoop():void {
1045
+ const want=canRepeatIdle();
1046
+ if(!player?.current||player.composed||player.entry(0)?.loop===want)return;
1047
+ try{drawRig(()=>{player!.play(animation,{loop:want});if(!playing)player!.pause();player!.seek(time);player!.draw();});}
1048
+ catch(error){message(errorText(error),true);}
1049
+ }
1032
1050
  function canRepeatIdle():boolean{return !!player&&idleAvailable(assets?.animations.map(a=>a.name)??[],animation)&&!axisInspection&&input('idle-repeat').checked&&duration>0;}
1033
1051
  function renderIdle():void {text('idle-state',canRepeatIdle()?'Actual idle · repeat enabled':animation==='idle'?'Idle repeat paused':'Non-idle inspection · no automatic playback');}
1034
1052
  async function playPreview():Promise<void> {
1035
1053
  if((!player&&!video&&!sequence)||duration<=0)return;
1036
- const intent=++playbackIntent;desiredPlay=true;idleHeld=false;if(time>=duration)seek(0,{kind:'replay'});
1054
+ const intent=++playbackIntent;desiredPlay=true;idleHeld=false;syncPlayerLoop();if(time>=duration)seek(0,{kind:'replay'});
1037
1055
  if(video&&referenceInput.state==='loaded'){try{await video.play();}catch(error){pause();message(`Playback is paused: ${errorText(error)}. Use Play to retry.`,true);return;}}
1038
1056
  if(intent!==playbackIntent||!desiredPlay){if(!desiredPlay)video?.pause();return;}playing=true;lastFrame=0;player?.resume();button('play').textContent='Ⅱ';button('play').setAttribute('aria-label','Pause');
1039
1057
  }
@@ -1242,7 +1260,7 @@ async function exportChest():Promise<void> {
1242
1260
  const environmentInputs=['wind-base','wind-breeze','wind-gust','wind-repeat','wind-gust-peak','wind-gust-duration','gravity','jolt','physics-reset','environment-use','environment-export','environment-check'];
1243
1261
  function environmentApplied():boolean{return input('environment-applied').checked;}
1244
1262
  function gravityValue():number{return Number(input('gravity').value);}
1245
- /** Called from `tick` right before `player.frame(dt)`: the gust clock is the stepped time, so a paused player freezes it. */
1263
+ /** Called from `tick` right before the fixed playback steps (#346): the gust clock is the stepped time, so a paused player freezes it. */
1246
1264
  function stepEnvironment(dt:number):void {
1247
1265
  if(!player)return;
1248
1266
  wind.advance(dt);
@@ -0,0 +1,57 @@
1
+ /**
2
+ * #346: Animate's playback clock. Wall-clock time is accumulated and the clip and its physics advance in fixed
3
+ * `PLAYBACK_STEP` steps, so the integrated physics does not depend on the display's refresh rate. A repeating clip
4
+ * wraps its own time here; the player is opened with `loop: true` and is never re-seeked at the wrap, so physics
5
+ * state carries across the loop seam. Only an explicit reset or a seek restarts physics.
6
+ */
7
+ export const PLAYBACK_STEP = 1 / 60;
8
+ /** A step this close to whole counts as whole, so float residue in the accumulator never drops a step. */
9
+ const STEP_SLACK = 1e-9;
10
+
11
+ export interface PlaybackInput {
12
+ /** The clip time before this frame, in seconds. */
13
+ time: number;
14
+ duration: number;
15
+ /** Wall-clock seconds accumulated but not yet stepped, carried from the previous frame. */
16
+ carry: number;
17
+ /** Wall-clock seconds since the previous frame. */
18
+ elapsed: number;
19
+ repeat: boolean;
20
+ step?: number;
21
+ }
22
+ export interface PlaybackAdvance {
23
+ /** The player steps to take, in order. Each is `step`, except a shorter last step that lands exactly on a non-repeating clip's end. */
24
+ steps: number[];
25
+ time: number;
26
+ carry: number;
27
+ /** The clip wrapped at least once this frame (repeating clips only). */
28
+ wrapped: boolean;
29
+ /** A non-repeating clip reached its end this frame. */
30
+ ended: boolean;
31
+ }
32
+
33
+ export function advancePlayback(input: PlaybackInput): PlaybackAdvance {
34
+ const step = input.step ?? PLAYBACK_STEP, duration = input.duration, steps: number[] = [];
35
+ let time = input.time, carry = input.carry + Math.max(0, input.elapsed), wrapped = false, ended = false;
36
+ if (!(duration > 0)) return { steps, time, carry: 0, wrapped, ended };
37
+ while (carry >= step - STEP_SLACK) {
38
+ if (!input.repeat && time + step >= duration) {
39
+ const last = duration - time;
40
+ if (last > 0) steps.push(last);
41
+ time = duration; carry = 0; ended = true;
42
+ break;
43
+ }
44
+ steps.push(step); carry = Math.max(0, carry - step); time += step;
45
+ if (input.repeat) while (time >= duration) { time -= duration; wrapped = true; }
46
+ }
47
+ return { steps, time, carry, wrapped, ended };
48
+ }
49
+
50
+ /**
51
+ * Whether an audio cue at `at` seconds falls in the interval this frame played. On a wrap that is
52
+ * (previous, duration] and then [0, time], so a cue just before the clip's end still sounds.
53
+ */
54
+ export function cueDue(at: number, previous: number, next: PlaybackAdvance, duration: number): boolean {
55
+ if (next.wrapped) return (previous < at && at <= duration) || at <= next.time;
56
+ return (previous < at && at <= next.time) || (previous === 0 && at === 0 && next.steps.length > 0);
57
+ }