Skip to content

Commit

Permalink
fix(camera): zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
evandrododo committed Dec 10, 2023
1 parent cfea205 commit 793631a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/components/VideoPlane/VideoPlane.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useAspect } from "@react-three/drei";
import { Suspense } from "react";
import { Suspense, useEffect, useState } from "react";

Check failure on line 2 in src/components/VideoPlane/VideoPlane.tsx

View workflow job for this annotation

GitHub Actions / deploy

'useEffect' is declared but its value is never read.

Check failure on line 2 in src/components/VideoPlane/VideoPlane.tsx

View workflow job for this annotation

GitHub Actions / deploy

'useState' is declared but its value is never read.
import { FilterMaterialVideoChroma } from "../../materials/FilterMaterialVideoChroma";
import { FilterMaterialVideoEdge } from "../../materials/FilterMaterialVideoEdge";
import { useControls } from "leva";
Expand All @@ -18,8 +18,7 @@ export const VideoPlane = ({ userMedia }: { userMedia: MediaStream }) => {
const mediaAspect = mediaWidth / mediaHeight;
const size = useAspect(mediaAspect, 1);

console.log("size", size)


return (
<mesh scale={size} position={[0, 0, 0]}>
<planeGeometry />
Expand Down
13 changes: 12 additions & 1 deletion src/components/WebCamVideoPlane/WebCamVideoPlane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { VideoPlane } from "../VideoPlane/VideoPlane";

export const WebCamVideoPlane = () => {
const [userMedia, setUserMedia] = useState<MediaStream>();
const [renderizado, setRenderizado] = useState(false);

useEffect(() => {
const timeout = setTimeout(() => {
setRenderizado(true);
}, 100);

// Limpa o timeout para evitar execuções extras
return () => clearTimeout(timeout);
}, []);

// Gets user webcam
useEffect(() => {
navigator.mediaDevices
Expand Down Expand Up @@ -31,5 +42,5 @@ export const WebCamVideoPlane = () => {
if (!userMedia || !userMedia.getVideoTracks().length) {
return null;
}
return <VideoPlane userMedia={userMedia} />;
return <>{renderizado && <VideoPlane userMedia={userMedia} />};</>;
};

0 comments on commit 793631a

Please sign in to comment.