Skip to content

Commit d095760

Browse files
committed
refactor(shader-transitions): extract DEFAULT_DURATION and DEFAULT_EASE constants
The three fallback sites in hyper-shader.ts (metadata write, browser/render mode, and engine mode) had drifted apart: the metadata path used 1s/'none' while the actual rendering used 0.7s/'power2.inOut'. This meant a transition without an explicit duration/ease would render at 0.7s but tell the engine it was 1s, throwing off the producer's compositing window planning. Extract DEFAULT_DURATION (0.7) and DEFAULT_EASE ('power2.inOut') as module-level constants and use them at all three sites so a missing duration/ease produces identical behavior in preview, the engine's deterministic seek path, and the metadata the producer reads. The explicit `ease: 'none'` on the timeline-length anchor tweens elsewhere in the file is intentional (those are linear interpolators driving the shader's progress uniform) and is left unchanged.
1 parent ce815c2 commit d095760

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

packages/shader-transitions/src/hyper-shader.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ interface TransState {
6161
progress: number;
6262
}
6363

64+
// Defaults for transition duration/ease. Used by every fallback site in this
65+
// file — meta-write, browser/render mode, and engine mode — so a transition
66+
// without explicit `duration`/`ease` plays the same length and curve in
67+
// preview, the engine's deterministic seek path, and the metadata the
68+
// producer reads to plan compositing.
69+
const DEFAULT_DURATION = 0.7;
70+
const DEFAULT_EASE = "power2.inOut";
71+
6472
function parseHex(hex: string): [number, number, number] {
6573
const h = hex.replace("#", "");
6674
if (h.length < 6) return [0.5, 0.5, 0.5];
@@ -130,9 +138,9 @@ export function init(config: HyperShaderConfig): GsapTimeline {
130138
if (hfWin.__hf) {
131139
hfWin.__hf.transitions = transitions.map((t: TransitionConfig, i: number) => ({
132140
time: t.time,
133-
duration: t.duration ?? 1,
141+
duration: t.duration ?? DEFAULT_DURATION,
134142
shader: t.shader,
135-
ease: t.ease ?? "none",
143+
ease: t.ease ?? DEFAULT_EASE,
136144
fromScene: scenes[i] ?? "",
137145
toScene: scenes[i + 1] ?? "",
138146
}));
@@ -238,8 +246,8 @@ export function init(config: HyperShaderConfig): GsapTimeline {
238246
const prog = programs.get(t.shader);
239247
if (!prog) continue;
240248

241-
const dur = t.duration ?? 0.7;
242-
const ease = t.ease ?? "power2.inOut";
249+
const dur = t.duration ?? DEFAULT_DURATION;
250+
const ease = t.ease ?? DEFAULT_EASE;
243251
const T = t.time;
244252

245253
// Pause timeline during async capture to prevent the progress tween
@@ -361,7 +369,7 @@ function initEngineMode(
361369
const toId = scenes[i + 1];
362370
if (!fromId || !toId) continue;
363371

364-
const dur = t.duration ?? 0.7;
372+
const dur = t.duration ?? DEFAULT_DURATION;
365373
const T = t.time;
366374

367375
// During the transition both scenes need to be visible so the engine

0 commit comments

Comments
 (0)