@remotion/three 4.0.143 → 4.0.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +4 -0
- package/bundle.ts +23 -0
- package/dist/cjs/use-offthread-video-texture.d.ts +6 -0
- package/dist/cjs/use-offthread-video-texture.js +6 -0
- package/dist/esm/index.mjs +235 -184
- package/package.json +5 -7
- package/dist/esm/SuspenseLoader.d.ts +0 -4
- package/dist/esm/ThreeCanvas.d.ts +0 -12
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/use-offthread-video-texture.d.ts +0 -13
- package/dist/esm/use-video-texture.d.ts +0 -9
- package/dist/esm/validate.d.ts +0 -2
package/LICENSE.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Remotion License
|
|
2
2
|
|
|
3
|
+
In Remotion 5.0, the license will slightly change. [View the changes here](https://github.com/remotion-dev/remotion/pull/3750).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
3
7
|
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
|
|
4
8
|
|
|
5
9
|
- [Free license](#free-license)
|
package/bundle.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {build} from 'bun';
|
|
2
|
+
|
|
3
|
+
const output = await build({
|
|
4
|
+
entrypoints: ['src/index.ts'],
|
|
5
|
+
naming: '[name].mjs',
|
|
6
|
+
external: [
|
|
7
|
+
'react',
|
|
8
|
+
'remotion',
|
|
9
|
+
'@remotion/media-utils',
|
|
10
|
+
'remotion/no-react',
|
|
11
|
+
'react/jsx-runtime',
|
|
12
|
+
'@react-three/fiber',
|
|
13
|
+
'three/src/textures/VideoTexture.js',
|
|
14
|
+
'three/src/loaders/TextureLoader.js',
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const [file] = output.outputs;
|
|
19
|
+
const text = await file.text();
|
|
20
|
+
|
|
21
|
+
await Bun.write('dist/esm/index.mjs', text);
|
|
22
|
+
|
|
23
|
+
export {};
|
|
@@ -10,4 +10,10 @@ export declare const useInnerVideoTexture: ({ playbackRate, src, transparent, to
|
|
|
10
10
|
transparent: boolean;
|
|
11
11
|
toneMapped: boolean;
|
|
12
12
|
}) => import("three").Texture | null;
|
|
13
|
+
/**
|
|
14
|
+
* @description Allows you to use a video in React Three Fiber that is synchronized with Remotion's `useCurrentFrame()` using the `<OffthreadVideo>`.
|
|
15
|
+
* @see [Documentation](https://remotion.dev/docs/use-offthread-video-texture)
|
|
16
|
+
* @param {UseOffthreadVideoTextureOptions} options Configuration options including the video source (`src`), playback rate (`playbackRate`), transparency (`transparent`), and tone mapping (`toneMapped`).
|
|
17
|
+
* @returns {THREE.Texture | null} A THREE.Texture if available, otherwise null. To be used as a texture in 3D objects in React Three Fiber.
|
|
18
|
+
*/
|
|
13
19
|
export declare function useOffthreadVideoTexture({ src, playbackRate, transparent, toneMapped, }: UseOffthreadVideoTextureOptions): import("three").Texture | null;
|
|
@@ -82,6 +82,12 @@ const useInnerVideoTexture = ({ playbackRate, src, transparent, toneMapped, }) =
|
|
|
82
82
|
return imageTexture;
|
|
83
83
|
};
|
|
84
84
|
exports.useInnerVideoTexture = useInnerVideoTexture;
|
|
85
|
+
/**
|
|
86
|
+
* @description Allows you to use a video in React Three Fiber that is synchronized with Remotion's `useCurrentFrame()` using the `<OffthreadVideo>`.
|
|
87
|
+
* @see [Documentation](https://remotion.dev/docs/use-offthread-video-texture)
|
|
88
|
+
* @param {UseOffthreadVideoTextureOptions} options Configuration options including the video source (`src`), playback rate (`playbackRate`), transparency (`transparent`), and tone mapping (`toneMapped`).
|
|
89
|
+
* @returns {THREE.Texture | null} A THREE.Texture if available, otherwise null. To be used as a texture in 3D objects in React Three Fiber.
|
|
90
|
+
*/
|
|
85
91
|
function useOffthreadVideoTexture({ src, playbackRate = 1, transparent = false, toneMapped = true, }) {
|
|
86
92
|
if (!src) {
|
|
87
93
|
throw new Error('src must be provided to useOffthreadVideoTexture');
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,200 +1,251 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __require = ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
// src/ThreeCanvas.tsx
|
|
10
|
+
import {Canvas, useThree} from "@react-three/fiber";
|
|
11
|
+
import {useCallback, useLayoutEffect as useLayoutEffect2, useState} from "react";
|
|
12
|
+
import {Internals, continueRender as continueRender2, delayRender as delayRender2} from "remotion";
|
|
13
|
+
|
|
14
|
+
// src/SuspenseLoader.tsx
|
|
15
|
+
import {Suspense, useLayoutEffect} from "react";
|
|
16
|
+
import {continueRender, delayRender} from "remotion";
|
|
17
|
+
import {
|
|
18
|
+
jsxDEV
|
|
19
|
+
} from "react/jsx-dev-runtime";
|
|
20
|
+
var Unblocker = () => {
|
|
21
|
+
if (typeof document !== "undefined") {
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
const handle = delayRender(`Waiting for <Suspense /> of <ThreeCanvas /> to resolve`);
|
|
24
|
+
return () => {
|
|
25
|
+
continueRender(handle);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
18
30
|
};
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
var SuspenseLoader = ({ children }) => {
|
|
32
|
+
return jsxDEV(Suspense, {
|
|
33
|
+
fallback: jsxDEV(Unblocker, {}, undefined, false, undefined, this),
|
|
34
|
+
children
|
|
35
|
+
}, undefined, false, undefined, this);
|
|
21
36
|
};
|
|
22
37
|
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
// src/validate.ts
|
|
39
|
+
import {NoReactInternals} from "remotion/no-react";
|
|
40
|
+
var validateDimension = NoReactInternals.validateDimension;
|
|
25
41
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
// src/ThreeCanvas.tsx
|
|
43
|
+
import {
|
|
44
|
+
jsxDEV as jsxDEV2
|
|
45
|
+
} from "react/jsx-dev-runtime";
|
|
46
|
+
var Scale = ({
|
|
47
|
+
width,
|
|
48
|
+
height
|
|
49
|
+
}) => {
|
|
50
|
+
const { set, setSize: threeSetSize } = useThree();
|
|
51
|
+
const [setSize] = useState(() => threeSetSize);
|
|
52
|
+
useLayoutEffect2(() => {
|
|
53
|
+
setSize(width, height);
|
|
54
|
+
set({ setSize: () => null });
|
|
55
|
+
return () => set({ setSize });
|
|
56
|
+
}, [setSize, width, height, set]);
|
|
57
|
+
return null;
|
|
58
|
+
};
|
|
59
|
+
var ThreeCanvas = (props) => {
|
|
60
|
+
const { children, width, height, style, onCreated, ...rest } = props;
|
|
61
|
+
const [waitForCreated] = useState(() => delayRender2("Waiting for <ThreeCanvas/> to be created"));
|
|
62
|
+
validateDimension(width, "width", "of the <ThreeCanvas /> component");
|
|
63
|
+
validateDimension(height, "height", "of the <ThreeCanvas /> component");
|
|
64
|
+
const contexts = Internals.useRemotionContexts();
|
|
65
|
+
const actualStyle = {
|
|
66
|
+
width: props.width,
|
|
67
|
+
height: props.height,
|
|
68
|
+
...style ?? {}
|
|
69
|
+
};
|
|
70
|
+
const remotion_onCreated = useCallback((state) => {
|
|
71
|
+
continueRender2(waitForCreated);
|
|
72
|
+
onCreated?.(state);
|
|
73
|
+
}, [onCreated, waitForCreated]);
|
|
74
|
+
return jsxDEV2(SuspenseLoader, {
|
|
75
|
+
children: jsxDEV2(Canvas, {
|
|
76
|
+
style: actualStyle,
|
|
77
|
+
...rest,
|
|
78
|
+
onCreated: remotion_onCreated,
|
|
79
|
+
children: [
|
|
80
|
+
jsxDEV2(Scale, {
|
|
81
|
+
width,
|
|
82
|
+
height
|
|
83
|
+
}, undefined, false, undefined, this),
|
|
84
|
+
jsxDEV2(Internals.RemotionContextProvider, {
|
|
85
|
+
contexts,
|
|
86
|
+
children
|
|
87
|
+
}, undefined, false, undefined, this)
|
|
88
|
+
]
|
|
89
|
+
}, undefined, true, undefined, this)
|
|
90
|
+
}, undefined, false, undefined, this);
|
|
35
91
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
92
|
+
|
|
93
|
+
// src/use-offthread-video-texture.ts
|
|
94
|
+
import {useCallback as useCallback2, useLayoutEffect as useLayoutEffect3, useMemo, useState as useState2} from "react";
|
|
95
|
+
import {
|
|
96
|
+
Internals as Internals2,
|
|
97
|
+
cancelRender,
|
|
98
|
+
continueRender as continueRender3,
|
|
99
|
+
delayRender as delayRender3,
|
|
100
|
+
getRemotionEnvironment,
|
|
101
|
+
useCurrentFrame,
|
|
102
|
+
useVideoConfig
|
|
103
|
+
} from "remotion";
|
|
104
|
+
import {NoReactInternals as NoReactInternals2} from "remotion/no-react";
|
|
105
|
+
function useOffthreadVideoTexture({
|
|
106
|
+
src,
|
|
107
|
+
playbackRate = 1,
|
|
108
|
+
transparent = false,
|
|
109
|
+
toneMapped = true
|
|
110
|
+
}) {
|
|
111
|
+
if (!src) {
|
|
112
|
+
throw new Error("src must be provided to useOffthreadVideoTexture");
|
|
113
|
+
}
|
|
114
|
+
const { isRendering } = getRemotionEnvironment();
|
|
115
|
+
if (!isRendering) {
|
|
116
|
+
throw new Error("useOffthreadVideoTexture() can only be used during rendering. Use getRemotionEnvironment().isRendering to render it conditionally.");
|
|
117
|
+
}
|
|
118
|
+
return useInnerVideoTexture({ playbackRate, src, transparent, toneMapped });
|
|
119
|
+
}
|
|
120
|
+
var useInnerVideoTexture = ({
|
|
121
|
+
playbackRate,
|
|
122
|
+
src,
|
|
123
|
+
transparent,
|
|
124
|
+
toneMapped
|
|
125
|
+
}) => {
|
|
126
|
+
const frame = useCurrentFrame();
|
|
127
|
+
const { fps } = useVideoConfig();
|
|
128
|
+
const mediaStartsAt = Internals2.useMediaStartsAt();
|
|
129
|
+
const currentTime = useMemo(() => {
|
|
130
|
+
return NoReactInternals2.getExpectedMediaFrameUncorrected({
|
|
131
|
+
frame,
|
|
132
|
+
playbackRate,
|
|
133
|
+
startFrom: -mediaStartsAt
|
|
134
|
+
}) / fps;
|
|
135
|
+
}, [frame, playbackRate, mediaStartsAt, fps]);
|
|
136
|
+
const offthreadVideoFrameSrc = useMemo(() => {
|
|
137
|
+
return NoReactInternals2.getOffthreadVideoSource({
|
|
138
|
+
currentTime,
|
|
139
|
+
src,
|
|
140
|
+
transparent,
|
|
141
|
+
toneMapped
|
|
142
|
+
});
|
|
143
|
+
}, [toneMapped, currentTime, src, transparent]);
|
|
144
|
+
const [textLoaderPromise] = useState2(() => import("three/src/loaders/TextureLoader.js"));
|
|
145
|
+
const [imageTexture, setImageTexture] = useState2(null);
|
|
146
|
+
const fetchTexture = useCallback2(() => {
|
|
147
|
+
const imageTextureHandle = delayRender3("fetch offthread video frame");
|
|
148
|
+
let textureLoaded = null;
|
|
149
|
+
let cleanedUp = false;
|
|
150
|
+
textLoaderPromise.then((loader) => {
|
|
151
|
+
new loader.TextureLoader().loadAsync(offthreadVideoFrameSrc).then((texture) => {
|
|
152
|
+
textureLoaded = texture;
|
|
153
|
+
if (cleanedUp) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
setImageTexture(texture);
|
|
157
|
+
continueRender3(imageTextureHandle);
|
|
158
|
+
}).catch((err) => {
|
|
159
|
+
cancelRender(err);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
return () => {
|
|
163
|
+
cleanedUp = true;
|
|
164
|
+
textureLoaded?.dispose();
|
|
165
|
+
continueRender3(imageTextureHandle);
|
|
166
|
+
};
|
|
167
|
+
}, [offthreadVideoFrameSrc, textLoaderPromise]);
|
|
168
|
+
useLayoutEffect3(() => {
|
|
169
|
+
const cleanup = fetchTexture();
|
|
170
|
+
return () => {
|
|
171
|
+
cleanup();
|
|
50
172
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onCreated === null || onCreated === void 0 ? void 0 : onCreated(state);
|
|
54
|
-
}, [onCreated, waitForCreated]);
|
|
55
|
-
return (jsx(SuspenseLoader, { children: jsxs(Canvas, { style: actualStyle, ...rest, onCreated: remotion_onCreated, children: [jsx(Scale, { width: width, height: height }), jsx(Internals.RemotionContextProvider, { contexts: contexts, children: children })] }) }));
|
|
173
|
+
}, [offthreadVideoFrameSrc, fetchTexture]);
|
|
174
|
+
return imageTexture;
|
|
56
175
|
};
|
|
57
176
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, [frame, playbackRate, mediaStartsAt, fps]);
|
|
69
|
-
const offthreadVideoFrameSrc = useMemo(() => {
|
|
70
|
-
return NoReactInternals.getOffthreadVideoSource({
|
|
71
|
-
currentTime,
|
|
72
|
-
src,
|
|
73
|
-
transparent,
|
|
74
|
-
toneMapped,
|
|
75
|
-
});
|
|
76
|
-
}, [toneMapped, currentTime, src, transparent]);
|
|
77
|
-
const [textLoaderPromise] = useState(() => import('three/src/loaders/TextureLoader.js'));
|
|
78
|
-
const [imageTexture, setImageTexture] = useState(null);
|
|
79
|
-
const fetchTexture = useCallback(() => {
|
|
80
|
-
const imageTextureHandle = delayRender('fetch offthread video frame');
|
|
81
|
-
let textureLoaded = null;
|
|
82
|
-
let cleanedUp = false;
|
|
83
|
-
textLoaderPromise.then((loader) => {
|
|
84
|
-
new loader.TextureLoader()
|
|
85
|
-
.loadAsync(offthreadVideoFrameSrc)
|
|
86
|
-
.then((texture) => {
|
|
87
|
-
textureLoaded = texture;
|
|
88
|
-
if (cleanedUp) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
setImageTexture(texture);
|
|
92
|
-
continueRender(imageTextureHandle);
|
|
93
|
-
})
|
|
94
|
-
.catch((err) => {
|
|
95
|
-
cancelRender(err);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
return () => {
|
|
99
|
-
cleanedUp = true;
|
|
100
|
-
textureLoaded === null || textureLoaded === void 0 ? void 0 : textureLoaded.dispose();
|
|
101
|
-
continueRender(imageTextureHandle);
|
|
102
|
-
};
|
|
103
|
-
}, [offthreadVideoFrameSrc, textLoaderPromise]);
|
|
104
|
-
useLayoutEffect(() => {
|
|
105
|
-
const cleanup = fetchTexture();
|
|
106
|
-
return () => {
|
|
107
|
-
cleanup();
|
|
108
|
-
};
|
|
109
|
-
}, [offthreadVideoFrameSrc, fetchTexture]);
|
|
110
|
-
return imageTexture;
|
|
177
|
+
// src/use-video-texture.ts
|
|
178
|
+
import React3, {useCallback as useCallback3, useState as useState3} from "react";
|
|
179
|
+
import {continueRender as continueRender4, delayRender as delayRender4, useCurrentFrame as useCurrentFrame2} from "remotion";
|
|
180
|
+
var warned = false;
|
|
181
|
+
var warnAboutRequestVideoFrameCallback = () => {
|
|
182
|
+
if (warned) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
warned = true;
|
|
186
|
+
console.warn("Browser does not support requestVideoFrameCallback. Cannot display video.");
|
|
111
187
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
188
|
+
var useVideoTexture = (videoRef) => {
|
|
189
|
+
const [loaded] = useState3(() => {
|
|
190
|
+
if (typeof document === "undefined") {
|
|
191
|
+
return 0;
|
|
115
192
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
193
|
+
return delayRender4(`Waiting for texture in useVideoTexture() to be loaded`);
|
|
194
|
+
});
|
|
195
|
+
const [videoTexture, setVideoTexture] = useState3(null);
|
|
196
|
+
const [vidText] = useState3(() => import("three/src/textures/VideoTexture.js"));
|
|
197
|
+
const [error, setError] = useState3(null);
|
|
198
|
+
const frame = useCurrentFrame2();
|
|
199
|
+
if (error) {
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
const onReady = useCallback3(() => {
|
|
203
|
+
vidText.then(({ VideoTexture }) => {
|
|
204
|
+
if (!videoRef.current) {
|
|
205
|
+
throw new Error("Video not ready");
|
|
206
|
+
}
|
|
207
|
+
const vt = new VideoTexture(videoRef.current);
|
|
208
|
+
videoRef.current.width = videoRef.current.videoWidth;
|
|
209
|
+
videoRef.current.height = videoRef.current.videoHeight;
|
|
210
|
+
setVideoTexture(vt);
|
|
211
|
+
continueRender4(loaded);
|
|
212
|
+
}).catch((err) => {
|
|
213
|
+
setError(err);
|
|
214
|
+
});
|
|
215
|
+
}, [loaded, vidText, videoRef]);
|
|
216
|
+
React3.useEffect(() => {
|
|
217
|
+
if (!videoRef.current) {
|
|
218
|
+
return;
|
|
119
219
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
let warned = false;
|
|
124
|
-
const warnAboutRequestVideoFrameCallback = () => {
|
|
125
|
-
if (warned) {
|
|
126
|
-
return false;
|
|
220
|
+
if (videoRef.current.readyState >= 2) {
|
|
221
|
+
onReady();
|
|
222
|
+
return;
|
|
127
223
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const [loaded] = useState(() => {
|
|
137
|
-
if (typeof document === 'undefined') {
|
|
138
|
-
return 0;
|
|
139
|
-
}
|
|
140
|
-
return delayRender(`Waiting for texture in useVideoTexture() to be loaded`);
|
|
141
|
-
});
|
|
142
|
-
const [videoTexture, setVideoTexture] = useState(null);
|
|
143
|
-
const [vidText] = useState(() => import('three/src/textures/VideoTexture.js'));
|
|
144
|
-
const [error, setError] = useState(null);
|
|
145
|
-
const frame = useCurrentFrame();
|
|
146
|
-
if (error) {
|
|
147
|
-
throw error;
|
|
224
|
+
videoRef.current.addEventListener("loadeddata", () => {
|
|
225
|
+
onReady();
|
|
226
|
+
}, { once: true });
|
|
227
|
+
}, [loaded, onReady, videoRef]);
|
|
228
|
+
React3.useEffect(() => {
|
|
229
|
+
const { current } = videoRef;
|
|
230
|
+
if (!current) {
|
|
231
|
+
return;
|
|
148
232
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (!videoRef.current) {
|
|
153
|
-
throw new Error('Video not ready');
|
|
154
|
-
}
|
|
155
|
-
const vt = new VideoTexture(videoRef.current);
|
|
156
|
-
videoRef.current.width = videoRef.current.videoWidth;
|
|
157
|
-
videoRef.current.height = videoRef.current.videoHeight;
|
|
158
|
-
setVideoTexture(vt);
|
|
159
|
-
continueRender(loaded);
|
|
160
|
-
})
|
|
161
|
-
.catch((err) => {
|
|
162
|
-
setError(err);
|
|
163
|
-
});
|
|
164
|
-
}, [loaded, vidText, videoRef]);
|
|
165
|
-
React.useEffect(() => {
|
|
166
|
-
if (!videoRef.current) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (videoRef.current.readyState >= 2) {
|
|
170
|
-
onReady();
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
videoRef.current.addEventListener('loadeddata', () => {
|
|
174
|
-
onReady();
|
|
175
|
-
}, { once: true });
|
|
176
|
-
}, [loaded, onReady, videoRef]);
|
|
177
|
-
React.useEffect(() => {
|
|
178
|
-
const { current } = videoRef;
|
|
179
|
-
if (!current) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (!current.requestVideoFrameCallback) {
|
|
183
|
-
warnAboutRequestVideoFrameCallback();
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const ready = () => {
|
|
187
|
-
// Now force a new render so the latest video frame shows up in the canvas
|
|
188
|
-
// Allow remotion to continue
|
|
189
|
-
};
|
|
190
|
-
current.requestVideoFrameCallback(ready);
|
|
191
|
-
}, [frame, loaded, videoRef]);
|
|
192
|
-
if (typeof HTMLVideoElement === 'undefined' ||
|
|
193
|
-
!HTMLVideoElement.prototype.requestVideoFrameCallback) {
|
|
194
|
-
continueRender(loaded);
|
|
195
|
-
return null;
|
|
233
|
+
if (!current.requestVideoFrameCallback) {
|
|
234
|
+
warnAboutRequestVideoFrameCallback();
|
|
235
|
+
return;
|
|
196
236
|
}
|
|
197
|
-
|
|
237
|
+
const ready = () => {
|
|
238
|
+
};
|
|
239
|
+
current.requestVideoFrameCallback(ready);
|
|
240
|
+
}, [frame, loaded, videoRef]);
|
|
241
|
+
if (typeof HTMLVideoElement === "undefined" || !HTMLVideoElement.prototype.requestVideoFrameCallback) {
|
|
242
|
+
continueRender4(loaded);
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
return videoTexture;
|
|
246
|
+
};
|
|
247
|
+
export {
|
|
248
|
+
useVideoTexture,
|
|
249
|
+
useOffthreadVideoTexture,
|
|
250
|
+
ThreeCanvas
|
|
198
251
|
};
|
|
199
|
-
|
|
200
|
-
export { ThreeCanvas, useOffthreadVideoTexture, useVideoTexture };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/three",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.144",
|
|
4
4
|
"description": "Utility functions for using react-three-fiber with remotion",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -16,19 +16,18 @@
|
|
|
16
16
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"remotion": "4.0.
|
|
19
|
+
"remotion": "4.0.144"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@react-three/fiber": ">=8.0.0",
|
|
23
23
|
"react": ">=16.8.0",
|
|
24
24
|
"react-dom": ">=16.8.0",
|
|
25
25
|
"three": ">=0.137.0",
|
|
26
|
-
"remotion": "4.0.
|
|
26
|
+
"remotion": "4.0.144"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@jonny/eslint-config": "3.0.281",
|
|
30
30
|
"@react-three/fiber": "8.13.5",
|
|
31
|
-
"@rollup/plugin-typescript": "^8.2.0",
|
|
32
31
|
"@types/node": "18.14.6",
|
|
33
32
|
"@types/react": "18.2.48",
|
|
34
33
|
"@types/react-reconciler": "^0.26.4",
|
|
@@ -39,9 +38,8 @@
|
|
|
39
38
|
"prettier-plugin-organize-imports": "3.2.4",
|
|
40
39
|
"react": "18.2.0",
|
|
41
40
|
"react-dom": "18.2.0",
|
|
42
|
-
"rollup": "^2.70.1",
|
|
43
41
|
"three": "0.158.0",
|
|
44
|
-
"remotion": "4.0.
|
|
42
|
+
"remotion": "4.0.144"
|
|
45
43
|
},
|
|
46
44
|
"keywords": [
|
|
47
45
|
"remotion",
|
|
@@ -67,6 +65,6 @@
|
|
|
67
65
|
"formatting": "prettier src --check",
|
|
68
66
|
"lint": "eslint src --ext ts,tsx",
|
|
69
67
|
"watch": "tsc -w",
|
|
70
|
-
"build": "
|
|
68
|
+
"build": "bun bundle.ts && tsc -d"
|
|
71
69
|
}
|
|
72
70
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Canvas } from '@react-three/fiber';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export type ThreeCanvasProps = React.ComponentProps<typeof Canvas> & {
|
|
4
|
-
readonly width: number;
|
|
5
|
-
readonly height: number;
|
|
6
|
-
readonly children: React.ReactNode;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* @description A wrapper for React Three Fiber's <Canvas /> which synchronizes with Remotions useCurrentFrame().
|
|
10
|
-
* @see [Documentation](https://www.remotion.dev/docs/three-canvas)
|
|
11
|
-
*/
|
|
12
|
-
export declare const ThreeCanvas: (props: ThreeCanvasProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type UseOffthreadVideoTextureOptions = {
|
|
2
|
-
src: string;
|
|
3
|
-
playbackRate?: number;
|
|
4
|
-
transparent?: boolean;
|
|
5
|
-
toneMapped?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const useInnerVideoTexture: ({ playbackRate, src, transparent, toneMapped, }: {
|
|
8
|
-
playbackRate: number;
|
|
9
|
-
src: string;
|
|
10
|
-
transparent: boolean;
|
|
11
|
-
toneMapped: boolean;
|
|
12
|
-
}) => import("three").Texture | null;
|
|
13
|
-
export declare function useOffthreadVideoTexture({ src, playbackRate, transparent, toneMapped, }: UseOffthreadVideoTextureOptions): import("three").Texture | null;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Video } from 'remotion';
|
|
3
|
-
import type { VideoTexture } from 'three/src/textures/VideoTexture';
|
|
4
|
-
export type UseVideoTextureOptions = React.ComponentProps<typeof Video>;
|
|
5
|
-
/**
|
|
6
|
-
* @description Allows you to use a video in React Three Fiber that is synchronized with Remotion's useCurrentFrame().
|
|
7
|
-
* @see [Documentation](https://www.remotion.dev/docs/use-video-texture)
|
|
8
|
-
*/
|
|
9
|
-
export declare const useVideoTexture: (videoRef: React.RefObject<HTMLVideoElement>) => VideoTexture | null;
|
package/dist/esm/validate.d.ts
DELETED