Skip to content

🎥 Make videos programmatically with React

remotionthreecanvas -> threecanvas

Jonny Burgerccdfadac3b93
diff --git a/packages/example/src/ThreeBasic/index.tsx b/packages/example/src/ThreeBasic/index.tsx
index 5dd80557d0..dbd5cc59ef 100644
--- a/packages/example/src/ThreeBasic/index.tsx
+++ b/packages/example/src/ThreeBasic/index.tsx
@@ -1,4 +1,4 @@
-import {RemotionThreeCanvas, ThreeVideo} from '@remotion/three';
+import {ThreeCanvas, ThreeVideo} from '@remotion/three';
import React from 'react';
import {Sequence, useCurrentFrame} from 'remotion';
@@ -9,7 +9,7 @@ const ThreeBasic = (): React.ReactElement => {
const frame = useCurrentFrame();
return (
<div style={{display: 'flex', width: '100%'}}>
- <RemotionThreeCanvas
+ <ThreeCanvas
orthographic={false}
camera={{fov: 75, position: [0, 0, 470]}}
>
@@ -51,7 +51,7 @@ const ThreeBasic = (): React.ReactElement => {
<cylinderGeometry args={[50, 50, 180, 24]} />
<meshStandardMaterial color="red" />
</mesh>
- </RemotionThreeCanvas>
+ </ThreeCanvas>
</div>
);
};
diff --git a/packages/example/src/ThreePostprocessing/index.tsx b/packages/example/src/ThreePostprocessing/index.tsx
index d687209e43..d4e9cb95da 100644
--- a/packages/example/src/ThreePostprocessing/index.tsx
+++ b/packages/example/src/ThreePostprocessing/index.tsx
@@ -1,21 +1,22 @@
+import {EffectComposer, Scanline, Vignette} from '@react-three/postprocessing';
+import {SwirlEffect, ThreeCanvas, ThreeVideo} from '@remotion/three';
import React from 'react';
-import { useCurrentFrame } from 'remotion';
-import { RemotionThreeCanvas, SwirlEffect, ThreeVideo } from '@remotion/three';
-import { EffectComposer, Vignette, Scanline } from '@react-three/postprocessing';
+import {useCurrentFrame} from 'remotion';
-const videoSrc = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
+const videoSrc =
+ 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
const ThreePostprocessing = (): React.ReactElement => {
const frame = useCurrentFrame();
const [enableEffects, setEnableEffects] = React.useState(true); // eslint-disable-line @typescript-eslint/no-unused-vars
return (
<div
- style={{ display: 'flex', width: '100%' }}
+ style={{display: 'flex', width: '100%'}}
// onClick={() => setEnableEffects(x => !x)}
>
- <RemotionThreeCanvas
+ <ThreeCanvas
orthographic={false}
- camera={{ fov: 75, position: [0, 0, 470] }}
+ camera={{fov: 75, position: [0, 0, 470]}}
>
<ambientLight intensity={0.15} />
<pointLight args={[undefined, 0.4]} position={[200, 200, 0]} />
@@ -24,7 +25,11 @@ const ThreePostprocessing = (): React.ReactElement => {
<mesh
position={[-300, -200, 0]}
- rotation={[frame * 0.06 * 0.5, frame * 0.07 * 0.5, frame * 0.08 * 0.5]}
+ rotation={[
+ frame * 0.06 * 0.5,
+ frame * 0.07 * 0.5,
+ frame * 0.08 * 0.5,
+ ]}
>
<boxGeometry args={[100, 100, 100]} />
<meshStandardMaterial
@@ -38,10 +43,14 @@ const ThreePostprocessing = (): React.ReactElement => {
<mesh
position={[300, -200, 0]}
- rotation={[frame * 0.06 * 0.5, frame * 0.07 * 0.5, frame * 0.08 * 0.5]}
+ 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' />
+ <meshStandardMaterial color="red" />
</mesh>
{enableEffects && (
@@ -60,7 +69,7 @@ const ThreePostprocessing = (): React.ReactElement => {
radius={400}
offset={[
Math.sin(frame * 0.1) * 200,
- Math.cos(frame * 0.1) * 200
+ Math.cos(frame * 0.1) * 200,
]}
angle={Math.cos(frame * 0.013) * 0.6}
/>
@@ -68,7 +77,7 @@ const ThreePostprocessing = (): React.ReactElement => {
<Vignette darkness={0.55} />
</EffectComposer>
)}
- </RemotionThreeCanvas>
+ </ThreeCanvas>
</div>
);
};
diff --git a/packages/example/src/ThreeShaderedVideo/index.tsx b/packages/example/src/ThreeShaderedVideo/index.tsx
index 14a050a3f5..28e846e7b7 100644
--- a/packages/example/src/ThreeShaderedVideo/index.tsx
+++ b/packages/example/src/ThreeShaderedVideo/index.tsx
@@ -1,23 +1,23 @@
/// <reference types="@react-three/fiber" />
+import {ThreeCanvas} from '@remotion/three';
import React from 'react';
-import { RemotionThreeCanvas } from '@remotion/three';
-
import ShaderedVideo from './ShaderedVideo';
-const videoSrc = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
+const videoSrc =
+ 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
const ThreeShaderedVideo = (): React.ReactElement => {
return (
- <div style={{ display: 'flex', width: '100%' }}>
- <RemotionThreeCanvas
+ <div style={{display: 'flex', width: '100%'}}>
+ <ThreeCanvas
orthographic={false}
- camera={{ fov: 75, position: [0, 0, 470] }}
+ camera={{fov: 75, position: [0, 0, 470]}}
>
<ambientLight intensity={0.15} />
<pointLight args={[undefined, 0.4]} position={[200, 200, 0]} />
<ShaderedVideo ignoreDepth src={videoSrc} startFrom={460} />
- </RemotionThreeCanvas>
+ </ThreeCanvas>
</div>
);
};
diff --git a/packages/three/src/RemotionThreeCanvas.tsx b/packages/three/src/RemotionThreeCanvas.tsx
index 46afaea30b..a5259639c1 100644
--- a/packages/three/src/RemotionThreeCanvas.tsx
+++ b/packages/three/src/RemotionThreeCanvas.tsx
@@ -7,7 +7,7 @@ import {
RemotionThreeContextType,
} from './RemotionThreeContext';
-export const RemotionThreeCanvas = ({
+export const ThreeCanvas = ({
children,
tabIndex,
resize,
@@ -162,7 +162,7 @@ function useCreateRemotionThreeContext() {
// React.useEffect(() => {
// // Updating threeDomNodes has to happen outside the react-three render loop, so use a timeout
// setTimeout(() => {
-// // Only perform update, if the RemotionThreeCanvas is still mounted
+// // Only perform update, if the ThreeCanvas is still mounted
// if (isMountedRef.current) {
// const finalNode = (
// <Internals.RemotionContextProvider key={key} contexts={_remotionContexts}>
@@ -177,7 +177,7 @@ function useCreateRemotionThreeContext() {
// React.useEffect(() => () => {
// setTimeout(() => {
-// // Only perform unmount, if the RemotionThreeCanvas is still mounted
+// // Only perform unmount, if the ThreeCanvas is still mounted
// if (isMountedRef.current) {
// // Remove from nodes array
// setThreeDomNodes(sn => sn.filter(x => x.key !== key));
diff --git a/packages/three/src/index.ts b/packages/three/src/index.ts
index 861c4db628..cf1be044e1 100644
--- a/packages/three/src/index.ts
+++ b/packages/three/src/index.ts
@@ -1,5 +1,5 @@
export { SwirlEffect, SwirlEffectOptions } from './effects/SwirlEffect';
-export { RemotionThreeCanvas } from './RemotionThreeCanvas';
+export { ThreeCanvas } from './RemotionThreeCanvas';
export { useRemotionThreeDomNode } from './RemotionThreeContext';
export { ThreeVideo, ThreeVideoProps } from './ThreeVideo';
export { useVideoTexture, UseVideoTextureOptions } from './useVideoTexture';