Skip to content

🎥 Make videos programmatically with React

simplify examples

Jonny Burger33316dbeb161
diff --git a/packages/example/src/ThreeBasic/index.tsx b/packages/example/src/ThreeBasic/index.tsx
index 9854c5b6a9..7d297f8875 100644
--- a/packages/example/src/ThreeBasic/index.tsx
+++ b/packages/example/src/ThreeBasic/index.tsx
@@ -1,14 +1,11 @@
-import {ThreeCanvas, ThreeVideo} from '@remotion/three';
+import {ThreeCanvas} from '@remotion/three';
import React from 'react';
-import {Sequence, useCurrentFrame} from 'remotion';
+import {interpolate, useCurrentFrame} from 'remotion';
-const videoSrc =
- 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
-
-const ThreeBasic = (): React.ReactElement => {
+const ThreeBasic: React.FC = () => {
const frame = useCurrentFrame();
return (
- <div style={{display: 'flex', width: '100%'}}>
+ <div style={{display: 'flex', width: '100%', backgroundColor: 'white'}}>
<ThreeCanvas
orthographic={false}
camera={{fov: 75, position: [0, 0, 470]}}
@@ -16,20 +13,14 @@ const ThreeBasic = (): React.ReactElement => {
<ambientLight intensity={0.15} />
<pointLight args={[undefined, 0.4]} position={[200, 200, 0]} />
- {/**
- * // TODO: Cannot find parent of sequence
- */}
- <Sequence layout="none" from={-460} durationInFrames={Infinity}>
- <ThreeVideo ignoreDepth src={videoSrc} />
- </Sequence>
-
<mesh
- position={[-300, -200, 0]}
+ position={[0, 0, 0]}
rotation={[
frame * 0.06 * 0.5,
frame * 0.07 * 0.5,
frame * 0.08 * 0.5,
]}
+ scale={interpolate(Math.sin(frame / 10), [-1, 1], [0.8, 1.2])}
>
<boxGeometry args={[100, 100, 100]} />
<meshStandardMaterial
@@ -40,18 +31,6 @@ const ThreeBasic = (): React.ReactElement => {
]}
/>
</mesh>
-
- <mesh
- position={[300, -200, 0]}
- rotation={[
- frame * 0.06 * 0.5,
- frame * 0.07 * 0.5,
- frame * 0.08 * 0.5,
- ]}
- >
- <cylinderGeometry args={[50, 50, 180, 24]} />
- <meshStandardMaterial color="red" />
- </mesh>
</ThreeCanvas>
</div>
);
diff --git a/packages/example/src/ThreeShaderedVideo/ShaderedVideo.tsx b/packages/example/src/ThreeShaderedVideo/ShaderedVideo.tsx
index 906bc79d38..4660e29590 100644
--- a/packages/example/src/ThreeShaderedVideo/ShaderedVideo.tsx
+++ b/packages/example/src/ThreeShaderedVideo/ShaderedVideo.tsx
@@ -1,26 +1,9 @@
-import {MaterialNode, MeshProps, useThree} from '@react-three/fiber';
-import {
- TexturedShaderMaterial,
- TexturedShaderMaterialParameters,
- useVideoTexture,
- UseVideoTextureOptions,
-} from '@remotion/three';
+import {MeshProps, useThree} from '@react-three/fiber';
+import {useVideoTexture, UseVideoTextureOptions} from '@remotion/three';
import React from 'react';
import {useCurrentFrame} from 'remotion';
import {ShaderChunk, ShaderLib} from 'three';
-declare global {
- // eslint-disable-next-line @typescript-eslint/no-namespace
- namespace JSX {
- interface IntrinsicElements {
- texturedShaderMaterial: MaterialNode<
- TexturedShaderMaterial,
- [TexturedShaderMaterialParameters]
- >;
- }
- }
-}
-
const vShaderFullViewport = ShaderLib.basic.vertexShader.replace(
'#include <project_vertex>',
`
diff --git a/packages/example/src/ThreeVideo/index.tsx b/packages/example/src/ThreeVideo/index.tsx
new file mode 100644
index 0000000000..8edfb13992
--- /dev/null
+++ b/packages/example/src/ThreeVideo/index.tsx
@@ -0,0 +1,20 @@
+import {ThreeCanvas, ThreeVideo} from '@remotion/three';
+import React from 'react';
+import {Sequence} from 'remotion';
+
+const videoSrc =
+ 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
+
+const Video = (): React.ReactElement => {
+ return (
+ <div style={{display: 'flex', width: '100%'}}>
+ <ThreeCanvas>
+ <Sequence layout="none" from={-460} durationInFrames={Infinity}>
+ <ThreeVideo ignoreDepth src={videoSrc} />
+ </Sequence>
+ </ThreeCanvas>
+ </div>
+ );
+};
+
+export default Video;
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index c7f7f99dcc..ac924b9b1d 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -8,6 +8,7 @@ import {TenFrameTester} from './TenFrameTester';
import ThreeBasic from './ThreeBasic';
import ThreePostprocessing from './ThreePostprocessing';
import ThreeShaderedVideo from './ThreeShaderedVideo';
+import ThreeVideo from './ThreeVideo';
import {VideoTesting} from './VideoTesting';
export const Index: React.FC = () => {
@@ -252,6 +253,14 @@ export const Index: React.FC = () => {
fps={30}
durationInFrames={600}
/>
+ <Composition
+ id="three-video"
+ component={ThreeVideo}
+ width={1280}
+ height={720}
+ fps={30}
+ durationInFrames={600}
+ />
<Composition
id="three-postprocessing"
component={ThreePostprocessing}