Skip to content

🎥 Make videos programmatically with React

div 3d

Jonny Burgerf5ea5cc6e5aa
diff --git a/packages/example/src/3DContext/Div3D.tsx b/packages/example/src/3DContext/Div3D.tsx
index 9184e18623..c73a86bc7e 100644
--- a/packages/example/src/3DContext/Div3D.tsx
+++ b/packages/example/src/3DContext/Div3D.tsx
@@ -42,26 +42,14 @@ export const ExtrudeDiv: React.FC<{
);
};
-export const ThreeDPlane: React.FC<{
- readonly children: React.ReactNode;
- readonly width: number;
- readonly height: number;
- readonly cornerRadius: number;
- readonly style?: React.CSSProperties;
-}> = ({children, width, height, cornerRadius, style}) => {
+export const ThreeDiv: React.FC<React.HtmlHTMLAttributes<HTMLDivElement>> = ({
+ style,
+ ...props
+}) => {
return (
- <RectProvider height={height} width={width} cornerRadius={cornerRadius}>
- <div
- style={{
- width,
- height,
- position: 'relative',
- transform: makeMatrix3dTransform(useTransformations()),
- ...style,
- }}
- >
- {children}
- </div>
- </RectProvider>
+ <div
+ {...props}
+ style={{...style, transform: makeMatrix3dTransform(useTransformations())}}
+ />
);
};
diff --git a/packages/example/src/ParseAndDownloadMedia/index.tsx b/packages/example/src/ParseAndDownloadMedia/index.tsx
index aaed1a1f6c..3a1039e082 100644
--- a/packages/example/src/ParseAndDownloadMedia/index.tsx
+++ b/packages/example/src/ParseAndDownloadMedia/index.tsx
@@ -6,7 +6,7 @@ import {
useCurrentFrame,
useVideoConfig,
} from 'remotion';
-import {ExtrudeDiv, ThreeDPlane} from '../3DContext/Div3D';
+import {ExtrudeDiv, ThreeDiv} from '../3DContext/Div3D';
import {RotateX, RotateY} from '../3DContext/transformation-context';
export const ParseAndDownloadMedia: React.FC = () => {
@@ -23,37 +23,28 @@ export const ParseAndDownloadMedia: React.FC = () => {
const rotateY = interpolate(prog, [0, 1], [0, Math.PI / 2]);
return (
- <AbsoluteFill className="bg-white flex">
+ <AbsoluteFill className="bg-white flex justify-center items-center">
<RotateY radians={rotateX}>
<RotateX radians={rotateY}>
- <ThreeDPlane
- width={width}
- height={height}
- cornerRadius={0}
- style={{
- display: 'flex',
- justifyContent: 'center',
- alignItems: 'center',
- flexDirection: 'column',
- }}
+ <ThreeDiv
+ className="text-3xl mb-10"
+ style={{fontFamily: 'GT Planar'}}
>
- <div className="text-3xl mb-10" style={{fontFamily: 'GT Planar'}}>
- hi there
- </div>
- <ExtrudeDiv depth={40} width={700} height={120} cornerRadius={10}>
+ hi there
+ </ThreeDiv>
+ <ExtrudeDiv depth={40} width={700} height={120} cornerRadius={10}>
+ <div
+ className="h-full w-full overflow-hidden border-black border-solid border-2"
+ style={{borderRadius: 10, backgroundColor: 'white'}}
+ >
<div
- className="h-full w-full overflow-hidden border-black border-solid border-2"
- style={{borderRadius: 10, backgroundColor: 'white'}}
- >
- <div
- style={{
- width: `${interpolate(prog, [0, 1], [0, 100])}%`,
- }}
- className="bg-red-500 h-full"
- />
- </div>
- </ExtrudeDiv>
- </ThreeDPlane>
+ style={{
+ width: `${interpolate(prog, [0, 1], [0, 100])}%`,
+ }}
+ className="bg-red-500 h-full"
+ />
+ </div>
+ </ExtrudeDiv>
</RotateX>
</RotateY>
</AbsoluteFill>