@remotion/transitions 4.0.465 → 4.0.466
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/crosswarp.js +2 -0
- package/dist/TransitionSeries.js +16 -6
- package/dist/esm/book-flip.mjs +433 -0
- package/dist/esm/crosswarp.mjs +330 -0
- package/dist/esm/dreamy-zoom.mjs +347 -0
- package/dist/esm/index.mjs +553 -209
- package/dist/esm/linear-blur.mjs +342 -0
- package/dist/esm/ripple.mjs +341 -0
- package/dist/esm/swap.mjs +393 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.js +5 -1
- package/dist/presentations/book-flip.d.ts +14 -0
- package/dist/presentations/book-flip.js +255 -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/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/dreamy-zoom.js +2 -0
- package/linear-blur.js +2 -0
- package/package.json +62 -8
- package/ripple.js +2 -0
- package/swap.js +2 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type SwapProps = {
|
|
2
|
+
reflection?: number;
|
|
3
|
+
perspective?: number;
|
|
4
|
+
depth?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const swapShader: (canvas: OffscreenCanvas) => {
|
|
7
|
+
clear: () => void;
|
|
8
|
+
cleanup: () => void;
|
|
9
|
+
draw: import("..").HtmlInCanvasShaderDraw<SwapProps>;
|
|
10
|
+
};
|
|
11
|
+
export declare const swap: (props: SwapProps & {
|
|
12
|
+
effects?: import("remotion").EffectsProp | undefined;
|
|
13
|
+
}) => import("..").TransitionPresentation<SwapProps & {
|
|
14
|
+
effects?: import("remotion").EffectsProp | undefined;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.swap = exports.swapShader = void 0;
|
|
4
|
+
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const DEFAULT_REFLECTION = 0.4;
|
|
6
|
+
const DEFAULT_PERSPECTIVE = 0.2;
|
|
7
|
+
const DEFAULT_DEPTH = 3.0;
|
|
8
|
+
const VERTEX_SHADER = `#version 300 es
|
|
9
|
+
in vec2 a_pos;
|
|
10
|
+
out vec2 v_uv;
|
|
11
|
+
void main() {
|
|
12
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
13
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
14
|
+
}`;
|
|
15
|
+
// Adapted from https://gl-transitions.com/editor/swap
|
|
16
|
+
// Author: gre - License: MIT
|
|
17
|
+
const FRAGMENT_SHADER = `#version 300 es
|
|
18
|
+
precision highp float;
|
|
19
|
+
|
|
20
|
+
uniform sampler2D u_prev;
|
|
21
|
+
uniform sampler2D u_next;
|
|
22
|
+
uniform float u_time;
|
|
23
|
+
uniform float u_reflection;
|
|
24
|
+
uniform float u_perspective;
|
|
25
|
+
uniform float u_depth;
|
|
26
|
+
|
|
27
|
+
in vec2 v_uv;
|
|
28
|
+
out vec4 outColor;
|
|
29
|
+
|
|
30
|
+
const vec4 black = vec4(0.0, 0.0, 0.0, 1.0);
|
|
31
|
+
const vec2 boundMin = vec2(0.0, 0.0);
|
|
32
|
+
const vec2 boundMax = vec2(1.0, 1.0);
|
|
33
|
+
|
|
34
|
+
bool inBounds(vec2 p) {
|
|
35
|
+
return all(lessThan(boundMin, p)) && all(lessThan(p, boundMax));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
vec2 project(vec2 p) {
|
|
39
|
+
return p * vec2(1.0, -1.2) + vec2(0.0, 2.22);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
vec4 bgColor(vec2 p, vec2 pfr, vec2 pto) {
|
|
43
|
+
vec4 c = black;
|
|
44
|
+
pfr = project(pfr);
|
|
45
|
+
if (inBounds(pfr)) {
|
|
46
|
+
c += mix(black, texture(u_prev, pfr), u_reflection * mix(1.0, 0.0, pfr.y));
|
|
47
|
+
}
|
|
48
|
+
pto = project(pto);
|
|
49
|
+
if (inBounds(pto)) {
|
|
50
|
+
c += mix(black, texture(u_next, pto), u_reflection * mix(1.0, 0.0, pto.y));
|
|
51
|
+
}
|
|
52
|
+
return c;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
vec4 transition(vec2 p, float progress) {
|
|
56
|
+
vec2 pfr;
|
|
57
|
+
vec2 pto = vec2(-1.0);
|
|
58
|
+
|
|
59
|
+
float size = mix(1.0, u_depth, progress);
|
|
60
|
+
float persp = u_perspective * progress;
|
|
61
|
+
pfr = (p + vec2(-0.0, -0.5)) * vec2(
|
|
62
|
+
size / (1.0 - u_perspective * progress),
|
|
63
|
+
size / (1.0 - size * persp * p.x)
|
|
64
|
+
) + vec2(0.0, 0.5);
|
|
65
|
+
|
|
66
|
+
size = mix(1.0, u_depth, 1.0 - progress);
|
|
67
|
+
persp = u_perspective * (1.0 - progress);
|
|
68
|
+
pto = (p + vec2(-1.0, -0.5)) * vec2(
|
|
69
|
+
size / (1.0 - u_perspective * (1.0 - progress)),
|
|
70
|
+
size / (1.0 - size * persp * (0.5 - p.x))
|
|
71
|
+
) + vec2(1.0, 0.5);
|
|
72
|
+
|
|
73
|
+
if (progress < 0.5) {
|
|
74
|
+
if (inBounds(pfr)) {
|
|
75
|
+
return texture(u_prev, pfr);
|
|
76
|
+
}
|
|
77
|
+
if (inBounds(pto)) {
|
|
78
|
+
return texture(u_next, pto);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (inBounds(pto)) {
|
|
82
|
+
return texture(u_next, pto);
|
|
83
|
+
}
|
|
84
|
+
if (inBounds(pfr)) {
|
|
85
|
+
return texture(u_prev, pfr);
|
|
86
|
+
}
|
|
87
|
+
return bgColor(p, pfr, pto);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
void main() {
|
|
91
|
+
float progress = 1.0 - u_time;
|
|
92
|
+
outColor = transition(v_uv, progress);
|
|
93
|
+
}`;
|
|
94
|
+
const compileShader = (gl, source, type) => {
|
|
95
|
+
const shader = gl.createShader(type);
|
|
96
|
+
if (!shader) {
|
|
97
|
+
throw new Error('Failed to create shader');
|
|
98
|
+
}
|
|
99
|
+
gl.shaderSource(shader, source);
|
|
100
|
+
gl.compileShader(shader);
|
|
101
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
102
|
+
const log = gl.getShaderInfoLog(shader);
|
|
103
|
+
gl.deleteShader(shader);
|
|
104
|
+
throw new Error(`Failed to compile shader: ${log}`);
|
|
105
|
+
}
|
|
106
|
+
return shader;
|
|
107
|
+
};
|
|
108
|
+
const createProgram = (gl) => {
|
|
109
|
+
const program = gl.createProgram();
|
|
110
|
+
if (!program) {
|
|
111
|
+
throw new Error('Failed to create WebGL program');
|
|
112
|
+
}
|
|
113
|
+
const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);
|
|
114
|
+
const fs = compileShader(gl, FRAGMENT_SHADER, gl.FRAGMENT_SHADER);
|
|
115
|
+
gl.attachShader(program, vs);
|
|
116
|
+
gl.attachShader(program, fs);
|
|
117
|
+
gl.linkProgram(program);
|
|
118
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
119
|
+
const log = gl.getProgramInfoLog(program);
|
|
120
|
+
gl.deleteProgram(program);
|
|
121
|
+
throw new Error(`Failed to link program: ${log}`);
|
|
122
|
+
}
|
|
123
|
+
return program;
|
|
124
|
+
};
|
|
125
|
+
const createTexture = (gl) => {
|
|
126
|
+
const tex = gl.createTexture();
|
|
127
|
+
if (!tex) {
|
|
128
|
+
throw new Error('Failed to create texture');
|
|
129
|
+
}
|
|
130
|
+
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
131
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
132
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
133
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
134
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
135
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
|
|
136
|
+
return tex;
|
|
137
|
+
};
|
|
138
|
+
const swapShader = (canvas) => {
|
|
139
|
+
const gl = canvas.getContext('webgl2', { premultipliedAlpha: true });
|
|
140
|
+
if (!gl) {
|
|
141
|
+
throw new Error('Failed to create WebGL2 context');
|
|
142
|
+
}
|
|
143
|
+
const program = createProgram(gl);
|
|
144
|
+
const prevTex = createTexture(gl);
|
|
145
|
+
const nextTex = createTexture(gl);
|
|
146
|
+
const vao = gl.createVertexArray();
|
|
147
|
+
gl.bindVertexArray(vao);
|
|
148
|
+
const buffer = gl.createBuffer();
|
|
149
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
150
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
|
151
|
+
const aPos = gl.getAttribLocation(program, 'a_pos');
|
|
152
|
+
gl.enableVertexAttribArray(aPos);
|
|
153
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
|
|
154
|
+
const uTime = gl.getUniformLocation(program, 'u_time');
|
|
155
|
+
const uPrev = gl.getUniformLocation(program, 'u_prev');
|
|
156
|
+
const uNext = gl.getUniformLocation(program, 'u_next');
|
|
157
|
+
const uReflection = gl.getUniformLocation(program, 'u_reflection');
|
|
158
|
+
const uPerspective = gl.getUniformLocation(program, 'u_perspective');
|
|
159
|
+
const uDepth = gl.getUniformLocation(program, 'u_depth');
|
|
160
|
+
const cleanup = () => {
|
|
161
|
+
gl.deleteProgram(program);
|
|
162
|
+
gl.deleteTexture(prevTex);
|
|
163
|
+
gl.deleteTexture(nextTex);
|
|
164
|
+
};
|
|
165
|
+
const clear = () => {
|
|
166
|
+
gl.clearColor(0, 0, 0, 0);
|
|
167
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
168
|
+
};
|
|
169
|
+
const draw = ({ prevImage, nextImage, width, height, time, passedProps, }) => {
|
|
170
|
+
const { reflection = DEFAULT_REFLECTION, perspective = DEFAULT_PERSPECTIVE, depth = DEFAULT_DEPTH, } = passedProps;
|
|
171
|
+
if (!prevImage && !nextImage) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
// When one side is missing, force the mix to fully show the other.
|
|
181
|
+
// At time=0 the shader outputs nextImage. At time=1 the shader outputs prevImage.
|
|
182
|
+
const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
|
|
183
|
+
gl.viewport(0, 0, width, height);
|
|
184
|
+
gl.clearColor(0, 0, 0, 0);
|
|
185
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
186
|
+
gl.useProgram(program);
|
|
187
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
188
|
+
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
189
|
+
if (prevImage) {
|
|
190
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
|
|
191
|
+
}
|
|
192
|
+
gl.uniform1i(uPrev, 0);
|
|
193
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
194
|
+
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
195
|
+
if (nextImage) {
|
|
196
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
|
|
197
|
+
}
|
|
198
|
+
gl.uniform1i(uNext, 1);
|
|
199
|
+
gl.uniform1f(uTime, effectiveTime);
|
|
200
|
+
gl.uniform1f(uReflection, reflection);
|
|
201
|
+
gl.uniform1f(uPerspective, perspective);
|
|
202
|
+
gl.uniform1f(uDepth, depth);
|
|
203
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
clear,
|
|
207
|
+
cleanup,
|
|
208
|
+
draw,
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
exports.swapShader = swapShader;
|
|
212
|
+
exports.swap = (0, html_in_canvas_presentation_1.makeHtmlInCanvasPresentation)(exports.swapShader);
|
package/dreamy-zoom.js
ADDED
package/linear-blur.js
ADDED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/transitions"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/transitions",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.466",
|
|
7
7
|
"description": "Library for creating transitions in Remotion",
|
|
8
8
|
"main": "dist/esm/index.mjs",
|
|
9
9
|
"module": "dist/esm/index.js",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"remotion": "4.0.
|
|
26
|
-
"@remotion/shapes": "4.0.
|
|
27
|
-
"@remotion/paths": "4.0.
|
|
25
|
+
"remotion": "4.0.466",
|
|
26
|
+
"@remotion/shapes": "4.0.466",
|
|
27
|
+
"@remotion/paths": "4.0.466"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@happy-dom/global-registrator": "14.5.1",
|
|
31
|
-
"remotion": "4.0.
|
|
31
|
+
"remotion": "4.0.466",
|
|
32
32
|
"react": "19.2.3",
|
|
33
33
|
"react-dom": "19.2.3",
|
|
34
|
-
"@remotion/test-utils": "4.0.
|
|
35
|
-
"@remotion/player": "4.0.
|
|
36
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
34
|
+
"@remotion/test-utils": "4.0.466",
|
|
35
|
+
"@remotion/player": "4.0.466",
|
|
36
|
+
"@remotion/eslint-config-internal": "4.0.466",
|
|
37
37
|
"eslint": "9.19.0",
|
|
38
38
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
39
39
|
},
|
|
@@ -85,12 +85,30 @@
|
|
|
85
85
|
"import": "./dist/esm/clock-wipe.mjs",
|
|
86
86
|
"require": "./dist/presentations/clock-wipe.js"
|
|
87
87
|
},
|
|
88
|
+
"./book-flip": {
|
|
89
|
+
"types": "./dist/presentations/book-flip.d.ts",
|
|
90
|
+
"module": "./dist/esm/book-flip.mjs",
|
|
91
|
+
"import": "./dist/esm/book-flip.mjs",
|
|
92
|
+
"require": "./dist/presentations/book-flip.js"
|
|
93
|
+
},
|
|
88
94
|
"./zoom-blur": {
|
|
89
95
|
"types": "./dist/presentations/zoom-blur.d.ts",
|
|
90
96
|
"module": "./dist/esm/zoom-blur.mjs",
|
|
91
97
|
"import": "./dist/esm/zoom-blur.mjs",
|
|
92
98
|
"require": "./dist/presentations/zoom-blur.js"
|
|
93
99
|
},
|
|
100
|
+
"./dreamy-zoom": {
|
|
101
|
+
"types": "./dist/presentations/dreamy-zoom.d.ts",
|
|
102
|
+
"module": "./dist/esm/dreamy-zoom.mjs",
|
|
103
|
+
"import": "./dist/esm/dreamy-zoom.mjs",
|
|
104
|
+
"require": "./dist/presentations/dreamy-zoom.js"
|
|
105
|
+
},
|
|
106
|
+
"./linear-blur": {
|
|
107
|
+
"types": "./dist/presentations/linear-blur.d.ts",
|
|
108
|
+
"module": "./dist/esm/linear-blur.mjs",
|
|
109
|
+
"import": "./dist/esm/linear-blur.mjs",
|
|
110
|
+
"require": "./dist/presentations/linear-blur.js"
|
|
111
|
+
},
|
|
94
112
|
"./zoom-in-out": {
|
|
95
113
|
"types": "./dist/presentations/zoom-in-out.d.ts",
|
|
96
114
|
"module": "./dist/esm/zoom-in-out.mjs",
|
|
@@ -115,6 +133,24 @@
|
|
|
115
133
|
"import": "./dist/esm/dissolve.mjs",
|
|
116
134
|
"require": "./dist/presentations/dissolve.js"
|
|
117
135
|
},
|
|
136
|
+
"./ripple": {
|
|
137
|
+
"types": "./dist/presentations/ripple.d.ts",
|
|
138
|
+
"module": "./dist/esm/ripple.mjs",
|
|
139
|
+
"import": "./dist/esm/ripple.mjs",
|
|
140
|
+
"require": "./dist/presentations/ripple.js"
|
|
141
|
+
},
|
|
142
|
+
"./crosswarp": {
|
|
143
|
+
"types": "./dist/presentations/crosswarp.d.ts",
|
|
144
|
+
"module": "./dist/esm/crosswarp.mjs",
|
|
145
|
+
"import": "./dist/esm/crosswarp.mjs",
|
|
146
|
+
"require": "./dist/presentations/crosswarp.js"
|
|
147
|
+
},
|
|
148
|
+
"./swap": {
|
|
149
|
+
"types": "./dist/presentations/swap.d.ts",
|
|
150
|
+
"module": "./dist/esm/swap.mjs",
|
|
151
|
+
"import": "./dist/esm/swap.mjs",
|
|
152
|
+
"require": "./dist/presentations/swap.js"
|
|
153
|
+
},
|
|
118
154
|
"./package.json": "./package.json"
|
|
119
155
|
},
|
|
120
156
|
"typesVersions": {
|
|
@@ -137,17 +173,35 @@
|
|
|
137
173
|
"clock-wipe": [
|
|
138
174
|
"dist/presentations/clock-wipe.d.ts"
|
|
139
175
|
],
|
|
176
|
+
"book-flip": [
|
|
177
|
+
"dist/presentations/book-flip.d.ts"
|
|
178
|
+
],
|
|
140
179
|
"iris": [
|
|
141
180
|
"dist/presentations/iris.d.ts"
|
|
142
181
|
],
|
|
143
182
|
"zoom-blur": [
|
|
144
183
|
"dist/presentations/zoom-blur.d.ts"
|
|
145
184
|
],
|
|
185
|
+
"dreamy-zoom": [
|
|
186
|
+
"dist/presentations/dreamy-zoom.d.ts"
|
|
187
|
+
],
|
|
188
|
+
"linear-blur": [
|
|
189
|
+
"dist/presentations/linear-blur.d.ts"
|
|
190
|
+
],
|
|
146
191
|
"zoom-in-out": [
|
|
147
192
|
"dist/presentations/zoom-in-out.d.ts"
|
|
148
193
|
],
|
|
149
194
|
"dissolve": [
|
|
150
195
|
"dist/presentations/dissolve.d.ts"
|
|
196
|
+
],
|
|
197
|
+
"ripple": [
|
|
198
|
+
"dist/presentations/ripple.d.ts"
|
|
199
|
+
],
|
|
200
|
+
"crosswarp": [
|
|
201
|
+
"dist/presentations/crosswarp.d.ts"
|
|
202
|
+
],
|
|
203
|
+
"swap": [
|
|
204
|
+
"dist/presentations/swap.d.ts"
|
|
151
205
|
]
|
|
152
206
|
}
|
|
153
207
|
},
|
package/ripple.js
ADDED
package/swap.js
ADDED