@remotion/three 3.3.78 → 3.3.80
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/package.json +2 -2
- package/dist/SuspenseLoader.d.ts +0 -4
- package/dist/SuspenseLoader.js +0 -22
- package/dist/ThreeCanvas.d.ts +0 -12
- package/dist/ThreeCanvas.js +0 -40
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -7
- package/dist/use-video-texture.d.ts +0 -9
- package/dist/use-video-texture.js +0 -90
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/three",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.80",
|
|
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,7 +16,7 @@
|
|
|
16
16
|
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"remotion": "3.3.
|
|
19
|
+
"remotion": "3.3.80"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@react-three/fiber": ">=8.0.0",
|
package/dist/SuspenseLoader.d.ts
DELETED
package/dist/SuspenseLoader.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SuspenseLoader = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const remotion_1 = require("remotion");
|
|
7
|
-
const Unblocker = () => {
|
|
8
|
-
if (typeof document !== 'undefined') {
|
|
9
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
10
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
11
|
-
const handle = (0, remotion_1.delayRender)(`Waiting for <Suspense /> of <ThreeCanvas /> to resolve`);
|
|
12
|
-
return () => {
|
|
13
|
-
(0, remotion_1.continueRender)(handle);
|
|
14
|
-
};
|
|
15
|
-
}, []);
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
};
|
|
19
|
-
const SuspenseLoader = ({ children }) => {
|
|
20
|
-
return (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Unblocker, {}), children: children });
|
|
21
|
-
};
|
|
22
|
-
exports.SuspenseLoader = SuspenseLoader;
|
package/dist/ThreeCanvas.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Canvas } from '@react-three/fiber';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export declare type ThreeCanvasProps = React.ComponentProps<typeof Canvas> & {
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
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) => JSX.Element;
|
package/dist/ThreeCanvas.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThreeCanvas = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const fiber_1 = require("@react-three/fiber");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const remotion_1 = require("remotion");
|
|
8
|
-
const SuspenseLoader_1 = require("./SuspenseLoader");
|
|
9
|
-
const Scale = ({ width, height }) => {
|
|
10
|
-
const { set, setSize: threeSetSize } = (0, fiber_1.useThree)();
|
|
11
|
-
const [setSize] = (0, react_1.useState)(() => threeSetSize);
|
|
12
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
13
|
-
setSize(width, height);
|
|
14
|
-
set({ setSize: () => null });
|
|
15
|
-
return () => set({ setSize });
|
|
16
|
-
}, [setSize, width, height, set]);
|
|
17
|
-
return null;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* @description A wrapper for React Three Fiber's <Canvas /> which synchronizes with Remotions useCurrentFrame().
|
|
21
|
-
* @see [Documentation](https://www.remotion.dev/docs/three-canvas)
|
|
22
|
-
*/
|
|
23
|
-
const ThreeCanvas = (props) => {
|
|
24
|
-
const { children, width, height, style, onCreated, ...rest } = props;
|
|
25
|
-
const [waitForCreated] = (0, react_1.useState)(() => (0, remotion_1.delayRender)('Waiting for <ThreeCanvas/> to be created'));
|
|
26
|
-
remotion_1.Internals.validateDimension(width, 'width', 'of the <ThreeCanvas /> component');
|
|
27
|
-
remotion_1.Internals.validateDimension(height, 'height', 'of the <ThreeCanvas /> component');
|
|
28
|
-
const contexts = remotion_1.Internals.useRemotionContexts();
|
|
29
|
-
const actualStyle = {
|
|
30
|
-
width: props.width,
|
|
31
|
-
height: props.height,
|
|
32
|
-
...(style !== null && style !== void 0 ? style : {}),
|
|
33
|
-
};
|
|
34
|
-
const remotion_onCreated = (0, react_1.useCallback)((state) => {
|
|
35
|
-
(0, remotion_1.continueRender)(waitForCreated);
|
|
36
|
-
onCreated === null || onCreated === void 0 ? void 0 : onCreated(state);
|
|
37
|
-
}, [onCreated, waitForCreated]);
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)(SuspenseLoader_1.SuspenseLoader, { children: (0, jsx_runtime_1.jsxs)(fiber_1.Canvas, { style: actualStyle, ...rest, onCreated: remotion_onCreated, children: [(0, jsx_runtime_1.jsx)(Scale, { width: width, height: height }), (0, jsx_runtime_1.jsx)(remotion_1.Internals.RemotionContextProvider, { contexts: contexts, children: children })] }) }));
|
|
39
|
-
};
|
|
40
|
-
exports.ThreeCanvas = ThreeCanvas;
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useVideoTexture = exports.ThreeCanvas = void 0;
|
|
4
|
-
var ThreeCanvas_1 = require("./ThreeCanvas");
|
|
5
|
-
Object.defineProperty(exports, "ThreeCanvas", { enumerable: true, get: function () { return ThreeCanvas_1.ThreeCanvas; } });
|
|
6
|
-
var use_video_texture_1 = require("./use-video-texture");
|
|
7
|
-
Object.defineProperty(exports, "useVideoTexture", { enumerable: true, get: function () { return use_video_texture_1.useVideoTexture; } });
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Video } from 'remotion';
|
|
3
|
-
import { VideoTexture } from 'three/src/textures/VideoTexture';
|
|
4
|
-
export declare 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;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.useVideoTexture = void 0;
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
const remotion_1 = require("remotion");
|
|
29
|
-
const VideoTexture_1 = require("three/src/textures/VideoTexture");
|
|
30
|
-
let warned = false;
|
|
31
|
-
const warnAboutRequestVideoFrameCallback = () => {
|
|
32
|
-
if (warned) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
warned = true;
|
|
36
|
-
console.warn('Browser does not support requestVideoFrameCallback. Cannot display video.');
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* @description Allows you to use a video in React Three Fiber that is synchronized with Remotion's useCurrentFrame().
|
|
40
|
-
* @see [Documentation](https://www.remotion.dev/docs/use-video-texture)
|
|
41
|
-
*/
|
|
42
|
-
const useVideoTexture = (videoRef) => {
|
|
43
|
-
const [loaded] = (0, react_1.useState)(() => (0, remotion_1.delayRender)(`Waiting for texture in useVideoTexture() to be loaded`));
|
|
44
|
-
const [videoTexture, setVideoTexture] = (0, react_1.useState)(null);
|
|
45
|
-
const frame = (0, remotion_1.useCurrentFrame)();
|
|
46
|
-
const onReady = (0, react_1.useCallback)(() => {
|
|
47
|
-
if (!videoRef.current) {
|
|
48
|
-
throw new Error('Video not ready');
|
|
49
|
-
}
|
|
50
|
-
const vt = new VideoTexture_1.VideoTexture(videoRef.current);
|
|
51
|
-
videoRef.current.width = videoRef.current.videoWidth;
|
|
52
|
-
videoRef.current.height = videoRef.current.videoHeight;
|
|
53
|
-
setVideoTexture(vt);
|
|
54
|
-
(0, remotion_1.continueRender)(loaded);
|
|
55
|
-
}, [loaded, videoRef]);
|
|
56
|
-
react_1.default.useEffect(() => {
|
|
57
|
-
if (!videoRef.current) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (videoRef.current.readyState >= 2) {
|
|
61
|
-
onReady();
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
videoRef.current.addEventListener('loadeddata', () => {
|
|
65
|
-
onReady();
|
|
66
|
-
}, { once: true });
|
|
67
|
-
}, [loaded, onReady, videoRef]);
|
|
68
|
-
react_1.default.useEffect(() => {
|
|
69
|
-
const { current } = videoRef;
|
|
70
|
-
if (!current) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (!current.requestVideoFrameCallback) {
|
|
74
|
-
warnAboutRequestVideoFrameCallback();
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const ready = () => {
|
|
78
|
-
// Now force a new render so the latest video frame shows up in the canvas
|
|
79
|
-
// Allow remotion to continue
|
|
80
|
-
};
|
|
81
|
-
current.requestVideoFrameCallback(ready);
|
|
82
|
-
}, [frame, loaded, videoRef]);
|
|
83
|
-
if (typeof HTMLVideoElement === 'undefined' ||
|
|
84
|
-
!HTMLVideoElement.prototype.requestVideoFrameCallback) {
|
|
85
|
-
(0, remotion_1.continueRender)(loaded);
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
return videoTexture;
|
|
89
|
-
};
|
|
90
|
-
exports.useVideoTexture = useVideoTexture;
|