Skip to content

🎥 Make videos programmatically with React

three as well

Jonny Burger69a04749ceb0
diff --git a/packages/astro-example/package.json b/packages/astro-example/package.json
index f8b7f2ba3b..2f40776bb9 100644
--- a/packages/astro-example/package.json
+++ b/packages/astro-example/package.json
@@ -22,6 +22,7 @@
"remotion": "3.3.62",
"@remotion/lottie": "3.3.62",
"@remotion/motion-blur": "3.3.62",
+ "@remotion/three": "3.3.62",
"@remotion/gif": "3.3.62",
"@remotion/skia": "3.3.62"
}
diff --git a/packages/astro-example/test.cjs b/packages/astro-example/test.cjs
index c9d2726b1d..d913df68ea 100644
--- a/packages/astro-example/test.cjs
+++ b/packages/astro-example/test.cjs
@@ -6,6 +6,7 @@ const { enableSkia } = require("@remotion/skia/enable");
const { Lottie } = require("@remotion/lottie");
const { Gif } = require("@remotion/gif");
const { CameraMotionBlur } = require("@remotion/motion-blur");
+const { ThreeCanvas } = require("@remotion/three");
const val = interpolate(1, [0, 1], [0, 100]);
@@ -16,5 +17,6 @@ assert(Boolean(enableSkia));
assert(Boolean(Lottie));
assert(Boolean(Gif));
assert(Boolean(CameraMotionBlur));
+assert(Boolean(ThreeCanvas));
console.log("CommonJS works!");
diff --git a/packages/astro-example/test.js b/packages/astro-example/test.js
index 72eb2d10d7..da783bb459 100644
--- a/packages/astro-example/test.js
+++ b/packages/astro-example/test.js
@@ -6,6 +6,7 @@ const { enableSkia } = require("@remotion/skia/enable");
const { Lottie } = require("@remotion/lottie");
const { Gif } = require("@remotion/gif");
const { CameraMotionBlur } = require("@remotion/motion-blur");
+const { ThreeCanvas } = require("@remotion/three");
const val = interpolate(1, [0, 1], [0, 100]);
@@ -16,5 +17,6 @@ assert(Boolean(enableSkia));
assert(Boolean(Lottie));
assert(Boolean(Gif));
assert(Boolean(CameraMotionBlur));
+assert(Boolean(ThreeCanvas));
console.log("ESM Wallaby works!");
diff --git a/packages/astro-example/test.mjs b/packages/astro-example/test.mjs
index bdd8fef6e2..65a29cd626 100644
--- a/packages/astro-example/test.mjs
+++ b/packages/astro-example/test.mjs
@@ -5,6 +5,7 @@ import { VERSION } from "remotion/version";
import { enableSkia } from "@remotion/skia/enable";
import { Lottie } from "@remotion/lottie";
import { MotionBlur } from "@remotion/motion-blur";
+import { ThreeCanvas } from "@remotion/three";
import { Gif } from "@remotion/gif";
const val = interpolate(1, [0, 1], [0, 100]);
@@ -15,5 +16,6 @@ assert(typeof VERSION === "string");
assert(Boolean(enableSkia));
assert(Boolean(Lottie));
assert(Boolean(Gif));
+assert(Boolean(ThreeCanvas));
console.log("ESM works!");
diff --git a/packages/three/package.json b/packages/three/package.json
index 84341bcb92..c619c84202 100644
--- a/packages/three/package.json
+++ b/packages/three/package.json
@@ -2,13 +2,14 @@
"name": "@remotion/three",
"version": "3.3.62",
"description": "Utility functions for using react-three-fiber with remotion",
- "main": "dist/index.js",
- "types": "dist/index.d.ts",
+ "main": "dist/cjs/index.js",
+ "types": "dist/cjs/index.d.ts",
+ "module": "dist/esm/index.mjs",
"sideEffects": false,
"scripts": {
"lint": "eslint src --ext ts,tsx",
"watch": "tsc -w",
- "build": "tsc -d"
+ "build": "rollup --config rollup.config.js && tsc -d"
},
"author": "Björn Zeutzheim",
"contributors": [],
@@ -36,11 +37,13 @@
"@types/react-reconciler": "^0.26.4",
"@types/three": "^0.134.0",
"@types/web": "0.0.78",
+ "@rollup/plugin-typescript": "^8.2.0",
"eslint": "8.25.0",
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^2.3.4",
"react": "18.0.0",
"react-dom": "18.0.0",
+ "rollup": "^2.70.1",
"three": "^0.145.0",
"typescript": "^4.7.0"
},
diff --git a/packages/three/rollup.config.js b/packages/three/rollup.config.js
new file mode 100644
index 0000000000..1f52493997
--- /dev/null
+++ b/packages/three/rollup.config.js
@@ -0,0 +1,29 @@
+// rollup.config.js
+import typescript from '@rollup/plugin-typescript';
+
+export default [
+ {
+ input: 'src/index.ts',
+ output: [
+ {
+ file: 'dist/esm/index.mjs',
+ format: 'es',
+ sourcemap: false,
+ },
+ ],
+ external: [
+ 'react',
+ 'remotion',
+ 'react/jsx-runtime',
+ '@react-three/fiber',
+ 'three/src/textures/VideoTexture',
+ ],
+ plugins: [
+ typescript({
+ tsconfig: 'tsconfig-esm.json',
+ sourceMap: false,
+ outputToFilesystem: true,
+ }),
+ ],
+ },
+];
diff --git a/packages/three/tsconfig-esm.json b/packages/three/tsconfig-esm.json
new file mode 100644
index 0000000000..93ac160761
--- /dev/null
+++ b/packages/three/tsconfig-esm.json
@@ -0,0 +1,13 @@
+{
+ "extends": "../tsconfig-esm.settings.json",
+ "compilerOptions": {
+ "composite": true,
+ "rootDir": "./src",
+ "outDir": "./dist/esm",
+ "skipLibCheck": true,
+ "jsx": "react-jsx",
+ "moduleResolution": "node"
+ },
+ "references": [{"path": "../core"}],
+ "include": ["./src"]
+}
diff --git a/packages/three/tsconfig.json b/packages/three/tsconfig.json
index 9985243f83..e4b8aba3bc 100644
--- a/packages/three/tsconfig.json
+++ b/packages/three/tsconfig.json
@@ -3,7 +3,7 @@
"compilerOptions": {
"composite": true,
"rootDir": "src",
- "outDir": "dist",
+ "outDir": "./dist/cjs",
"skipLibCheck": true
},
"references": [
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9becf81369..2d5829c0c2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -21,6 +21,7 @@ importers:
'@remotion/motion-blur': 3.3.62
'@remotion/player': 3.3.62
'@remotion/skia': 3.3.62
+ '@remotion/three': 3.3.62
'@types/react': ^18.0.10
'@types/react-dom': ^18.0.5
astro: ^2.0.14
@@ -35,6 +36,7 @@ importers:
'@remotion/motion-blur': link:../motion-blur
'@remotion/player': link:../player
'@remotion/skia': link:../skia
+ '@remotion/three': link:../three
'@types/react': 18.0.26
'@types/react-dom': 18.0.10
astro: 2.0.14
@@ -1070,6 +1072,7 @@ importers:
specifiers:
'@jonny/eslint-config': 3.0.266
'@react-three/fiber': '>=8.0.0'
+ '@rollup/plugin-typescript': ^8.2.0
'@types/node': ^14.14.14
'@types/react': 18.0.26
'@types/react-reconciler': ^0.26.4
@@ -1081,6 +1084,7 @@ importers:
react: 18.0.0
react-dom: 18.0.0
remotion: 3.3.62
+ rollup: ^2.70.1
three: ^0.145.0
typescript: ^4.7.0
dependencies:
@@ -1088,6 +1092,7 @@ importers:
devDependencies:
'@jonny/eslint-config': 3.0.266_t54va6jeo5lf3vtqih5uiyrm5e
'@react-three/fiber': 8.8.10_u3n4asvhgbrwklmocjcudrf5be
+ '@rollup/plugin-typescript': 8.5.0_2s5nfqwcf62746iqzotp3mpuy4
'@types/node': 14.17.20
'@types/react': 18.0.26
'@types/react-reconciler': 0.26.4
@@ -1098,6 +1103,7 @@ importers:
prettier-plugin-organize-imports: 2.3.4_j2odc4yr77iddtreafyicbq5hi
react: 18.0.0
react-dom: [email protected]
+ rollup: 2.76.0
three: 0.145.0
typescript: 4.7.2