@remotion/transitions 4.0.465 → 4.0.467
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/book-flip.js +2 -0
- package/cross-zoom.js +2 -0
- package/crosswarp.js +2 -0
- package/dist/TransitionSeries.js +16 -6
- package/dist/esm/book-flip.mjs +434 -0
- package/dist/esm/cross-zoom.mjs +377 -0
- package/dist/esm/crosswarp.mjs +331 -0
- package/dist/esm/dissolve.mjs +4 -3
- package/dist/esm/dreamy-zoom.mjs +348 -0
- package/dist/esm/film-burn.mjs +443 -0
- package/dist/esm/index.mjs +1020 -209
- package/dist/esm/linear-blur.mjs +343 -0
- package/dist/esm/ripple.mjs +342 -0
- package/dist/esm/swap.mjs +394 -0
- package/dist/esm/zoom-blur.mjs +4 -3
- package/dist/esm/zoom-in-out.mjs +4 -3
- package/dist/html-in-canvas-presentation.js +4 -5
- package/dist/index.d.ts +13 -3
- package/dist/index.js +9 -1
- package/dist/presentations/book-flip.d.ts +14 -0
- package/dist/presentations/book-flip.js +255 -0
- package/dist/presentations/cross-zoom.d.ts +13 -0
- package/dist/presentations/cross-zoom.js +199 -0
- package/dist/presentations/crosswarp.d.ts +11 -0
- package/dist/presentations/crosswarp.js +154 -0
- package/dist/presentations/dreamy-zoom.d.ts +14 -0
- package/dist/presentations/dreamy-zoom.js +169 -0
- package/dist/presentations/film-burn.d.ts +13 -0
- package/dist/presentations/film-burn.js +265 -0
- package/dist/presentations/linear-blur.d.ts +13 -0
- package/dist/presentations/linear-blur.js +164 -0
- package/dist/presentations/ripple.d.ts +14 -0
- package/dist/presentations/ripple.js +164 -0
- package/dist/presentations/swap.d.ts +15 -0
- package/dist/presentations/swap.js +212 -0
- package/dist/types.d.ts +1 -1
- package/dreamy-zoom.js +2 -0
- package/film-burn.js +2 -0
- package/linear-blur.js +2 -0
- package/package.json +80 -8
- package/ripple.js +2 -0
- package/swap.js +2 -0
package/dist/esm/index.mjs
CHANGED
|
@@ -76,6 +76,980 @@ var slide = (props) => {
|
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
// src/html-in-canvas-presentation.tsx
|
|
80
|
+
import { useCallback, useLayoutEffect, useMemo as useMemo2, useRef, useState } from "react";
|
|
81
|
+
import {
|
|
82
|
+
AbsoluteFill as AbsoluteFill2,
|
|
83
|
+
HTML_IN_CANVAS_UNSUPPORTED_MESSAGE,
|
|
84
|
+
HtmlInCanvas,
|
|
85
|
+
Internals,
|
|
86
|
+
useDelayRender
|
|
87
|
+
} from "remotion";
|
|
88
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
89
|
+
var HtmlInCanvasPresentation = ({
|
|
90
|
+
children,
|
|
91
|
+
onElementImage,
|
|
92
|
+
onUnmount,
|
|
93
|
+
presentationProgress,
|
|
94
|
+
presentationDirection,
|
|
95
|
+
shader,
|
|
96
|
+
effects,
|
|
97
|
+
passedProps,
|
|
98
|
+
bothEnteringAndExiting
|
|
99
|
+
}) => {
|
|
100
|
+
if (!HtmlInCanvas.isSupported()) {
|
|
101
|
+
throw new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
|
|
102
|
+
}
|
|
103
|
+
const canvasRef = useRef(null);
|
|
104
|
+
const canvasSubtreeStyle = useMemo2(() => {
|
|
105
|
+
return {
|
|
106
|
+
width: "100%",
|
|
107
|
+
height: "100%",
|
|
108
|
+
position: "absolute",
|
|
109
|
+
top: 0,
|
|
110
|
+
left: 0,
|
|
111
|
+
right: 0,
|
|
112
|
+
bottom: 0
|
|
113
|
+
};
|
|
114
|
+
}, []);
|
|
115
|
+
const [offscreenCanvas] = useState(() => new OffscreenCanvas(1, 1));
|
|
116
|
+
const passedPropsRef = useRef(passedProps);
|
|
117
|
+
passedPropsRef.current = passedProps;
|
|
118
|
+
const memoizedEffects = Internals.useMemoizedEffects({
|
|
119
|
+
effects: effects ?? [],
|
|
120
|
+
overrideId: null
|
|
121
|
+
});
|
|
122
|
+
const effectsRef = useRef(memoizedEffects);
|
|
123
|
+
effectsRef.current = memoizedEffects;
|
|
124
|
+
const [instance] = useState(() => shader(offscreenCanvas));
|
|
125
|
+
useLayoutEffect(() => {
|
|
126
|
+
return () => {
|
|
127
|
+
instance.cleanup();
|
|
128
|
+
};
|
|
129
|
+
}, [offscreenCanvas, instance]);
|
|
130
|
+
const chainState = Internals.useEffectChainState();
|
|
131
|
+
const { delayRender, continueRender } = useDelayRender();
|
|
132
|
+
const draw = useCallback(async (prevImage, nextImage, progress) => {
|
|
133
|
+
if (!canvasRef.current) {
|
|
134
|
+
throw new Error("Canvas not found");
|
|
135
|
+
}
|
|
136
|
+
const handle = delayRender("onPaint");
|
|
137
|
+
if (!prevImage && !nextImage) {
|
|
138
|
+
continueRender(handle);
|
|
139
|
+
instance.clear();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const width = prevImage?.width ?? nextImage?.width ?? 0;
|
|
143
|
+
const height = prevImage?.height ?? nextImage?.height ?? 0;
|
|
144
|
+
if (width === 0 || height === 0) {
|
|
145
|
+
continueRender(handle);
|
|
146
|
+
instance.clear();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
offscreenCanvas.width = width;
|
|
150
|
+
offscreenCanvas.height = height;
|
|
151
|
+
instance.draw({
|
|
152
|
+
prevImage,
|
|
153
|
+
nextImage,
|
|
154
|
+
width,
|
|
155
|
+
height,
|
|
156
|
+
time: progress,
|
|
157
|
+
passedProps: passedPropsRef.current
|
|
158
|
+
});
|
|
159
|
+
await Internals.runEffectChain({
|
|
160
|
+
state: chainState.get(width, height),
|
|
161
|
+
source: offscreenCanvas,
|
|
162
|
+
effects: effectsRef.current ?? [],
|
|
163
|
+
width,
|
|
164
|
+
height,
|
|
165
|
+
output: canvasRef.current
|
|
166
|
+
});
|
|
167
|
+
continueRender(handle);
|
|
168
|
+
}, [chainState, instance, offscreenCanvas, continueRender, delayRender]);
|
|
169
|
+
const passThrough = bothEnteringAndExiting && presentationDirection === "exiting";
|
|
170
|
+
useLayoutEffect(() => {
|
|
171
|
+
if (passThrough) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const canvas = canvasRef.current;
|
|
175
|
+
if (!canvas) {
|
|
176
|
+
throw new Error("Canvas not found");
|
|
177
|
+
}
|
|
178
|
+
canvas.layoutSubtree = true;
|
|
179
|
+
const onPaint = () => {
|
|
180
|
+
const firstChild = canvas.firstChild;
|
|
181
|
+
if (!firstChild) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const elementImage = canvas.captureElementImage(firstChild);
|
|
185
|
+
onElementImage(elementImage, draw);
|
|
186
|
+
};
|
|
187
|
+
canvas.addEventListener("paint", onPaint);
|
|
188
|
+
return () => {
|
|
189
|
+
canvas.removeEventListener("paint", onPaint);
|
|
190
|
+
};
|
|
191
|
+
}, [onElementImage, presentationDirection, draw, passThrough]);
|
|
192
|
+
useLayoutEffect(() => {
|
|
193
|
+
if (passThrough) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const canvas = canvasRef.current;
|
|
197
|
+
if (!canvas) {
|
|
198
|
+
throw new Error("Canvas not found");
|
|
199
|
+
}
|
|
200
|
+
canvas.requestPaint?.();
|
|
201
|
+
}, [presentationProgress, passThrough, memoizedEffects]);
|
|
202
|
+
useLayoutEffect(() => {
|
|
203
|
+
if (passThrough) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
return () => {
|
|
207
|
+
onUnmount();
|
|
208
|
+
};
|
|
209
|
+
}, [onUnmount, passThrough]);
|
|
210
|
+
useLayoutEffect(() => {
|
|
211
|
+
if (passThrough) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const canvas = canvasRef.current;
|
|
215
|
+
if (!canvas) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
219
|
+
canvas.width = entry.devicePixelContentBoxSize[0].inlineSize;
|
|
220
|
+
canvas.height = entry.devicePixelContentBoxSize[0].blockSize;
|
|
221
|
+
});
|
|
222
|
+
observer.observe(canvas, { box: "device-pixel-content-box" });
|
|
223
|
+
}, [passThrough]);
|
|
224
|
+
if (passThrough) {
|
|
225
|
+
return children;
|
|
226
|
+
}
|
|
227
|
+
return /* @__PURE__ */ jsx2(AbsoluteFill2, {
|
|
228
|
+
children: /* @__PURE__ */ jsx2("canvas", {
|
|
229
|
+
ref: canvasRef,
|
|
230
|
+
style: canvasSubtreeStyle,
|
|
231
|
+
children
|
|
232
|
+
})
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
var makeHtmlInCanvasPresentation = (shader) => {
|
|
236
|
+
const CompWithShader = (props) => {
|
|
237
|
+
const { passedProps, ...otherProps } = props;
|
|
238
|
+
const { effects, ...restPassedProps } = props.passedProps;
|
|
239
|
+
return /* @__PURE__ */ jsx2(HtmlInCanvasPresentation, {
|
|
240
|
+
shader,
|
|
241
|
+
passedProps: restPassedProps,
|
|
242
|
+
effects,
|
|
243
|
+
...otherProps
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
return (props) => {
|
|
247
|
+
return {
|
|
248
|
+
component: CompWithShader,
|
|
249
|
+
props
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// src/presentations/cross-zoom.tsx
|
|
255
|
+
var DEFAULT_STRENGTH = 0.4;
|
|
256
|
+
var VERTEX_SHADER = `#version 300 es
|
|
257
|
+
in vec2 a_pos;
|
|
258
|
+
out vec2 v_uv;
|
|
259
|
+
void main() {
|
|
260
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
261
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
262
|
+
}`;
|
|
263
|
+
var FRAGMENT_SHADER = `#version 300 es
|
|
264
|
+
precision highp float;
|
|
265
|
+
|
|
266
|
+
uniform sampler2D u_prev;
|
|
267
|
+
uniform sampler2D u_next;
|
|
268
|
+
uniform float u_time;
|
|
269
|
+
uniform float u_strength;
|
|
270
|
+
|
|
271
|
+
in vec2 v_uv;
|
|
272
|
+
out vec4 outColor;
|
|
273
|
+
|
|
274
|
+
const float PI = 3.141592653589793;
|
|
275
|
+
|
|
276
|
+
float linearEase(float begin, float change, float duration, float time) {
|
|
277
|
+
return change * time / duration + begin;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
float exponentialEaseInOut(float begin, float change, float duration, float time) {
|
|
281
|
+
if (time == 0.0) {
|
|
282
|
+
return begin;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (time == duration) {
|
|
286
|
+
return begin + change;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
float t = time / (duration / 2.0);
|
|
290
|
+
if (t < 1.0) {
|
|
291
|
+
return change / 2.0 * pow(2.0, 10.0 * (t - 1.0)) + begin;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return change / 2.0 * (-pow(2.0, -10.0 * (t - 1.0)) + 2.0) + begin;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
float sinusoidalEaseInOut(float begin, float change, float duration, float time) {
|
|
298
|
+
return -change / 2.0 * (cos(PI * time / duration) - 1.0) + begin;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
float random(vec2 co) {
|
|
302
|
+
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
vec4 crossFade(vec2 uv, float dissolve) {
|
|
306
|
+
return mix(texture(u_prev, uv), texture(u_next, uv), dissolve);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
vec4 transition(vec2 uv, float progress) {
|
|
310
|
+
vec2 center = vec2(linearEase(0.25, 0.5, 1.0, progress), 0.5);
|
|
311
|
+
float dissolve = exponentialEaseInOut(0.0, 1.0, 1.0, progress);
|
|
312
|
+
float strength = sinusoidalEaseInOut(0.0, u_strength, 0.5, progress);
|
|
313
|
+
|
|
314
|
+
vec4 color = vec4(0.0);
|
|
315
|
+
float total = 0.0;
|
|
316
|
+
vec2 toCenter = center - uv;
|
|
317
|
+
float offset = random(uv);
|
|
318
|
+
|
|
319
|
+
for (int i = 0; i <= 40; i++) {
|
|
320
|
+
float percent = (float(i) + offset) / 40.0;
|
|
321
|
+
float weight = 4.0 * (percent - percent * percent);
|
|
322
|
+
color += crossFade(uv + toCenter * percent * strength, dissolve) * weight;
|
|
323
|
+
total += weight;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return color / total;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
void main() {
|
|
330
|
+
float progress = 1.0 - u_time;
|
|
331
|
+
outColor = transition(v_uv, progress);
|
|
332
|
+
}`;
|
|
333
|
+
var compileShader = (gl, source, type) => {
|
|
334
|
+
const shader = gl.createShader(type);
|
|
335
|
+
if (!shader) {
|
|
336
|
+
throw new Error("Failed to create shader");
|
|
337
|
+
}
|
|
338
|
+
gl.shaderSource(shader, source);
|
|
339
|
+
gl.compileShader(shader);
|
|
340
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
341
|
+
const log = gl.getShaderInfoLog(shader);
|
|
342
|
+
gl.deleteShader(shader);
|
|
343
|
+
throw new Error(`Failed to compile shader: ${log}`);
|
|
344
|
+
}
|
|
345
|
+
return shader;
|
|
346
|
+
};
|
|
347
|
+
var createProgram = (gl) => {
|
|
348
|
+
const program = gl.createProgram();
|
|
349
|
+
if (!program) {
|
|
350
|
+
throw new Error("Failed to create WebGL program");
|
|
351
|
+
}
|
|
352
|
+
const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);
|
|
353
|
+
const fs = compileShader(gl, FRAGMENT_SHADER, gl.FRAGMENT_SHADER);
|
|
354
|
+
gl.attachShader(program, vs);
|
|
355
|
+
gl.attachShader(program, fs);
|
|
356
|
+
gl.linkProgram(program);
|
|
357
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
358
|
+
const log = gl.getProgramInfoLog(program);
|
|
359
|
+
gl.deleteProgram(program);
|
|
360
|
+
throw new Error(`Failed to link program: ${log}`);
|
|
361
|
+
}
|
|
362
|
+
return program;
|
|
363
|
+
};
|
|
364
|
+
var createTexture = (gl) => {
|
|
365
|
+
const tex = gl.createTexture();
|
|
366
|
+
if (!tex) {
|
|
367
|
+
throw new Error("Failed to create texture");
|
|
368
|
+
}
|
|
369
|
+
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
370
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
371
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
372
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
373
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
374
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
|
|
375
|
+
return tex;
|
|
376
|
+
};
|
|
377
|
+
var crossZoomShader = (canvas) => {
|
|
378
|
+
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
|
|
379
|
+
if (!gl) {
|
|
380
|
+
throw new Error("Failed to create WebGL2 context");
|
|
381
|
+
}
|
|
382
|
+
const program = createProgram(gl);
|
|
383
|
+
const prevTex = createTexture(gl);
|
|
384
|
+
const nextTex = createTexture(gl);
|
|
385
|
+
const vao = gl.createVertexArray();
|
|
386
|
+
gl.bindVertexArray(vao);
|
|
387
|
+
const buffer = gl.createBuffer();
|
|
388
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
389
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
|
390
|
+
const aPos = gl.getAttribLocation(program, "a_pos");
|
|
391
|
+
gl.enableVertexAttribArray(aPos);
|
|
392
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
|
|
393
|
+
const uTime = gl.getUniformLocation(program, "u_time");
|
|
394
|
+
const uPrev = gl.getUniformLocation(program, "u_prev");
|
|
395
|
+
const uNext = gl.getUniformLocation(program, "u_next");
|
|
396
|
+
const uStrength = gl.getUniformLocation(program, "u_strength");
|
|
397
|
+
const cleanup = () => {
|
|
398
|
+
gl.deleteProgram(program);
|
|
399
|
+
gl.deleteTexture(prevTex);
|
|
400
|
+
gl.deleteTexture(nextTex);
|
|
401
|
+
};
|
|
402
|
+
const clear = () => {
|
|
403
|
+
gl.clearColor(0, 0, 0, 0);
|
|
404
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
405
|
+
};
|
|
406
|
+
const draw = ({
|
|
407
|
+
prevImage,
|
|
408
|
+
nextImage,
|
|
409
|
+
width,
|
|
410
|
+
height,
|
|
411
|
+
time,
|
|
412
|
+
passedProps
|
|
413
|
+
}) => {
|
|
414
|
+
const { strength = DEFAULT_STRENGTH } = passedProps;
|
|
415
|
+
if (!prevImage && !nextImage) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
|
|
425
|
+
gl.viewport(0, 0, width, height);
|
|
426
|
+
gl.clearColor(0, 0, 0, 0);
|
|
427
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
428
|
+
gl.useProgram(program);
|
|
429
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
430
|
+
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
431
|
+
if (prevImage) {
|
|
432
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
|
|
433
|
+
}
|
|
434
|
+
gl.uniform1i(uPrev, 0);
|
|
435
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
436
|
+
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
437
|
+
if (nextImage) {
|
|
438
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
|
|
439
|
+
}
|
|
440
|
+
gl.uniform1i(uNext, 1);
|
|
441
|
+
gl.uniform1f(uTime, effectiveTime);
|
|
442
|
+
gl.uniform1f(uStrength, strength);
|
|
443
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
444
|
+
};
|
|
445
|
+
return {
|
|
446
|
+
clear,
|
|
447
|
+
cleanup,
|
|
448
|
+
draw
|
|
449
|
+
};
|
|
450
|
+
};
|
|
451
|
+
var crossZoom = makeHtmlInCanvasPresentation(crossZoomShader);
|
|
452
|
+
|
|
453
|
+
// src/presentations/dreamy-zoom.tsx
|
|
454
|
+
var DEFAULT_ROTATION = 6;
|
|
455
|
+
var DEFAULT_SCALE = 1.2;
|
|
456
|
+
var VERTEX_SHADER2 = `#version 300 es
|
|
457
|
+
in vec2 a_pos;
|
|
458
|
+
out vec2 v_uv;
|
|
459
|
+
void main() {
|
|
460
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
461
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
462
|
+
}`;
|
|
463
|
+
var FRAGMENT_SHADER2 = `#version 300 es
|
|
464
|
+
precision highp float;
|
|
465
|
+
|
|
466
|
+
uniform sampler2D u_prev;
|
|
467
|
+
uniform sampler2D u_next;
|
|
468
|
+
uniform float u_time;
|
|
469
|
+
uniform float u_rotation;
|
|
470
|
+
uniform float u_scale;
|
|
471
|
+
uniform float u_ratio;
|
|
472
|
+
|
|
473
|
+
in vec2 v_uv;
|
|
474
|
+
out vec4 outColor;
|
|
475
|
+
|
|
476
|
+
const float DEG2RAD = 0.03926990816987241548078304229099;
|
|
477
|
+
|
|
478
|
+
vec4 transition(vec2 uv, float progress) {
|
|
479
|
+
float phase = progress < 0.5 ? progress * 2.0 : (progress - 0.5) * 2.0;
|
|
480
|
+
float angleOffset = progress < 0.5 ? mix(0.0, u_rotation * DEG2RAD, phase) : mix(-u_rotation * DEG2RAD, 0.0, phase);
|
|
481
|
+
float newScale = progress < 0.5 ? mix(1.0, u_scale, phase) : mix(u_scale, 1.0, phase);
|
|
482
|
+
|
|
483
|
+
vec2 center = vec2(0.0, 0.0);
|
|
484
|
+
vec2 p = (uv.xy - vec2(0.5, 0.5)) / newScale * vec2(u_ratio, 1.0);
|
|
485
|
+
float angle = atan(p.y, p.x) + angleOffset;
|
|
486
|
+
float dist = distance(center, p);
|
|
487
|
+
|
|
488
|
+
p.x = cos(angle) * dist / u_ratio + 0.5;
|
|
489
|
+
p.y = sin(angle) * dist + 0.5;
|
|
490
|
+
|
|
491
|
+
vec4 c = progress < 0.5 ? texture(u_prev, p) : texture(u_next, p);
|
|
492
|
+
return c + (progress < 0.5 ? mix(0.0, 1.0, phase) : mix(1.0, 0.0, phase));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
void main() {
|
|
496
|
+
float progress = 1.0 - u_time;
|
|
497
|
+
outColor = transition(v_uv, progress);
|
|
498
|
+
}`;
|
|
499
|
+
var compileShader2 = (gl, source, type) => {
|
|
500
|
+
const shader = gl.createShader(type);
|
|
501
|
+
if (!shader) {
|
|
502
|
+
throw new Error("Failed to create shader");
|
|
503
|
+
}
|
|
504
|
+
gl.shaderSource(shader, source);
|
|
505
|
+
gl.compileShader(shader);
|
|
506
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
507
|
+
const log = gl.getShaderInfoLog(shader);
|
|
508
|
+
gl.deleteShader(shader);
|
|
509
|
+
throw new Error(`Failed to compile shader: ${log}`);
|
|
510
|
+
}
|
|
511
|
+
return shader;
|
|
512
|
+
};
|
|
513
|
+
var createProgram2 = (gl) => {
|
|
514
|
+
const program = gl.createProgram();
|
|
515
|
+
if (!program) {
|
|
516
|
+
throw new Error("Failed to create WebGL program");
|
|
517
|
+
}
|
|
518
|
+
const vs = compileShader2(gl, VERTEX_SHADER2, gl.VERTEX_SHADER);
|
|
519
|
+
const fs = compileShader2(gl, FRAGMENT_SHADER2, gl.FRAGMENT_SHADER);
|
|
520
|
+
gl.attachShader(program, vs);
|
|
521
|
+
gl.attachShader(program, fs);
|
|
522
|
+
gl.linkProgram(program);
|
|
523
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
524
|
+
const log = gl.getProgramInfoLog(program);
|
|
525
|
+
gl.deleteProgram(program);
|
|
526
|
+
throw new Error(`Failed to link program: ${log}`);
|
|
527
|
+
}
|
|
528
|
+
return program;
|
|
529
|
+
};
|
|
530
|
+
var createTexture2 = (gl) => {
|
|
531
|
+
const tex = gl.createTexture();
|
|
532
|
+
if (!tex) {
|
|
533
|
+
throw new Error("Failed to create texture");
|
|
534
|
+
}
|
|
535
|
+
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
536
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
537
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
538
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
539
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
540
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
|
|
541
|
+
return tex;
|
|
542
|
+
};
|
|
543
|
+
var dreamyZoomShader = (canvas) => {
|
|
544
|
+
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
|
|
545
|
+
if (!gl) {
|
|
546
|
+
throw new Error("Failed to create WebGL2 context");
|
|
547
|
+
}
|
|
548
|
+
const program = createProgram2(gl);
|
|
549
|
+
const prevTex = createTexture2(gl);
|
|
550
|
+
const nextTex = createTexture2(gl);
|
|
551
|
+
const vao = gl.createVertexArray();
|
|
552
|
+
gl.bindVertexArray(vao);
|
|
553
|
+
const buffer = gl.createBuffer();
|
|
554
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
555
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
|
556
|
+
const aPos = gl.getAttribLocation(program, "a_pos");
|
|
557
|
+
gl.enableVertexAttribArray(aPos);
|
|
558
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
|
|
559
|
+
const uTime = gl.getUniformLocation(program, "u_time");
|
|
560
|
+
const uPrev = gl.getUniformLocation(program, "u_prev");
|
|
561
|
+
const uNext = gl.getUniformLocation(program, "u_next");
|
|
562
|
+
const uRotation = gl.getUniformLocation(program, "u_rotation");
|
|
563
|
+
const uScale = gl.getUniformLocation(program, "u_scale");
|
|
564
|
+
const uRatio = gl.getUniformLocation(program, "u_ratio");
|
|
565
|
+
const cleanup = () => {
|
|
566
|
+
gl.deleteProgram(program);
|
|
567
|
+
gl.deleteTexture(prevTex);
|
|
568
|
+
gl.deleteTexture(nextTex);
|
|
569
|
+
};
|
|
570
|
+
const clear = () => {
|
|
571
|
+
gl.clearColor(0, 0, 0, 0);
|
|
572
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
573
|
+
};
|
|
574
|
+
const draw = ({
|
|
575
|
+
prevImage,
|
|
576
|
+
nextImage,
|
|
577
|
+
width,
|
|
578
|
+
height,
|
|
579
|
+
time,
|
|
580
|
+
passedProps
|
|
581
|
+
}) => {
|
|
582
|
+
const { rotation = DEFAULT_ROTATION, scale = DEFAULT_SCALE } = passedProps;
|
|
583
|
+
if (!prevImage && !nextImage) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
|
|
593
|
+
gl.viewport(0, 0, width, height);
|
|
594
|
+
gl.clearColor(0, 0, 0, 0);
|
|
595
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
596
|
+
gl.useProgram(program);
|
|
597
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
598
|
+
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
599
|
+
if (prevImage) {
|
|
600
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
|
|
601
|
+
}
|
|
602
|
+
gl.uniform1i(uPrev, 0);
|
|
603
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
604
|
+
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
605
|
+
if (nextImage) {
|
|
606
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
|
|
607
|
+
}
|
|
608
|
+
gl.uniform1i(uNext, 1);
|
|
609
|
+
gl.uniform1f(uTime, effectiveTime);
|
|
610
|
+
gl.uniform1f(uRotation, rotation);
|
|
611
|
+
gl.uniform1f(uScale, scale);
|
|
612
|
+
gl.uniform1f(uRatio, width / height);
|
|
613
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
614
|
+
};
|
|
615
|
+
return {
|
|
616
|
+
clear,
|
|
617
|
+
cleanup,
|
|
618
|
+
draw
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
var dreamyZoom = makeHtmlInCanvasPresentation(dreamyZoomShader);
|
|
622
|
+
|
|
623
|
+
// src/presentations/film-burn.tsx
|
|
624
|
+
var DEFAULT_SEED = 2.31;
|
|
625
|
+
var VERTEX_SHADER3 = `#version 300 es
|
|
626
|
+
in vec2 a_pos;
|
|
627
|
+
out vec2 v_uv;
|
|
628
|
+
void main() {
|
|
629
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
630
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
631
|
+
}`;
|
|
632
|
+
var FRAGMENT_SHADER3 = `#version 300 es
|
|
633
|
+
precision highp float;
|
|
634
|
+
|
|
635
|
+
uniform sampler2D u_prev;
|
|
636
|
+
uniform sampler2D u_next;
|
|
637
|
+
uniform float u_time;
|
|
638
|
+
uniform float u_seed;
|
|
639
|
+
|
|
640
|
+
in vec2 v_uv;
|
|
641
|
+
out vec4 outColor;
|
|
642
|
+
|
|
643
|
+
#define PI 3.14159265358979323
|
|
644
|
+
#define CLAMPS(x) clamp(x, 0.0, 1.0)
|
|
645
|
+
#define REPEATS 50.0
|
|
646
|
+
|
|
647
|
+
float sigmoid(float x, float a) {
|
|
648
|
+
float b = pow(x * 2.0, a) / 2.0;
|
|
649
|
+
if (x > 0.5) {
|
|
650
|
+
b = 1.0 - pow(2.0 - (x * 2.0), a) / 2.0;
|
|
651
|
+
}
|
|
652
|
+
return b;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
float rand(float co) {
|
|
656
|
+
return fract(sin((co * 24.9898) + u_seed) * 43758.5453);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
float rand(vec2 co) {
|
|
660
|
+
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
float apow(float a, float b) {
|
|
664
|
+
return pow(abs(a), b) * sign(b);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
vec3 pow3(vec3 a, vec3 b) {
|
|
668
|
+
return vec3(apow(a.r, b.r), apow(a.g, b.g), apow(a.b, b.b));
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
float smoothMix(float a, float b, float c) {
|
|
672
|
+
return mix(a, b, sigmoid(c, 2.0));
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
float random(vec2 co, float shft) {
|
|
676
|
+
co += 10.0;
|
|
677
|
+
return smoothMix(
|
|
678
|
+
fract(
|
|
679
|
+
sin(
|
|
680
|
+
dot(
|
|
681
|
+
co.xy,
|
|
682
|
+
vec2(12.9898 + (floor(shft) * 0.5), 78.233 + u_seed)
|
|
683
|
+
)
|
|
684
|
+
) * 43758.5453
|
|
685
|
+
),
|
|
686
|
+
fract(
|
|
687
|
+
sin(
|
|
688
|
+
dot(
|
|
689
|
+
co.xy,
|
|
690
|
+
vec2(12.9898 + (floor(shft + 1.0) * 0.5), 78.233 + u_seed)
|
|
691
|
+
)
|
|
692
|
+
) * 43758.5453
|
|
693
|
+
),
|
|
694
|
+
fract(shft)
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
float smoothRandom(vec2 co, float shft) {
|
|
699
|
+
return smoothMix(
|
|
700
|
+
smoothMix(
|
|
701
|
+
random(floor(co), shft),
|
|
702
|
+
random(floor(co + vec2(1.0, 0.0)), shft),
|
|
703
|
+
fract(co.x)
|
|
704
|
+
),
|
|
705
|
+
smoothMix(
|
|
706
|
+
random(floor(co + vec2(0.0, 1.0)), shft),
|
|
707
|
+
random(floor(co + vec2(1.0, 1.0)), shft),
|
|
708
|
+
fract(co.x)
|
|
709
|
+
),
|
|
710
|
+
fract(co.y)
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
vec4 sampleTexture(vec2 p, float progress) {
|
|
715
|
+
return mix(texture(u_prev, p), texture(u_next, p), sigmoid(progress, 10.0));
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
vec4 transition(vec2 p, float progress) {
|
|
719
|
+
vec3 f = vec3(0.0);
|
|
720
|
+
for (float i = 0.0; i < 13.0; i++) {
|
|
721
|
+
f += sin(((p.x * rand(i) * 6.0) + (progress * 8.0)) + rand(i + 1.43)) *
|
|
722
|
+
sin(
|
|
723
|
+
((p.y * rand(i + 4.4) * 6.0) + (progress * 6.0)) +
|
|
724
|
+
rand(i + 2.4)
|
|
725
|
+
);
|
|
726
|
+
f += 1.0 - CLAMPS(
|
|
727
|
+
length(
|
|
728
|
+
p -
|
|
729
|
+
vec2(
|
|
730
|
+
smoothRandom(vec2(progress * 1.3), i + 1.0),
|
|
731
|
+
smoothRandom(vec2(progress * 0.5), i + 6.25)
|
|
732
|
+
)
|
|
733
|
+
) * mix(20.0, 70.0, rand(i))
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
f += 4.0;
|
|
738
|
+
f /= 11.0;
|
|
739
|
+
f = pow3(
|
|
740
|
+
f * vec3(1.0, 0.7, 0.6),
|
|
741
|
+
vec3(1.0, 2.0 - sin(progress * PI), 1.3)
|
|
742
|
+
);
|
|
743
|
+
f *= sin(progress * PI);
|
|
744
|
+
|
|
745
|
+
p -= 0.5;
|
|
746
|
+
p *= 1.0 + (smoothRandom(vec2(progress * 5.0), 6.3) * sin(progress * PI) * 0.05);
|
|
747
|
+
p += 0.5;
|
|
748
|
+
|
|
749
|
+
vec4 blurredImage = vec4(0.0);
|
|
750
|
+
float blurAmount = sin(progress * PI) * 0.03;
|
|
751
|
+
for (float i = 0.0; i < REPEATS; i++) {
|
|
752
|
+
vec2 q = vec2(
|
|
753
|
+
cos(degrees((i / REPEATS) * 360.0)),
|
|
754
|
+
sin(degrees((i / REPEATS) * 360.0))
|
|
755
|
+
) * (rand(vec2(i, p.x + p.y)) + blurAmount);
|
|
756
|
+
vec2 uv2 = p + (q * blurAmount);
|
|
757
|
+
blurredImage += sampleTexture(uv2, progress);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
blurredImage /= REPEATS;
|
|
761
|
+
return blurredImage + vec4(f, 0.0);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
void main() {
|
|
765
|
+
float progress = 1.0 - u_time;
|
|
766
|
+
outColor = transition(v_uv, progress);
|
|
767
|
+
}`;
|
|
768
|
+
var compileShader3 = (gl, source, type) => {
|
|
769
|
+
const shader = gl.createShader(type);
|
|
770
|
+
if (!shader) {
|
|
771
|
+
throw new Error("Failed to create shader");
|
|
772
|
+
}
|
|
773
|
+
gl.shaderSource(shader, source);
|
|
774
|
+
gl.compileShader(shader);
|
|
775
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
776
|
+
const log = gl.getShaderInfoLog(shader);
|
|
777
|
+
gl.deleteShader(shader);
|
|
778
|
+
throw new Error(`Failed to compile shader: ${log}`);
|
|
779
|
+
}
|
|
780
|
+
return shader;
|
|
781
|
+
};
|
|
782
|
+
var createProgram3 = (gl) => {
|
|
783
|
+
const program = gl.createProgram();
|
|
784
|
+
if (!program) {
|
|
785
|
+
throw new Error("Failed to create WebGL program");
|
|
786
|
+
}
|
|
787
|
+
const vs = compileShader3(gl, VERTEX_SHADER3, gl.VERTEX_SHADER);
|
|
788
|
+
const fs = compileShader3(gl, FRAGMENT_SHADER3, gl.FRAGMENT_SHADER);
|
|
789
|
+
gl.attachShader(program, vs);
|
|
790
|
+
gl.attachShader(program, fs);
|
|
791
|
+
gl.linkProgram(program);
|
|
792
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
793
|
+
const log = gl.getProgramInfoLog(program);
|
|
794
|
+
gl.deleteProgram(program);
|
|
795
|
+
throw new Error(`Failed to link program: ${log}`);
|
|
796
|
+
}
|
|
797
|
+
return program;
|
|
798
|
+
};
|
|
799
|
+
var createTexture3 = (gl) => {
|
|
800
|
+
const tex = gl.createTexture();
|
|
801
|
+
if (!tex) {
|
|
802
|
+
throw new Error("Failed to create texture");
|
|
803
|
+
}
|
|
804
|
+
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
805
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
806
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
807
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
808
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
809
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
|
|
810
|
+
return tex;
|
|
811
|
+
};
|
|
812
|
+
var filmBurnShader = (canvas) => {
|
|
813
|
+
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
|
|
814
|
+
if (!gl) {
|
|
815
|
+
throw new Error("Failed to create WebGL2 context");
|
|
816
|
+
}
|
|
817
|
+
const program = createProgram3(gl);
|
|
818
|
+
const prevTex = createTexture3(gl);
|
|
819
|
+
const nextTex = createTexture3(gl);
|
|
820
|
+
const vao = gl.createVertexArray();
|
|
821
|
+
gl.bindVertexArray(vao);
|
|
822
|
+
const buffer = gl.createBuffer();
|
|
823
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
824
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
|
825
|
+
const aPos = gl.getAttribLocation(program, "a_pos");
|
|
826
|
+
gl.enableVertexAttribArray(aPos);
|
|
827
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
|
|
828
|
+
const uTime = gl.getUniformLocation(program, "u_time");
|
|
829
|
+
const uPrev = gl.getUniformLocation(program, "u_prev");
|
|
830
|
+
const uNext = gl.getUniformLocation(program, "u_next");
|
|
831
|
+
const uSeed = gl.getUniformLocation(program, "u_seed");
|
|
832
|
+
const cleanup = () => {
|
|
833
|
+
gl.deleteProgram(program);
|
|
834
|
+
gl.deleteTexture(prevTex);
|
|
835
|
+
gl.deleteTexture(nextTex);
|
|
836
|
+
};
|
|
837
|
+
const clear = () => {
|
|
838
|
+
gl.clearColor(0, 0, 0, 0);
|
|
839
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
840
|
+
};
|
|
841
|
+
const draw = ({
|
|
842
|
+
prevImage,
|
|
843
|
+
nextImage,
|
|
844
|
+
width,
|
|
845
|
+
height,
|
|
846
|
+
time,
|
|
847
|
+
passedProps
|
|
848
|
+
}) => {
|
|
849
|
+
const { seed = DEFAULT_SEED } = passedProps;
|
|
850
|
+
if (!prevImage && !nextImage) {
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
|
|
860
|
+
gl.viewport(0, 0, width, height);
|
|
861
|
+
gl.clearColor(0, 0, 0, 0);
|
|
862
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
863
|
+
gl.useProgram(program);
|
|
864
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
865
|
+
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
866
|
+
if (prevImage) {
|
|
867
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
|
|
868
|
+
}
|
|
869
|
+
gl.uniform1i(uPrev, 0);
|
|
870
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
871
|
+
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
872
|
+
if (nextImage) {
|
|
873
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
|
|
874
|
+
}
|
|
875
|
+
gl.uniform1i(uNext, 1);
|
|
876
|
+
gl.uniform1f(uTime, effectiveTime);
|
|
877
|
+
gl.uniform1f(uSeed, seed);
|
|
878
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
879
|
+
};
|
|
880
|
+
return {
|
|
881
|
+
clear,
|
|
882
|
+
cleanup,
|
|
883
|
+
draw
|
|
884
|
+
};
|
|
885
|
+
};
|
|
886
|
+
var filmBurn = makeHtmlInCanvasPresentation(filmBurnShader);
|
|
887
|
+
|
|
888
|
+
// src/presentations/linear-blur.tsx
|
|
889
|
+
var VERTEX_SHADER4 = `#version 300 es
|
|
890
|
+
in vec2 a_pos;
|
|
891
|
+
out vec2 v_uv;
|
|
892
|
+
void main() {
|
|
893
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
894
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
895
|
+
}`;
|
|
896
|
+
var FRAGMENT_SHADER4 = `#version 300 es
|
|
897
|
+
precision highp float;
|
|
898
|
+
|
|
899
|
+
uniform sampler2D u_prev;
|
|
900
|
+
uniform sampler2D u_next;
|
|
901
|
+
uniform float u_time;
|
|
902
|
+
uniform float u_intensity;
|
|
903
|
+
|
|
904
|
+
in vec2 v_uv;
|
|
905
|
+
out vec4 outColor;
|
|
906
|
+
|
|
907
|
+
const int PASSES = 6;
|
|
908
|
+
|
|
909
|
+
vec4 transition(vec2 uv, float progress) {
|
|
910
|
+
vec4 c1 = vec4(0.0);
|
|
911
|
+
vec4 c2 = vec4(0.0);
|
|
912
|
+
|
|
913
|
+
float disp = u_intensity * (0.5 - distance(0.5, progress));
|
|
914
|
+
for (int xi = 0; xi < PASSES; xi++) {
|
|
915
|
+
float x = float(xi) / float(PASSES) - 0.5;
|
|
916
|
+
for (int yi = 0; yi < PASSES; yi++) {
|
|
917
|
+
float y = float(yi) / float(PASSES) - 0.5;
|
|
918
|
+
vec2 v = vec2(x, y);
|
|
919
|
+
c1 += texture(u_prev, uv + disp * v);
|
|
920
|
+
c2 += texture(u_next, uv + disp * v);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
c1 /= float(PASSES * PASSES);
|
|
925
|
+
c2 /= float(PASSES * PASSES);
|
|
926
|
+
return mix(c1, c2, progress);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
void main() {
|
|
930
|
+
float progress = 1.0 - u_time;
|
|
931
|
+
outColor = transition(v_uv, progress);
|
|
932
|
+
}`;
|
|
933
|
+
var compileShader4 = (gl, source, type) => {
|
|
934
|
+
const shader = gl.createShader(type);
|
|
935
|
+
if (!shader) {
|
|
936
|
+
throw new Error("Failed to create shader");
|
|
937
|
+
}
|
|
938
|
+
gl.shaderSource(shader, source);
|
|
939
|
+
gl.compileShader(shader);
|
|
940
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
941
|
+
const log = gl.getShaderInfoLog(shader);
|
|
942
|
+
gl.deleteShader(shader);
|
|
943
|
+
throw new Error(`Failed to compile shader: ${log}`);
|
|
944
|
+
}
|
|
945
|
+
return shader;
|
|
946
|
+
};
|
|
947
|
+
var createProgram4 = (gl) => {
|
|
948
|
+
const program = gl.createProgram();
|
|
949
|
+
if (!program) {
|
|
950
|
+
throw new Error("Failed to create WebGL program");
|
|
951
|
+
}
|
|
952
|
+
const vs = compileShader4(gl, VERTEX_SHADER4, gl.VERTEX_SHADER);
|
|
953
|
+
const fs = compileShader4(gl, FRAGMENT_SHADER4, gl.FRAGMENT_SHADER);
|
|
954
|
+
gl.attachShader(program, vs);
|
|
955
|
+
gl.attachShader(program, fs);
|
|
956
|
+
gl.linkProgram(program);
|
|
957
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
958
|
+
const log = gl.getProgramInfoLog(program);
|
|
959
|
+
gl.deleteProgram(program);
|
|
960
|
+
throw new Error(`Failed to link program: ${log}`);
|
|
961
|
+
}
|
|
962
|
+
return program;
|
|
963
|
+
};
|
|
964
|
+
var createTexture4 = (gl) => {
|
|
965
|
+
const tex = gl.createTexture();
|
|
966
|
+
if (!tex) {
|
|
967
|
+
throw new Error("Failed to create texture");
|
|
968
|
+
}
|
|
969
|
+
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
970
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
971
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
972
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
973
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
974
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
|
|
975
|
+
return tex;
|
|
976
|
+
};
|
|
977
|
+
var linearBlurShader = (canvas) => {
|
|
978
|
+
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
|
|
979
|
+
if (!gl) {
|
|
980
|
+
throw new Error("Failed to create WebGL2 context");
|
|
981
|
+
}
|
|
982
|
+
const program = createProgram4(gl);
|
|
983
|
+
const prevTex = createTexture4(gl);
|
|
984
|
+
const nextTex = createTexture4(gl);
|
|
985
|
+
const vao = gl.createVertexArray();
|
|
986
|
+
gl.bindVertexArray(vao);
|
|
987
|
+
const buffer = gl.createBuffer();
|
|
988
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
989
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
|
990
|
+
const aPos = gl.getAttribLocation(program, "a_pos");
|
|
991
|
+
gl.enableVertexAttribArray(aPos);
|
|
992
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
|
|
993
|
+
const uTime = gl.getUniformLocation(program, "u_time");
|
|
994
|
+
const uPrev = gl.getUniformLocation(program, "u_prev");
|
|
995
|
+
const uNext = gl.getUniformLocation(program, "u_next");
|
|
996
|
+
const uIntensity = gl.getUniformLocation(program, "u_intensity");
|
|
997
|
+
const cleanup = () => {
|
|
998
|
+
gl.deleteProgram(program);
|
|
999
|
+
gl.deleteTexture(prevTex);
|
|
1000
|
+
gl.deleteTexture(nextTex);
|
|
1001
|
+
};
|
|
1002
|
+
const clear = () => {
|
|
1003
|
+
gl.clearColor(0, 0, 0, 0);
|
|
1004
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
1005
|
+
};
|
|
1006
|
+
const draw = ({
|
|
1007
|
+
prevImage,
|
|
1008
|
+
nextImage,
|
|
1009
|
+
width,
|
|
1010
|
+
height,
|
|
1011
|
+
time,
|
|
1012
|
+
passedProps
|
|
1013
|
+
}) => {
|
|
1014
|
+
const { intensity = 0.1 } = passedProps;
|
|
1015
|
+
if (!prevImage && !nextImage) {
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
|
|
1025
|
+
gl.viewport(0, 0, width, height);
|
|
1026
|
+
gl.clearColor(0, 0, 0, 0);
|
|
1027
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
1028
|
+
gl.useProgram(program);
|
|
1029
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
1030
|
+
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
1031
|
+
if (prevImage) {
|
|
1032
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
|
|
1033
|
+
}
|
|
1034
|
+
gl.uniform1i(uPrev, 0);
|
|
1035
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
1036
|
+
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
1037
|
+
if (nextImage) {
|
|
1038
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
|
|
1039
|
+
}
|
|
1040
|
+
gl.uniform1i(uNext, 1);
|
|
1041
|
+
gl.uniform1f(uTime, effectiveTime);
|
|
1042
|
+
gl.uniform1f(uIntensity, intensity);
|
|
1043
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
1044
|
+
};
|
|
1045
|
+
return {
|
|
1046
|
+
clear,
|
|
1047
|
+
cleanup,
|
|
1048
|
+
draw
|
|
1049
|
+
};
|
|
1050
|
+
};
|
|
1051
|
+
var linearBlur = makeHtmlInCanvasPresentation(linearBlurShader);
|
|
1052
|
+
|
|
79
1053
|
// src/timings/linear-timing.ts
|
|
80
1054
|
import { interpolate } from "remotion";
|
|
81
1055
|
var linearTiming = (options) => {
|
|
@@ -123,33 +1097,33 @@ var springTiming = (options = {}) => {
|
|
|
123
1097
|
};
|
|
124
1098
|
};
|
|
125
1099
|
// src/TransitionSeries.tsx
|
|
126
|
-
import { Children, useCallback, useMemo as
|
|
127
|
-
import { Internals, Sequence, useCurrentFrame, useVideoConfig } from "remotion";
|
|
1100
|
+
import { Children, useCallback as useCallback2, useMemo as useMemo4, useRef as useRef2 } from "react";
|
|
1101
|
+
import { Internals as Internals2, Sequence, useCurrentFrame, useVideoConfig } from "remotion";
|
|
128
1102
|
import { NoReactInternals as NoReactInternals2 } from "remotion/no-react";
|
|
129
1103
|
|
|
130
1104
|
// src/context.tsx
|
|
131
|
-
import React2, { useMemo as
|
|
132
|
-
import { jsx as
|
|
1105
|
+
import React2, { useMemo as useMemo3 } from "react";
|
|
1106
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
133
1107
|
var EnteringContext = React2.createContext(null);
|
|
134
1108
|
var ExitingContext = React2.createContext(null);
|
|
135
1109
|
var WrapInEnteringProgressContext = ({ presentationProgress, children }) => {
|
|
136
|
-
const value =
|
|
1110
|
+
const value = useMemo3(() => {
|
|
137
1111
|
return {
|
|
138
1112
|
enteringProgress: presentationProgress
|
|
139
1113
|
};
|
|
140
1114
|
}, [presentationProgress]);
|
|
141
|
-
return /* @__PURE__ */
|
|
1115
|
+
return /* @__PURE__ */ jsx3(EnteringContext.Provider, {
|
|
142
1116
|
value,
|
|
143
1117
|
children
|
|
144
1118
|
});
|
|
145
1119
|
};
|
|
146
1120
|
var WrapInExitingProgressContext = ({ presentationProgress, children }) => {
|
|
147
|
-
const value =
|
|
1121
|
+
const value = useMemo3(() => {
|
|
148
1122
|
return {
|
|
149
1123
|
exitingProgress: presentationProgress
|
|
150
1124
|
};
|
|
151
1125
|
}, [presentationProgress]);
|
|
152
|
-
return /* @__PURE__ */
|
|
1126
|
+
return /* @__PURE__ */ jsx3(ExitingContext.Provider, {
|
|
153
1127
|
value,
|
|
154
1128
|
children
|
|
155
1129
|
});
|
|
@@ -173,7 +1147,7 @@ import { NoReactInternals } from "remotion/no-react";
|
|
|
173
1147
|
var validateDurationInFrames = NoReactInternals.validateDurationInFrames;
|
|
174
1148
|
|
|
175
1149
|
// src/TransitionSeries.tsx
|
|
176
|
-
import { jsx as
|
|
1150
|
+
import { jsx as jsx4, Fragment } from "react/jsx-runtime";
|
|
177
1151
|
var TransitionSeriesTransition = function(_props) {
|
|
178
1152
|
return null;
|
|
179
1153
|
};
|
|
@@ -181,7 +1155,7 @@ var SeriesOverlay = () => {
|
|
|
181
1155
|
return null;
|
|
182
1156
|
};
|
|
183
1157
|
var SeriesSequence = ({ children }) => {
|
|
184
|
-
return /* @__PURE__ */
|
|
1158
|
+
return /* @__PURE__ */ jsx4(Fragment, {
|
|
185
1159
|
children
|
|
186
1160
|
});
|
|
187
1161
|
};
|
|
@@ -190,12 +1164,12 @@ var TransitionSeriesChildren = ({
|
|
|
190
1164
|
}) => {
|
|
191
1165
|
const { fps } = useVideoConfig();
|
|
192
1166
|
const frame = useCurrentFrame();
|
|
193
|
-
const prevImageRef =
|
|
194
|
-
const nextImageRef =
|
|
195
|
-
const flattedChildren =
|
|
1167
|
+
const prevImageRef = useRef2({});
|
|
1168
|
+
const nextImageRef = useRef2({});
|
|
1169
|
+
const flattedChildren = useMemo4(() => {
|
|
196
1170
|
return flattenChildren(children);
|
|
197
1171
|
}, [children]);
|
|
198
|
-
const drawIfSynced =
|
|
1172
|
+
const drawIfSynced = useCallback2((index) => {
|
|
199
1173
|
const prevImage = prevImageRef?.current?.[index];
|
|
200
1174
|
const nextImage = nextImageRef?.current?.[index];
|
|
201
1175
|
if (!nextImage?.elementImage && prevImage?.elementImage) {
|
|
@@ -213,15 +1187,15 @@ var TransitionSeriesChildren = ({
|
|
|
213
1187
|
nextImage?.draw?.(null, null, 0);
|
|
214
1188
|
}
|
|
215
1189
|
}, []);
|
|
216
|
-
const onNextElementImage =
|
|
1190
|
+
const onNextElementImage = useCallback2((elementImage, progress, draw, index) => {
|
|
217
1191
|
prevImageRef.current[index] = { elementImage, progress, draw };
|
|
218
1192
|
drawIfSynced(index);
|
|
219
1193
|
}, [drawIfSynced]);
|
|
220
|
-
const onPrevElementImage =
|
|
1194
|
+
const onPrevElementImage = useCallback2((elementImage, progress, draw, index) => {
|
|
221
1195
|
nextImageRef.current[index] = { elementImage, progress, draw };
|
|
222
1196
|
drawIfSynced(index);
|
|
223
1197
|
}, [drawIfSynced]);
|
|
224
|
-
const childrenValue =
|
|
1198
|
+
const childrenValue = useMemo4(() => {
|
|
225
1199
|
let transitionOffsets = 0;
|
|
226
1200
|
let startFrame = 0;
|
|
227
1201
|
const overlayRenders = [];
|
|
@@ -369,12 +1343,13 @@ var TransitionSeriesChildren = ({
|
|
|
369
1343
|
const prevPresentation = prev.props.presentation ?? slide();
|
|
370
1344
|
const UppercaseNextPresentation = nextPresentation.component;
|
|
371
1345
|
const UppercasePrevPresentation = prevPresentation.component;
|
|
372
|
-
return /* @__PURE__ */
|
|
1346
|
+
return /* @__PURE__ */ jsx4(Sequence, {
|
|
373
1347
|
from: actualStartFrame,
|
|
374
1348
|
durationInFrames: durationInFramesProp,
|
|
375
1349
|
...passedProps,
|
|
376
1350
|
name: passedProps.name || "<TS.Sequence>",
|
|
377
|
-
|
|
1351
|
+
_remotionInternalDocumentationLink: passedProps.name ? undefined : "https://www.remotion.dev/docs/transitions/transitionseries",
|
|
1352
|
+
children: /* @__PURE__ */ jsx4(UppercaseNextPresentation, {
|
|
378
1353
|
passedProps: nextPresentation.props ?? {},
|
|
379
1354
|
presentationDirection: "exiting",
|
|
380
1355
|
presentationProgress: nextProgress,
|
|
@@ -386,9 +1361,9 @@ var TransitionSeriesChildren = ({
|
|
|
386
1361
|
throw new Error("Should not call when exiting");
|
|
387
1362
|
},
|
|
388
1363
|
bothEnteringAndExiting: true,
|
|
389
|
-
children: /* @__PURE__ */
|
|
1364
|
+
children: /* @__PURE__ */ jsx4(WrapInExitingProgressContext, {
|
|
390
1365
|
presentationProgress: nextProgress,
|
|
391
|
-
children: /* @__PURE__ */
|
|
1366
|
+
children: /* @__PURE__ */ jsx4(UppercasePrevPresentation, {
|
|
392
1367
|
passedProps: prevPresentation.props ?? {},
|
|
393
1368
|
presentationDirection: "entering",
|
|
394
1369
|
presentationProgress: prevProgress,
|
|
@@ -402,7 +1377,7 @@ var TransitionSeriesChildren = ({
|
|
|
402
1377
|
onNextElementImage(null, null, null, i - 1);
|
|
403
1378
|
},
|
|
404
1379
|
bothEnteringAndExiting: true,
|
|
405
|
-
children: /* @__PURE__ */
|
|
1380
|
+
children: /* @__PURE__ */ jsx4(WrapInEnteringProgressContext, {
|
|
406
1381
|
presentationProgress: prevProgress,
|
|
407
1382
|
children: child
|
|
408
1383
|
})
|
|
@@ -414,12 +1389,13 @@ var TransitionSeriesChildren = ({
|
|
|
414
1389
|
if (prevProgress !== null && prev) {
|
|
415
1390
|
const prevPresentation = prev.props.presentation ?? slide();
|
|
416
1391
|
const UppercasePrevPresentation = prevPresentation.component;
|
|
417
|
-
return /* @__PURE__ */
|
|
1392
|
+
return /* @__PURE__ */ jsx4(Sequence, {
|
|
418
1393
|
from: actualStartFrame,
|
|
419
1394
|
durationInFrames: durationInFramesProp,
|
|
420
1395
|
...passedProps,
|
|
421
1396
|
name: passedProps.name || "<TS.Sequence>",
|
|
422
|
-
|
|
1397
|
+
_remotionInternalDocumentationLink: passedProps.name ? undefined : "https://www.remotion.dev/docs/transitions/transitionseries",
|
|
1398
|
+
children: /* @__PURE__ */ jsx4(UppercasePrevPresentation, {
|
|
423
1399
|
passedProps: prevPresentation.props ?? {},
|
|
424
1400
|
presentationDirection: "entering",
|
|
425
1401
|
presentationProgress: prevProgress,
|
|
@@ -429,7 +1405,7 @@ var TransitionSeriesChildren = ({
|
|
|
429
1405
|
onNextElementImage(null, null, null, i - 1);
|
|
430
1406
|
},
|
|
431
1407
|
bothEnteringAndExiting: false,
|
|
432
|
-
children: /* @__PURE__ */
|
|
1408
|
+
children: /* @__PURE__ */ jsx4(WrapInEnteringProgressContext, {
|
|
433
1409
|
presentationProgress: prevProgress,
|
|
434
1410
|
children: child
|
|
435
1411
|
})
|
|
@@ -439,12 +1415,13 @@ var TransitionSeriesChildren = ({
|
|
|
439
1415
|
if (nextProgress !== null && next) {
|
|
440
1416
|
const nextPresentation = next.props.presentation ?? slide();
|
|
441
1417
|
const UppercaseNextPresentation = nextPresentation.component;
|
|
442
|
-
return /* @__PURE__ */
|
|
1418
|
+
return /* @__PURE__ */ jsx4(Sequence, {
|
|
443
1419
|
from: actualStartFrame,
|
|
444
1420
|
durationInFrames: durationInFramesProp,
|
|
445
1421
|
...passedProps,
|
|
446
1422
|
name: passedProps.name || "<TS.Sequence>",
|
|
447
|
-
|
|
1423
|
+
_remotionInternalDocumentationLink: passedProps.name ? undefined : "https://www.remotion.dev/docs/transitions/transitionseries",
|
|
1424
|
+
children: /* @__PURE__ */ jsx4(UppercaseNextPresentation, {
|
|
448
1425
|
passedProps: nextPresentation.props ?? {},
|
|
449
1426
|
presentationDirection: "exiting",
|
|
450
1427
|
presentationProgress: nextProgress,
|
|
@@ -454,27 +1431,29 @@ var TransitionSeriesChildren = ({
|
|
|
454
1431
|
onPrevElementImage(null, null, null, i + 1);
|
|
455
1432
|
},
|
|
456
1433
|
bothEnteringAndExiting: false,
|
|
457
|
-
children: /* @__PURE__ */
|
|
1434
|
+
children: /* @__PURE__ */ jsx4(WrapInExitingProgressContext, {
|
|
458
1435
|
presentationProgress: nextProgress,
|
|
459
1436
|
children: child
|
|
460
1437
|
})
|
|
461
1438
|
})
|
|
462
1439
|
}, i);
|
|
463
1440
|
}
|
|
464
|
-
return /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ jsx4(Sequence, {
|
|
465
1442
|
from: actualStartFrame,
|
|
466
1443
|
durationInFrames: durationInFramesProp,
|
|
467
1444
|
...passedProps,
|
|
468
1445
|
name: passedProps.name || "<TS.Sequence>",
|
|
1446
|
+
_remotionInternalDocumentationLink: passedProps.name ? undefined : "https://www.remotion.dev/docs/transitions/transitionseries",
|
|
469
1447
|
children: child
|
|
470
1448
|
}, i);
|
|
471
1449
|
});
|
|
472
1450
|
const overlayElements = overlayRenders.map((overlayInfo) => {
|
|
473
1451
|
const info = overlayInfo;
|
|
474
|
-
return /* @__PURE__ */
|
|
1452
|
+
return /* @__PURE__ */ jsx4(Sequence, {
|
|
475
1453
|
from: Math.round(info.overlayFrom),
|
|
476
1454
|
durationInFrames: info.durationInFrames,
|
|
477
1455
|
name: "<TS.Overlay>",
|
|
1456
|
+
_remotionInternalDocumentationLink: "https://www.remotion.dev/docs/transitions/transitionseries",
|
|
478
1457
|
layout: "absolute-fill",
|
|
479
1458
|
...info.stack ? { stack: info.stack } : {},
|
|
480
1459
|
children: info.children
|
|
@@ -482,7 +1461,7 @@ var TransitionSeriesChildren = ({
|
|
|
482
1461
|
});
|
|
483
1462
|
return [...mainChildren || [], ...overlayElements];
|
|
484
1463
|
}, [flattedChildren, fps, frame, onPrevElementImage, onNextElementImage]);
|
|
485
|
-
return /* @__PURE__ */
|
|
1464
|
+
return /* @__PURE__ */ jsx4(Fragment, {
|
|
486
1465
|
children: childrenValue
|
|
487
1466
|
});
|
|
488
1467
|
};
|
|
@@ -492,11 +1471,12 @@ var TransitionSeries = ({ children, name, layout: passedLayout, ...otherProps })
|
|
|
492
1471
|
if (NoReactInternals2.ENABLE_V5_BREAKING_CHANGES && layout !== "absolute-fill") {
|
|
493
1472
|
throw new TypeError(`The "layout" prop of <TransitionSeries /> is not supported anymore in v5. TransitionSeries' must be absolutely positioned.`);
|
|
494
1473
|
}
|
|
495
|
-
return /* @__PURE__ */
|
|
1474
|
+
return /* @__PURE__ */ jsx4(Sequence, {
|
|
496
1475
|
name: displayName,
|
|
497
1476
|
layout,
|
|
1477
|
+
_remotionInternalDocumentationLink: name === undefined ? "https://www.remotion.dev/docs/transitions/transitionseries" : undefined,
|
|
498
1478
|
...otherProps,
|
|
499
|
-
children: /* @__PURE__ */
|
|
1479
|
+
children: /* @__PURE__ */ jsx4(TransitionSeriesChildren, {
|
|
500
1480
|
children
|
|
501
1481
|
})
|
|
502
1482
|
});
|
|
@@ -504,9 +1484,9 @@ var TransitionSeries = ({ children, name, layout: passedLayout, ...otherProps })
|
|
|
504
1484
|
TransitionSeries.Sequence = SeriesSequence;
|
|
505
1485
|
TransitionSeries.Transition = TransitionSeriesTransition;
|
|
506
1486
|
TransitionSeries.Overlay = SeriesOverlay;
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
1487
|
+
Internals2.addSequenceStackTraces(TransitionSeries);
|
|
1488
|
+
Internals2.addSequenceStackTraces(SeriesSequence);
|
|
1489
|
+
Internals2.addSequenceStackTraces(SeriesOverlay);
|
|
510
1490
|
// src/use-transition-progress.ts
|
|
511
1491
|
import React5 from "react";
|
|
512
1492
|
var useTransitionProgress = () => {
|
|
@@ -525,183 +1505,14 @@ var useTransitionProgress = () => {
|
|
|
525
1505
|
exiting: exiting?.exitingProgress ?? 0
|
|
526
1506
|
};
|
|
527
1507
|
};
|
|
528
|
-
// src/html-in-canvas-presentation.tsx
|
|
529
|
-
import { useLayoutEffect, useMemo as useMemo4, useRef as useRef2, useState, useCallback as useCallback2 } from "react";
|
|
530
|
-
import {
|
|
531
|
-
HtmlInCanvas,
|
|
532
|
-
HTML_IN_CANVAS_UNSUPPORTED_MESSAGE,
|
|
533
|
-
useDelayRender
|
|
534
|
-
} from "remotion";
|
|
535
|
-
import { AbsoluteFill as AbsoluteFill2, Internals as Internals2 } from "remotion";
|
|
536
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
537
|
-
var HtmlInCanvasPresentation = ({
|
|
538
|
-
children,
|
|
539
|
-
onElementImage,
|
|
540
|
-
onUnmount,
|
|
541
|
-
presentationProgress,
|
|
542
|
-
presentationDirection,
|
|
543
|
-
shader,
|
|
544
|
-
effects,
|
|
545
|
-
passedProps,
|
|
546
|
-
bothEnteringAndExiting
|
|
547
|
-
}) => {
|
|
548
|
-
if (!HtmlInCanvas.isSupported()) {
|
|
549
|
-
throw new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
|
|
550
|
-
}
|
|
551
|
-
const canvasRef = useRef2(null);
|
|
552
|
-
const canvasSubtreeStyle = useMemo4(() => {
|
|
553
|
-
return {
|
|
554
|
-
width: "100%",
|
|
555
|
-
height: "100%",
|
|
556
|
-
position: "absolute",
|
|
557
|
-
top: 0,
|
|
558
|
-
left: 0,
|
|
559
|
-
right: 0,
|
|
560
|
-
bottom: 0
|
|
561
|
-
};
|
|
562
|
-
}, []);
|
|
563
|
-
const [offscreenCanvas] = useState(() => new OffscreenCanvas(1, 1));
|
|
564
|
-
const passedPropsRef = useRef2(passedProps);
|
|
565
|
-
passedPropsRef.current = passedProps;
|
|
566
|
-
const memoizedEffects = Internals2.useMemoizedEffects({
|
|
567
|
-
effects: effects ?? [],
|
|
568
|
-
overrideId: null
|
|
569
|
-
});
|
|
570
|
-
const effectsRef = useRef2(memoizedEffects);
|
|
571
|
-
effectsRef.current = memoizedEffects;
|
|
572
|
-
const [instance] = useState(() => shader(offscreenCanvas));
|
|
573
|
-
useLayoutEffect(() => {
|
|
574
|
-
return () => {
|
|
575
|
-
instance.cleanup();
|
|
576
|
-
};
|
|
577
|
-
}, [offscreenCanvas, instance]);
|
|
578
|
-
const chainState = Internals2.useEffectChainState();
|
|
579
|
-
const { delayRender, continueRender } = useDelayRender();
|
|
580
|
-
const draw = useCallback2(async (prevImage, nextImage, progress) => {
|
|
581
|
-
if (!canvasRef.current) {
|
|
582
|
-
throw new Error("Canvas not found");
|
|
583
|
-
}
|
|
584
|
-
const handle = delayRender("onPaint");
|
|
585
|
-
if (!prevImage && !nextImage) {
|
|
586
|
-
continueRender(handle);
|
|
587
|
-
instance.clear();
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
const width = prevImage?.width ?? nextImage?.width ?? 0;
|
|
591
|
-
const height = prevImage?.height ?? nextImage?.height ?? 0;
|
|
592
|
-
if (width === 0 || height === 0) {
|
|
593
|
-
continueRender(handle);
|
|
594
|
-
instance.clear();
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
offscreenCanvas.width = width;
|
|
598
|
-
offscreenCanvas.height = height;
|
|
599
|
-
instance.draw({
|
|
600
|
-
prevImage,
|
|
601
|
-
nextImage,
|
|
602
|
-
width,
|
|
603
|
-
height,
|
|
604
|
-
time: progress,
|
|
605
|
-
passedProps: passedPropsRef.current
|
|
606
|
-
});
|
|
607
|
-
await Internals2.runEffectChain({
|
|
608
|
-
state: chainState.get(width, height),
|
|
609
|
-
source: offscreenCanvas,
|
|
610
|
-
effects: effectsRef.current ?? [],
|
|
611
|
-
width,
|
|
612
|
-
height,
|
|
613
|
-
output: canvasRef.current
|
|
614
|
-
});
|
|
615
|
-
continueRender(handle);
|
|
616
|
-
}, [chainState, instance, offscreenCanvas, continueRender, delayRender]);
|
|
617
|
-
const passThrough = bothEnteringAndExiting && presentationDirection === "exiting";
|
|
618
|
-
useLayoutEffect(() => {
|
|
619
|
-
if (passThrough) {
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
const canvas = canvasRef.current;
|
|
623
|
-
if (!canvas) {
|
|
624
|
-
throw new Error("Canvas not found");
|
|
625
|
-
}
|
|
626
|
-
canvas.layoutSubtree = true;
|
|
627
|
-
const onPaint = () => {
|
|
628
|
-
const firstChild = canvas.firstChild;
|
|
629
|
-
if (!firstChild) {
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
632
|
-
const elementImage = canvas.captureElementImage(firstChild);
|
|
633
|
-
onElementImage(elementImage, draw);
|
|
634
|
-
};
|
|
635
|
-
canvas.addEventListener("paint", onPaint);
|
|
636
|
-
return () => {
|
|
637
|
-
canvas.removeEventListener("paint", onPaint);
|
|
638
|
-
};
|
|
639
|
-
}, [onElementImage, presentationDirection, draw, passThrough]);
|
|
640
|
-
useLayoutEffect(() => {
|
|
641
|
-
if (passThrough) {
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
const canvas = canvasRef.current;
|
|
645
|
-
if (!canvas) {
|
|
646
|
-
throw new Error("Canvas not found");
|
|
647
|
-
}
|
|
648
|
-
canvas.requestPaint?.();
|
|
649
|
-
}, [presentationProgress, passThrough, memoizedEffects]);
|
|
650
|
-
useLayoutEffect(() => {
|
|
651
|
-
if (passThrough) {
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
return () => {
|
|
655
|
-
onUnmount();
|
|
656
|
-
};
|
|
657
|
-
}, [onUnmount, passThrough]);
|
|
658
|
-
useLayoutEffect(() => {
|
|
659
|
-
if (passThrough) {
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
const canvas = canvasRef.current;
|
|
663
|
-
if (!canvas) {
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
const observer = new ResizeObserver(([entry]) => {
|
|
667
|
-
canvas.width = entry.devicePixelContentBoxSize[0].inlineSize;
|
|
668
|
-
canvas.height = entry.devicePixelContentBoxSize[0].blockSize;
|
|
669
|
-
});
|
|
670
|
-
observer.observe(canvas, { box: "device-pixel-content-box" });
|
|
671
|
-
}, [passThrough]);
|
|
672
|
-
if (passThrough) {
|
|
673
|
-
return children;
|
|
674
|
-
}
|
|
675
|
-
return /* @__PURE__ */ jsx4(AbsoluteFill2, {
|
|
676
|
-
children: /* @__PURE__ */ jsx4("canvas", {
|
|
677
|
-
ref: canvasRef,
|
|
678
|
-
style: canvasSubtreeStyle,
|
|
679
|
-
children
|
|
680
|
-
})
|
|
681
|
-
});
|
|
682
|
-
};
|
|
683
|
-
var makeHtmlInCanvasPresentation = (shader) => {
|
|
684
|
-
const CompWithShader = (props) => {
|
|
685
|
-
const { passedProps, ...otherProps } = props;
|
|
686
|
-
const { effects, ...restPassedProps } = props.passedProps;
|
|
687
|
-
return /* @__PURE__ */ jsx4(HtmlInCanvasPresentation, {
|
|
688
|
-
shader,
|
|
689
|
-
passedProps: restPassedProps,
|
|
690
|
-
effects,
|
|
691
|
-
...otherProps
|
|
692
|
-
});
|
|
693
|
-
};
|
|
694
|
-
return (props) => {
|
|
695
|
-
return {
|
|
696
|
-
component: CompWithShader,
|
|
697
|
-
props
|
|
698
|
-
};
|
|
699
|
-
};
|
|
700
|
-
};
|
|
701
1508
|
export {
|
|
702
1509
|
useTransitionProgress,
|
|
703
1510
|
springTiming,
|
|
704
1511
|
makeHtmlInCanvasPresentation,
|
|
705
1512
|
linearTiming,
|
|
1513
|
+
linearBlur,
|
|
1514
|
+
filmBurn,
|
|
1515
|
+
dreamyZoom,
|
|
1516
|
+
crossZoom,
|
|
706
1517
|
TransitionSeries
|
|
707
1518
|
};
|