Skip to content

🎥 Make videos programmatically with React

`@remotion/three`: Deprecate `useVideoTexture()` and `useOffthreadVideoTexture()`

Jonny Burgera3393cc7fe89
diff --git a/packages/template-three/src/use-texture.ts b/packages/template-three/src/use-texture.ts
deleted file mode 100644
index b9857baa22..0000000000
--- a/packages/template-three/src/use-texture.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/* eslint-disable react-hooks/rules-of-hooks */
-import { useOffthreadVideoTexture, useVideoTexture } from "@remotion/three";
-import { useRemotionEnvironment } from "remotion";
-
-export const useTexture = (
- src: string,
- videoRef: React.RefObject<HTMLVideoElement | null>,
-) => {
- const env = useRemotionEnvironment();
- if (env.isRendering) {
- return useOffthreadVideoTexture({
- src,
- });
- }
-
- return useVideoTexture(videoRef);
-};
diff --git a/packages/three/src/index.ts b/packages/three/src/index.ts
index 08d8f05cc1..1253d92b5f 100644
--- a/packages/three/src/index.ts
+++ b/packages/three/src/index.ts
@@ -1,6 +1,31 @@
export {ThreeCanvas, ThreeCanvasProps} from './ThreeCanvas';
-export {
- UseOffthreadVideoTextureOptions,
- useOffthreadVideoTexture,
-} from './use-offthread-video-texture';
-export {UseVideoTextureOptions, useVideoTexture} from './use-video-texture';
+
+/**
+ * @deprecated useOffthreadVideoTexture has been deprecated.
+ * Use the approach documented at https://remotion.dev/docs/videos/as-threejs-texture instead.
+ */
+export type {UseOffthreadVideoTextureOptions} from './use-offthread-video-texture';
+/**
+ * @deprecated useOffthreadVideoTexture has been deprecated.
+ * Use the approach documented at https://remotion.dev/docs/videos/as-threejs-texture instead.
+ */
+export const useOffthreadVideoTexture = () => {
+ throw new Error(
+ 'useOffthreadVideoTexture has been deprecated. Please see https://remotion.dev/docs/videos/as-threejs-texture for alternatives.',
+ );
+};
+
+/**
+ * @deprecated useVideoTexture has been deprecated.
+ * Use the approach documented at https://remotion.dev/docs/videos/as-threejs-texture instead.
+ */
+export type {UseVideoTextureOptions} from './use-video-texture';
+/**
+ * @deprecated useVideoTexture has been deprecated.
+ * Use the approach documented at https://remotion.dev/docs/videos/as-threejs-texture for alternatives.
+ */
+export const useVideoTexture = () => {
+ throw new Error(
+ 'useVideoTexture has been deprecated. Please see https://remotion.dev/docs/videos/as-threejs-texture for alternatives.',
+ );
+};