@remotion/effects 4.0.536 → 4.0.538
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/THIRD_PARTY_LICENSES.md +30 -0
- package/dist/barrel-distortion/index.d.ts +1 -1
- package/dist/bevel-alpha/index.d.ts +13 -0
- package/dist/bevel-alpha/shaders.d.ts +3 -0
- package/dist/bevel-alpha.d.ts +1 -0
- package/dist/blur/index.d.ts +1 -1
- package/dist/brightness.d.ts +1 -1
- package/dist/burlap.d.ts +1 -1
- package/dist/checkerboard.d.ts +17 -17
- package/dist/chromatic-aberration/index.d.ts +1 -1
- package/dist/color-correction.d.ts +1 -1
- package/dist/color-key.d.ts +9 -9
- package/dist/color-utils.d.ts +8 -8
- package/dist/contour-lines.d.ts +23 -23
- package/dist/contrast.d.ts +1 -1
- package/dist/corner-pin/index.d.ts +1 -1
- package/dist/cylinder/index.d.ts +20 -0
- package/dist/cylinder/shader.d.ts +1 -0
- package/dist/cylinder.d.ts +1 -0
- package/dist/dot-grid.d.ts +7 -7
- package/dist/drop-shadow/index.d.ts +1 -1
- package/dist/duotone.d.ts +7 -7
- package/dist/emboss.d.ts +15 -15
- package/dist/esm/bevel-alpha.mjs +474 -0
- package/dist/esm/cylinder.mjs +390 -0
- package/dist/esm/fractal-noise.mjs +688 -0
- package/dist/esm/lens-blur.mjs +550 -0
- package/dist/esm/long-shadows.mjs +410 -0
- package/dist/esm/page-turn.mjs +405 -0
- package/dist/esm/sphere.mjs +376 -0
- package/dist/esm/turbulent-displace.mjs +652 -0
- package/dist/evolve.d.ts +8 -8
- package/dist/exposure.d.ts +1 -1
- package/dist/fisheye/index.d.ts +1 -1
- package/dist/flannel.d.ts +1 -1
- package/dist/fractal-noise/index.d.ts +40 -0
- package/dist/fractal-noise/shader.d.ts +1 -0
- package/dist/fractal-noise.d.ts +1 -0
- package/dist/gaussian-blur-shader.d.ts +1 -1
- package/dist/glow/index.d.ts +1 -1
- package/dist/grayscale.d.ts +1 -1
- package/dist/gridlines.d.ts +23 -23
- package/dist/halftone-linear-gradient.d.ts +21 -21
- package/dist/halftone.d.ts +25 -25
- package/dist/hue.d.ts +1 -1
- package/dist/invert.d.ts +1 -1
- package/dist/lens-blur/index.d.ts +30 -0
- package/dist/lens-blur/shader.d.ts +1 -0
- package/dist/lens-blur.d.ts +1 -0
- package/dist/levels.d.ts +1 -1
- package/dist/light-leak.d.ts +7 -7
- package/dist/light-trail/index.d.ts +1 -1
- package/dist/linear-gradient-tint.d.ts +1 -1
- package/dist/linear-gradient.d.ts +1 -1
- package/dist/linear-progressive-blur/index.d.ts +1 -1
- package/dist/linear-progressive-blur/linear-progressive-blur-shaders.d.ts +1 -1
- package/dist/linear-progressive-pixelate/index.d.ts +1 -1
- package/dist/lines.d.ts +18 -18
- package/dist/liquid-contours.d.ts +21 -21
- package/dist/long-shadows.d.ts +13 -0
- package/dist/lut/index.d.ts +3 -3
- package/dist/mirror/index.d.ts +1 -1
- package/dist/noise-displacement.d.ts +1 -1
- package/dist/noise.d.ts +1 -1
- package/dist/outline/polygonize-alpha.d.ts +1 -1
- package/dist/outline.d.ts +11 -11
- package/dist/page-turn/index.d.ts +20 -0
- package/dist/page-turn/shader.d.ts +1 -0
- package/dist/page-turn.d.ts +1 -0
- package/dist/paper.d.ts +1 -1
- package/dist/pattern.d.ts +1 -1
- package/dist/pixel-dissolve.d.ts +1 -1
- package/dist/pixelate.d.ts +1 -1
- package/dist/radial-progressive-blur/index.d.ts +1 -1
- package/dist/radial-progressive-blur/radial-progressive-blur-shaders.d.ts +1 -1
- package/dist/radial-progressive-pixelate/index.d.ts +1 -1
- package/dist/region-blur/index.d.ts +11 -11
- package/dist/rings.d.ts +15 -15
- package/dist/roughen-edges.d.ts +1 -1
- package/dist/saturation.d.ts +1 -1
- package/dist/scale/index.d.ts +1 -1
- package/dist/scanlines.d.ts +1 -1
- package/dist/shadows-highlights.d.ts +1 -1
- package/dist/shine.d.ts +1 -1
- package/dist/shrinkwrap.d.ts +1 -1
- package/dist/skew.d.ts +1 -1
- package/dist/speckle.d.ts +1 -1
- package/dist/sphere/index.d.ts +18 -0
- package/dist/sphere/shader.d.ts +1 -0
- package/dist/sphere.d.ts +1 -0
- package/dist/starburst.d.ts +13 -13
- package/dist/tear.d.ts +1 -1
- package/dist/thermal-vision.d.ts +7 -7
- package/dist/tile.d.ts +1 -1
- package/dist/tint.d.ts +5 -5
- package/dist/translate/index.d.ts +2 -2
- package/dist/turbulent-displace/index.d.ts +28 -0
- package/dist/turbulent-displace/shader.d.ts +1 -0
- package/dist/turbulent-displace.d.ts +1 -0
- package/dist/tv-signal-off.d.ts +1 -1
- package/dist/value-noise-shader.d.ts +1 -0
- package/dist/venetian-blinds.d.ts +8 -8
- package/dist/vibrance.d.ts +1 -1
- package/dist/vignette.d.ts +16 -16
- package/dist/visual-test/visual-utils.d.ts +8 -8
- package/dist/wave/index.d.ts +1 -1
- package/dist/waves.d.ts +24 -24
- package/dist/webgpu-projection-runtime.d.ts +24 -0
- package/dist/white-balance.d.ts +1 -1
- package/dist/white-noise.d.ts +1 -1
- package/dist/zigzag.d.ts +22 -22
- package/dist/zoom-blur/index.d.ts +1 -1
- package/package.json +71 -6
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
// src/cylinder/index.ts
|
|
2
|
+
import { Internals } from "remotion";
|
|
3
|
+
|
|
4
|
+
// src/validate-effect-param.ts
|
|
5
|
+
var assertEffectParamsObject = (params, effectLabel) => {
|
|
6
|
+
if (params === null || typeof params !== "object") {
|
|
7
|
+
throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var assertRequiredFiniteNumber = (value, name) => {
|
|
11
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
12
|
+
throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var assertRequiredColor = (value, name) => {
|
|
16
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
17
|
+
throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var assertOptionalColor = (value, name) => {
|
|
21
|
+
if (value === undefined) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
assertRequiredColor(value, name);
|
|
25
|
+
};
|
|
26
|
+
var assertOptionalBoolean = (value, name) => {
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value !== "boolean") {
|
|
31
|
+
throw new TypeError(`"${name}" must be a boolean, but got ${JSON.stringify(value)}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/color-utils.ts
|
|
36
|
+
var DEFAULT_AMOUNT = 1;
|
|
37
|
+
var DEFAULT_BRIGHTNESS_AMOUNT = 0;
|
|
38
|
+
var DEFAULT_HUE_DEGREES = 0;
|
|
39
|
+
var colorAmountSchema = {
|
|
40
|
+
type: "number",
|
|
41
|
+
min: 0,
|
|
42
|
+
max: 1,
|
|
43
|
+
step: 0.01,
|
|
44
|
+
default: DEFAULT_AMOUNT,
|
|
45
|
+
description: "Amount",
|
|
46
|
+
hiddenFromList: false
|
|
47
|
+
};
|
|
48
|
+
var colorMultiplierSchema = {
|
|
49
|
+
type: "number",
|
|
50
|
+
min: 0,
|
|
51
|
+
step: 0.01,
|
|
52
|
+
default: DEFAULT_AMOUNT,
|
|
53
|
+
description: "Amount",
|
|
54
|
+
hiddenFromList: false
|
|
55
|
+
};
|
|
56
|
+
var brightnessAmountSchema = {
|
|
57
|
+
type: "number",
|
|
58
|
+
min: -1,
|
|
59
|
+
max: 1,
|
|
60
|
+
step: 0.01,
|
|
61
|
+
default: DEFAULT_BRIGHTNESS_AMOUNT,
|
|
62
|
+
description: "Amount",
|
|
63
|
+
hiddenFromList: false
|
|
64
|
+
};
|
|
65
|
+
var hueDegreesSchema = {
|
|
66
|
+
type: "rotation-degrees",
|
|
67
|
+
step: 1,
|
|
68
|
+
default: DEFAULT_HUE_DEGREES,
|
|
69
|
+
description: "Degrees"
|
|
70
|
+
};
|
|
71
|
+
var assertOptionalFiniteNumber = (value, name) => {
|
|
72
|
+
if (value === undefined) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
assertRequiredFiniteNumber(value, name);
|
|
76
|
+
};
|
|
77
|
+
var validateUnitInterval = (value, name) => {
|
|
78
|
+
if (value < 0) {
|
|
79
|
+
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
80
|
+
}
|
|
81
|
+
if (value > 1) {
|
|
82
|
+
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var validateNonNegative = (value, name) => {
|
|
86
|
+
if (value < 0) {
|
|
87
|
+
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var validateSignedUnitInterval = (value, name) => {
|
|
91
|
+
if (value < -1) {
|
|
92
|
+
throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
|
|
93
|
+
}
|
|
94
|
+
if (value > 1) {
|
|
95
|
+
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var clampColorChannel = (value) => {
|
|
99
|
+
return Math.max(0, Math.min(255, value));
|
|
100
|
+
};
|
|
101
|
+
var parseColorRgba = (ctx, color) => {
|
|
102
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
103
|
+
ctx.fillStyle = color;
|
|
104
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
105
|
+
const { data } = ctx.getImageData(0, 0, 1, 1);
|
|
106
|
+
return [data[0], data[1], data[2], data[3]];
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/webgpu-projection-runtime.ts
|
|
110
|
+
var cleanupWebGpuProjection = (state) => {
|
|
111
|
+
state.resources?.texture.destroy();
|
|
112
|
+
state.resources?.uniforms.destroy();
|
|
113
|
+
state.resources = null;
|
|
114
|
+
state.context.unconfigure();
|
|
115
|
+
};
|
|
116
|
+
var setupWebGpuProjection = (target, label) => {
|
|
117
|
+
const context = target.getContext("webgpu");
|
|
118
|
+
if (!context) {
|
|
119
|
+
throw new Error(`WebGPU is not available for the ${label} effect`);
|
|
120
|
+
}
|
|
121
|
+
return { context, resources: null };
|
|
122
|
+
};
|
|
123
|
+
var applyWebGpuProjection = ({
|
|
124
|
+
state,
|
|
125
|
+
source,
|
|
126
|
+
width,
|
|
127
|
+
height,
|
|
128
|
+
device,
|
|
129
|
+
shader,
|
|
130
|
+
uniformData
|
|
131
|
+
}) => {
|
|
132
|
+
if (state.resources && (state.resources.device !== device || state.resources.width !== width || state.resources.height !== height)) {
|
|
133
|
+
cleanupWebGpuProjection(state);
|
|
134
|
+
}
|
|
135
|
+
if (!state.resources) {
|
|
136
|
+
const format = navigator.gpu.getPreferredCanvasFormat();
|
|
137
|
+
state.context.configure({ device, format, alphaMode: "premultiplied" });
|
|
138
|
+
const module = device.createShaderModule({ code: shader });
|
|
139
|
+
const pipeline = device.createRenderPipeline({
|
|
140
|
+
layout: "auto",
|
|
141
|
+
vertex: { module, entryPoint: "vertex" },
|
|
142
|
+
fragment: { module, entryPoint: "fragment", targets: [{ format }] },
|
|
143
|
+
primitive: { topology: "triangle-list" }
|
|
144
|
+
});
|
|
145
|
+
const uniforms = device.createBuffer({
|
|
146
|
+
size: uniformData.byteLength,
|
|
147
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
148
|
+
});
|
|
149
|
+
const sampler = device.createSampler({
|
|
150
|
+
addressModeU: "repeat",
|
|
151
|
+
magFilter: "linear",
|
|
152
|
+
minFilter: "linear"
|
|
153
|
+
});
|
|
154
|
+
const texture = device.createTexture({
|
|
155
|
+
size: [width, height],
|
|
156
|
+
format: "rgba8unorm",
|
|
157
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
|
|
158
|
+
});
|
|
159
|
+
const bindGroup = device.createBindGroup({
|
|
160
|
+
layout: pipeline.getBindGroupLayout(0),
|
|
161
|
+
entries: [
|
|
162
|
+
{ binding: 0, resource: texture.createView() },
|
|
163
|
+
{ binding: 1, resource: sampler },
|
|
164
|
+
{ binding: 2, resource: { buffer: uniforms } }
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
state.resources = {
|
|
168
|
+
device,
|
|
169
|
+
pipeline,
|
|
170
|
+
uniforms,
|
|
171
|
+
sampler,
|
|
172
|
+
texture,
|
|
173
|
+
bindGroup,
|
|
174
|
+
width,
|
|
175
|
+
height
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const { resources } = state;
|
|
179
|
+
device.queue.copyExternalImageToTexture({ source }, { texture: resources.texture, premultipliedAlpha: true }, [width, height]);
|
|
180
|
+
device.queue.writeBuffer(resources.uniforms, 0, uniformData);
|
|
181
|
+
const encoder = device.createCommandEncoder();
|
|
182
|
+
const pass = encoder.beginRenderPass({
|
|
183
|
+
colorAttachments: [
|
|
184
|
+
{
|
|
185
|
+
view: state.context.getCurrentTexture().createView(),
|
|
186
|
+
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
|
187
|
+
loadOp: "clear",
|
|
188
|
+
storeOp: "store"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
pass.setPipeline(resources.pipeline);
|
|
193
|
+
pass.setBindGroup(0, resources.bindGroup);
|
|
194
|
+
pass.draw(3);
|
|
195
|
+
pass.end();
|
|
196
|
+
device.queue.submit([encoder.finish()]);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/cylinder/shader.ts
|
|
200
|
+
var CYLINDER_SHADER = `
|
|
201
|
+
struct Params {
|
|
202
|
+
resolution: vec2f,
|
|
203
|
+
center: vec2f,
|
|
204
|
+
radius: f32,
|
|
205
|
+
spin: f32,
|
|
206
|
+
shading: f32,
|
|
207
|
+
faces: f32,
|
|
208
|
+
rotation: vec4f,
|
|
209
|
+
}
|
|
210
|
+
@group(0) @binding(0) var source: texture_2d<f32>;
|
|
211
|
+
@group(0) @binding(1) var sourceSampler: sampler;
|
|
212
|
+
@group(0) @binding(2) var<uniform> params: Params;
|
|
213
|
+
|
|
214
|
+
@vertex fn vertex(@builtin(vertex_index) index: u32) -> @builtin(position) vec4f {
|
|
215
|
+
let positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));
|
|
216
|
+
return vec4f(positions[index], 0, 1);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fn sampleFace(point: vec3f, inverse: mat3x3f, rotation: mat3x3f) -> vec4f {
|
|
220
|
+
let local = inverse * point;
|
|
221
|
+
let uv = vec2f(fract((atan2(local.x, local.z) + params.spin) / 6.28318530718 + 0.5), local.y / params.resolution.y + 0.5);
|
|
222
|
+
let color = textureSampleLevel(source, sourceSampler, uv, 0);
|
|
223
|
+
if (uv.y < 0 || uv.y > 1) { return vec4f(0); }
|
|
224
|
+
let normal = rotation * vec3f(local.x / params.radius, 0, local.z / params.radius);
|
|
225
|
+
let shade = mix(1.0, abs(normal.z), params.shading);
|
|
226
|
+
return vec4f(color.rgb * shade, color.a);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@fragment fn fragment(@builtin(position) position: vec4f) -> @location(0) vec4f {
|
|
230
|
+
let s = sin(params.rotation.xyz);
|
|
231
|
+
let c = cos(params.rotation.xyz);
|
|
232
|
+
let rx = mat3x3f(vec3f(1, 0, 0), vec3f(0, c.x, s.x), vec3f(0, -s.x, c.x));
|
|
233
|
+
let ry = mat3x3f(vec3f(c.y, 0, -s.y), vec3f(0, 1, 0), vec3f(s.y, 0, c.y));
|
|
234
|
+
let rz = mat3x3f(vec3f(c.z, s.z, 0), vec3f(-s.z, c.z, 0), vec3f(0, 0, 1));
|
|
235
|
+
let rotation = rz * ry * rx;
|
|
236
|
+
let axis = rotation[1];
|
|
237
|
+
let p = position.xy - params.center;
|
|
238
|
+
// Orthographic viewing ray intersecting the rotated, open cylinder wall.
|
|
239
|
+
let a = 1.0 - axis.z * axis.z;
|
|
240
|
+
let da = dot(p, axis.xy);
|
|
241
|
+
let b = -da * axis.z;
|
|
242
|
+
let discriminant = b * b - a * (dot(p, p) - da * da - params.radius * params.radius);
|
|
243
|
+
if (a < 0.000001 || discriminant <= 0) { return vec4f(0); }
|
|
244
|
+
let root = sqrt(discriminant);
|
|
245
|
+
let inverse = transpose(rotation);
|
|
246
|
+
let front = sampleFace(vec3f(p, (-b + root) / a), inverse, rotation);
|
|
247
|
+
let back = sampleFace(vec3f(p, (-b - root) / a), inverse, rotation);
|
|
248
|
+
if (params.faces == 1) { return front; }
|
|
249
|
+
if (params.faces == 2) { return back; }
|
|
250
|
+
// Both the texture and output use premultiplied alpha.
|
|
251
|
+
return front + back * (1.0 - front.a);
|
|
252
|
+
}
|
|
253
|
+
`;
|
|
254
|
+
|
|
255
|
+
// src/cylinder/index.ts
|
|
256
|
+
var DEFAULT_RADIUS = 250;
|
|
257
|
+
var DEFAULT_ROTATION = 0;
|
|
258
|
+
var DEFAULT_POSITION = [0.5, 0.5];
|
|
259
|
+
var DEFAULT_RENDER = "both";
|
|
260
|
+
var DEFAULT_SHADING = 0.35;
|
|
261
|
+
var cylinderSchema = {
|
|
262
|
+
radius: {
|
|
263
|
+
type: "number",
|
|
264
|
+
min: 1,
|
|
265
|
+
max: 1000,
|
|
266
|
+
step: 1,
|
|
267
|
+
default: DEFAULT_RADIUS,
|
|
268
|
+
description: "Radius",
|
|
269
|
+
hiddenFromList: false
|
|
270
|
+
},
|
|
271
|
+
rotation: {
|
|
272
|
+
type: "rotation-degrees",
|
|
273
|
+
default: DEFAULT_ROTATION,
|
|
274
|
+
description: "Texture rotation"
|
|
275
|
+
},
|
|
276
|
+
rotationX: {
|
|
277
|
+
type: "rotation-degrees",
|
|
278
|
+
default: DEFAULT_ROTATION,
|
|
279
|
+
description: "X rotation"
|
|
280
|
+
},
|
|
281
|
+
rotationY: {
|
|
282
|
+
type: "rotation-degrees",
|
|
283
|
+
default: DEFAULT_ROTATION,
|
|
284
|
+
description: "Y rotation"
|
|
285
|
+
},
|
|
286
|
+
rotationZ: {
|
|
287
|
+
type: "rotation-degrees",
|
|
288
|
+
default: DEFAULT_ROTATION,
|
|
289
|
+
description: "Z rotation"
|
|
290
|
+
},
|
|
291
|
+
position: {
|
|
292
|
+
type: "uv-coordinate",
|
|
293
|
+
default: DEFAULT_POSITION,
|
|
294
|
+
description: "Position"
|
|
295
|
+
},
|
|
296
|
+
render: {
|
|
297
|
+
type: "enum",
|
|
298
|
+
variants: { both: {}, front: {}, back: {} },
|
|
299
|
+
default: DEFAULT_RENDER,
|
|
300
|
+
description: "Faces"
|
|
301
|
+
},
|
|
302
|
+
shading: {
|
|
303
|
+
type: "number",
|
|
304
|
+
min: 0,
|
|
305
|
+
max: 1,
|
|
306
|
+
step: 0.01,
|
|
307
|
+
default: DEFAULT_SHADING,
|
|
308
|
+
description: "Shading",
|
|
309
|
+
hiddenFromList: false
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
var resolve = (params) => ({
|
|
313
|
+
radius: params.radius ?? DEFAULT_RADIUS,
|
|
314
|
+
rotation: params.rotation ?? DEFAULT_ROTATION,
|
|
315
|
+
rotationX: params.rotationX ?? DEFAULT_ROTATION,
|
|
316
|
+
rotationY: params.rotationY ?? DEFAULT_ROTATION,
|
|
317
|
+
rotationZ: params.rotationZ ?? DEFAULT_ROTATION,
|
|
318
|
+
position: params.position ?? DEFAULT_POSITION,
|
|
319
|
+
render: params.render ?? DEFAULT_RENDER,
|
|
320
|
+
shading: params.shading ?? DEFAULT_SHADING
|
|
321
|
+
});
|
|
322
|
+
var cylinder = Internals.createEffect({
|
|
323
|
+
type: "remotion/cylinder",
|
|
324
|
+
label: "cylinder()",
|
|
325
|
+
documentationLink: "https://www.remotion.dev/docs/effects/cylinder",
|
|
326
|
+
backend: "webgpu",
|
|
327
|
+
schema: cylinderSchema,
|
|
328
|
+
validateParams: (params) => {
|
|
329
|
+
assertEffectParamsObject(params, "Cylinder");
|
|
330
|
+
for (const key of [
|
|
331
|
+
"radius",
|
|
332
|
+
"rotation",
|
|
333
|
+
"rotationX",
|
|
334
|
+
"rotationY",
|
|
335
|
+
"rotationZ",
|
|
336
|
+
"shading"
|
|
337
|
+
]) {
|
|
338
|
+
assertOptionalFiniteNumber(params[key], key);
|
|
339
|
+
}
|
|
340
|
+
const r = resolve(params);
|
|
341
|
+
if (r.radius <= 0) {
|
|
342
|
+
throw new TypeError('"radius" must be greater than 0');
|
|
343
|
+
}
|
|
344
|
+
validateUnitInterval(r.shading, "shading");
|
|
345
|
+
if (params.position !== undefined && (!Array.isArray(params.position) || params.position.length !== 2 || !Number.isFinite(params.position[0]) || !Number.isFinite(params.position[1]))) {
|
|
346
|
+
throw new TypeError('"position" must contain two finite numbers');
|
|
347
|
+
}
|
|
348
|
+
if (params.render !== undefined && params.render !== "both" && params.render !== "front" && params.render !== "back") {
|
|
349
|
+
throw new TypeError('"render" must be "both", "front", or "back"');
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
calculateKey: (params) => {
|
|
353
|
+
const r = resolve(params);
|
|
354
|
+
return `cylinder-${r.radius}-${r.rotation}-${r.rotationX}-${r.rotationY}-${r.rotationZ}-${r.position.join(",")}-${r.render}-${r.shading}`;
|
|
355
|
+
},
|
|
356
|
+
setup: (target) => setupWebGpuProjection(target, "cylinder"),
|
|
357
|
+
apply: ({ source, width, height, params, state, gpuDevice }) => {
|
|
358
|
+
if (!gpuDevice) {
|
|
359
|
+
throw new Error("A WebGPU device is required for the cylinder effect");
|
|
360
|
+
}
|
|
361
|
+
const r = resolve(params);
|
|
362
|
+
const radians = Math.PI / 180;
|
|
363
|
+
applyWebGpuProjection({
|
|
364
|
+
source,
|
|
365
|
+
width,
|
|
366
|
+
height,
|
|
367
|
+
state,
|
|
368
|
+
device: gpuDevice,
|
|
369
|
+
shader: CYLINDER_SHADER,
|
|
370
|
+
uniformData: new Float32Array([
|
|
371
|
+
width,
|
|
372
|
+
height,
|
|
373
|
+
r.position[0] * width,
|
|
374
|
+
r.position[1] * height,
|
|
375
|
+
r.radius,
|
|
376
|
+
r.rotation % 360 * radians,
|
|
377
|
+
r.shading,
|
|
378
|
+
r.render === "front" ? 1 : r.render === "back" ? 2 : 0,
|
|
379
|
+
r.rotationX % 360 * radians,
|
|
380
|
+
r.rotationY % 360 * radians,
|
|
381
|
+
r.rotationZ % 360 * radians,
|
|
382
|
+
0
|
|
383
|
+
])
|
|
384
|
+
});
|
|
385
|
+
},
|
|
386
|
+
cleanup: cleanupWebGpuProjection
|
|
387
|
+
});
|
|
388
|
+
export {
|
|
389
|
+
cylinder
|
|
390
|
+
};
|