🎥 Make videos programmatically with React
cube transition
Jonny Burgerd0031ed0359f
diff --git a/packages/docs/components/TableOfContents/pro-label.tsx b/packages/docs/components/TableOfContents/pro-label.tsxnew file mode 100644index 0000000000..6189b70da2--- /dev/null+++ b/packages/docs/components/TableOfContents/pro-label.tsx@@ -0,0 +1,26 @@+import React from "react";++export const ProLabel: React.FC = () => {+ return (+ <div+ style={{+ display: "inline-block",+ border: "1px solid",+ borderColor: "var(--border-color)",+ fontSize: 12,+ paddingLeft: 6,+ paddingRight: 6,+ marginLeft: 5,+ }}+ >+ <span+ style={{+ opacity: 0.8,+ color: "var(--text-color)",+ }}+ >+ Paid+ </span>+ </div>+ );+};diff --git a/packages/docs/components/TableOfContents/transitions/presentations.tsx b/packages/docs/components/TableOfContents/transitions/presentations.tsxindex c0f6eba5d5..04d0c005b6 100644--- a/packages/docs/components/TableOfContents/transitions/presentations.tsx+++ b/packages/docs/components/TableOfContents/transitions/presentations.tsx@@ -1,12 +1,13 @@+import { cube } from "@remotion-dev/cube-presentation";+import { clockWipe } from "@remotion/transitions/clock-wipe";import { fade } from "@remotion/transitions/fade";import { flip } from "@remotion/transitions/flip";import { slide } from "@remotion/transitions/slide";--import { clockWipe } from "@remotion/transitions/clock-wipe";import { wipe } from "@remotion/transitions/wipe";import React from "react";import { PresentationPreview } from "../../transitions/previews";import { Grid } from "../Grid";+import { ProLabel } from "../pro-label";import { TOCItem } from "../TOCItem";const row: React.CSSProperties = {@@ -90,6 +91,23 @@ export const Presentations: React.FC = () => {</div></div></TOCItem>+ <TOCItem link="/docs/transitions/presentations/cube">+ <div style={row}>+ <PresentationPreview+ durationRestThreshold={0.001}+ effect={cube({+ direction: "from-left",+ })}+ />+ <div style={{ flex: 1, marginLeft: 10 }}>+ <strong>+ <code>{"cube()"}</code>+ </strong>+ <ProLabel />+ <div>Rotate both scenes with 3D perspective</div>+ </div>+ </div>+ </TOCItem><TOCItem link="/docs/transitions/audio-transitions"><div style={row}><div style={{ flex: 1 }}>diff --git a/packages/docs/components/demos/index.tsx b/packages/docs/components/demos/index.tsxindex 7bb9c1570e..6feeceb0df 100644--- a/packages/docs/components/demos/index.tsx+++ b/packages/docs/components/demos/index.tsx@@ -8,6 +8,7 @@ import type { DemoType } from "./types";import {circleDemo,clockWipePresentationDemo,+ cubePresentationDemo,customPresentationDemo,customTimingDemo,ellipseDemo,@@ -59,6 +60,7 @@ const demos: DemoType[] = [customPresentationDemo,customTimingDemo,clockWipePresentationDemo,+ cubePresentationDemo,];export const Demo: React.FC<{diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.tsindex a10652085d..3a16089dc2 100644--- a/packages/docs/components/demos/types.ts+++ b/packages/docs/components/demos/types.ts@@ -1,5 +1,6 @@import {ClockWipeDemo,+ CubeDemo,CustomTimingDemo,CustomTransitionDemo,FadeDemo,@@ -626,6 +627,25 @@ export const clockWipePresentationDemo: DemoType = {options: [],};+export const cubePresentationDemo: DemoType = {+ comp: CubeDemo,+ compHeight: 280,+ compWidth: 540,+ durationInFrames: 60,+ fps: 30,+ id: "cube",+ autoPlay: true,+ options: [+ {+ type: "enum",+ name: "direction",+ default: "from-left",+ optional: "no",+ values: ["from-left", "from-top", "from-right", "from-bottom"],+ },+ ],+};+export const customPresentationDemo: DemoType = {comp: CustomTransitionDemo,compHeight: 280,diff --git a/packages/docs/components/transitions/previews.tsx b/packages/docs/components/transitions/previews.tsxindex 67885e03cf..0ecd196cbe 100644--- a/packages/docs/components/transitions/previews.tsx+++ b/packages/docs/components/transitions/previews.tsx@@ -1,3 +1,5 @@+import type { CubeDirection } from "@remotion-dev/cube-presentation";+import { cube } from "@remotion-dev/cube-presentation";import type { PlayerRef } from "@remotion/player";import { Player } from "@remotion/player";import type {@@ -147,6 +149,17 @@ export const ClockWipeDemo: React.FC<{}> = () => {);};+export const CubeDemo: React.FC<{ direction: CubeDirection }> = ({+ direction,+}) => {+ return (+ <SampleTransition+ effect={cube({ direction })}+ durationRestThreshold={0.001}+ />+ );+};+export const CustomTransitionDemo: React.FC<{}> = () => {const { width, height } = useVideoConfig();diff --git a/packages/docs/docs/transitions/presentations/cube.mdx b/packages/docs/docs/transitions/presentations/cube.mdxnew file mode 100644index 0000000000..ca292baa30--- /dev/null+++ b/packages/docs/docs/transitions/presentations/cube.mdx@@ -0,0 +1,81 @@+---+image: /generated/articles-docs-transitions-presentations-cube.png+crumb: "@remotion/transitions - Presentations"+title: "cube()"+---++:::note+This is a paid item which you can [buy here](https://remotion.pro/cube-transition).+:::++A presentation where both the entering and exiting scene rotate with 3D perspective.++<Demo type="cube" />++## Example++```tsx twoslash title="CubeTransition.tsx"+import { AbsoluteFill } from "remotion";++const Letter: React.FC<{+ children: React.ReactNode;+ color: string;+}> = ({ children, color }) => {+ return (+ <AbsoluteFill+ style={{+ backgroundColor: color,+ opacity: 0.9,+ justifyContent: "center",+ alignItems: "center",+ fontSize: 200,+ color: "white",+ }}+ >+ {children}+ </AbsoluteFill>+ );+};+// ---cut---+import { linearTiming, TransitionSeries } from "@remotion/transitions";+import { cube } from "@remotion-dev/cube-presentation";++const BasicTransition = () => {+ return (+ <TransitionSeries>+ <TransitionSeries.Sequence durationInFrames={40}>+ <Letter color="#0b84f3">A</Letter>+ </TransitionSeries.Sequence>+ <TransitionSeries.Transition+ presentation={cube({ direction: "from-left" })}+ timing={linearTiming({ durationInFrames: 30 })}+ />+ <TransitionSeries.Sequence durationInFrames={60}>+ <Letter color="pink">B</Letter>+ </TransitionSeries.Sequence>+ </TransitionSeries>+ );+};+```++## API++The `cube()` function does take an object with the following properties:++### `direction`++One of `from-left`, `from-right`, `from-top`, `from-bottom`.++```tsx twoslash+import { CubeDirection } from "@remotion-dev/cube-presentation";++const flipDirection: CubeDirection = "from-left";+```++### `perspective?`++The CSS `perspective` of the flip animation. Defaults to `1000`.++## See also++- [Presentations](/docs/transitions/presentations)diff --git a/packages/docs/package.json b/packages/docs/package.jsonindex b8b5e779f0..a272716241 100644--- a/packages/docs/package.json+++ b/packages/docs/package.json@@ -28,6 +28,7 @@"@docusaurus/types": "2.4.1","@jonny/eslint-config": "3.0.276","@mdx-js/react": "^1.6.21",+ "@remotion-dev/cube-presentation": "https://www.remotion.pro/pkg/cube-transition/1.0.1/docs","@remotion/babel-loader": "workspace:*","@remotion/bundler": "workspace:*","@remotion/cli": "workspace:*",@@ -35,6 +36,7 @@"@remotion/gif": "workspace:*","@remotion/google-fonts": "workspace:*","@remotion/lambda": "workspace:*",+ "@remotion/layout-utils": "workspace:*","@remotion/lottie": "workspace:*","@remotion/media-utils": "workspace:*","@remotion/motion-blur": "workspace:*",@@ -47,9 +49,8 @@"@remotion/shapes": "workspace:*","@remotion/skia": "workspace:*","@remotion/tailwind": "workspace:*",- "@remotion/transitions": "workspace:*","@remotion/three": "workspace:*",- "@remotion/layout-utils": "workspace:*",+ "@remotion/transitions": "workspace:*","@rive-app/canvas-advanced": "2.3.0","@shopify/react-native-skia": "^0.1.191","@swc/core": "^1.3.80",diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 401e1c8a93..afbb58cfc9 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -434,6 +434,7 @@ module.exports = {"transitions/presentations/wipe","transitions/presentations/flip","transitions/presentations/clock-wipe",+ "transitions/presentations/cube","transitions/presentations/custom","transitions/audio-transitions",],diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex b7bb0ee287..5ff9698915 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -2577,6 +2577,13 @@ export const articles = [compId: "articles-docs-transitions-presentations-clock-wipe",crumb: "@remotion/transitions - Presentations",},+ {+ id: "transitions/presentations/cube",+ title: "cube()",+ relativePath: "docs/transitions/presentations/cube.mdx",+ compId: "articles-docs-transitions-presentations-cube",+ crumb: "@remotion/transitions - Presentations",+ },{id: "transitions/presentations/custom",title: "Custom presentations",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3c8ddf6c55..e719fdd1dd 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -538,6 +538,9 @@ importers:'@mdx-js/react':specifier: ^1.6.21version: 1.6.22([email protected])+ '@remotion-dev/cube-presentation':+ specifier: https://www.remotion.pro/pkg/cube-transition/1.0.1/docs+ version: '@www.remotion.pro/pkg/cube-transition/1.0.1/docs(@remotion/transitions@packages+transitions)([email protected])(remotion@packages+core)''@remotion/babel-loader':specifier: workspace:*version: link:../babel-loader@@ -22553,3 +22556,18 @@ packages:resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}dev: false++ '@www.remotion.pro/pkg/cube-transition/1.0.1/docs(@remotion/transitions@packages+transitions)([email protected])(remotion@packages+core)':+ resolution: {tarball: https://www.remotion.pro/pkg/cube-transition/1.0.1/docs}+ id: '@www.remotion.pro/pkg/cube-transition/1.0.1/docs'+ name: '@remotion-dev/cube-presentation'+ version: 1.0.1+ peerDependencies:+ '@remotion/transitions': ^4.0.84+ react: ^18.2.0+ remotion: '*'+ dependencies:+ '@remotion/transitions': link:packages/transitions+ react: 18.2.0+ remotion: link:packages/core+ dev: false