@rig-c/review 1.4.3 → 1.5.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.
@@ -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
+ }
package/web/styles.css CHANGED
@@ -37,7 +37,7 @@
37
37
  input::placeholder,textarea::placeholder{color:var(--fg-muted)}
38
38
 
39
39
  :focus-visible{outline-color:var(--rv-focus)}
40
- .chest-regions{margin-top:22px;padding-top:15px;border-top:1px solid var(--border)}.chest-regions code{font:11px var(--font-mono)}.chest-grid,.chest-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 10px}.chest-row{border:1px solid var(--border);border-radius:6px;padding:9px 10px;margin:10px 0 0;min-width:0}.chest-row legend{font-size:11px;color:var(--fg-muted);padding:0 4px}.chest-grid label,.chest-row label{display:flex;flex-direction:column;gap:4px;font-size:11px;color:var(--fg-muted);min-width:0}.chest-row input,.chest-row select,.chest-grid input{width:100%;padding:5px 6px;font-size:11px}.chest-row .chest-check{flex-direction:row;align-items:center;gap:6px}.chest-row .chest-check input{width:auto}.chest-more{margin-top:10px;font-size:11px;color:var(--fg-muted)}.chest-more summary{cursor:pointer}#chest-status.error{color:var(--fail)}
40
+ .chest-regions{margin-top:22px;padding-top:15px;border-top:1px solid var(--border)}.chest-regions code{font:11px var(--font-mono)}.chest-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;margin-top:10px}.chest-markers{display:inline-flex;align-items:center;gap:6px;padding:4px 9px;font-size:11px}.chest-markers-state{font:600 10px/1 var(--font-mono);padding:2px 5px;border-radius:3px;border:1px solid var(--border);color:var(--fg-muted)}.chest-markers[aria-pressed=true] .chest-markers-off,.chest-markers:not([aria-pressed=true]) .chest-markers-on{display:none}.chest-markers[aria-pressed=true] .chest-markers-on{color:inherit;border-color:currentColor}.chest-crop{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--fg-muted)}.chest-crop input{width:64px;padding:4px 6px;font-size:11px}.chest-label{font-weight:600}.chest-unavailable{white-space:pre-line}.chest-table-wrap{overflow-x:auto;margin-top:8px}.chest-table{width:100%;border-collapse:collapse;font-size:11px;table-layout:fixed;min-width:640px}.chest-table th{font-weight:500;color:var(--fg-muted);text-align:left;padding:0 4px 4px;line-height:1.25;vertical-align:bottom}.chest-table td{padding:2px 4px}.chest-table td:first-child{width:72px}.chest-table th[scope=row]{width:72px;padding:2px 4px;vertical-align:middle;white-space:nowrap;color:var(--fg)}.chest-table input,.chest-table select{width:100%;min-width:0;padding:4px 5px;font-size:11px;font-variant-numeric:tabular-nums}.chest-table .chest-cell-name,.chest-table .chest-cell-bone{width:15%}.chest-side::before{content:"";display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:6px;vertical-align:middle;background:var(--rv-bust-r)}.chest-side-l::before{background:var(--rv-bust-l)}.chest-row{border:1px solid var(--border);border-radius:6px;padding:8px 10px;margin:10px 0 0;min-width:0;display:grid;grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:6px 10px;align-items:end}.chest-row legend{font-size:11px;color:var(--fg-muted);padding:0 4px}.chest-row label{display:flex;flex-direction:column;gap:3px;font-size:11px;color:var(--fg-muted);min-width:0}.chest-row input{width:100%;padding:4px 5px;font-size:11px}.chest-row .chest-check{flex-direction:row;align-items:center;gap:6px;padding-bottom:5px}.chest-row .chest-check input{width:auto}.chest-more{margin-top:10px;font-size:11px;color:var(--fg-muted)}.chest-more summary{cursor:pointer}.chest-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 12px;margin-top:10px}.chest-foot #chest-status{flex:1 1 240px;margin:0}.chest-foot #chest-export{flex:none;padding:5px 10px;font-size:11px}#chest-status.error{color:var(--fail)}
41
41
  /* Source pixels retain their original color; the neutral stage stays dark in both themes. */
42
42
 
43
43
  /* The application shell never scrolls; each Inspector tab and the source list owns overflow. */