Skip to content

Commit

Permalink
Merge pull request #3 from bien-pr/main
Browse files Browse the repository at this point in the history
Remove aspectRatio for performance
  • Loading branch information
tommasoturchi authored Nov 20, 2022
2 parents 3bc9537 + 7c27c1c commit f9c7818
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/AR.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,22 @@ const ARProvider = forwardRef(
}
}, [autoplay, ready, startTracking]);

const fixStyle = () => {
let offset = 0
if(webcamRef.current?.video?.clientWidth>0){
offset = (width - webcamRef.current.video.clientWidth) / 2;
}
offset = parseInt(offset+'')
return(
{
width: "auto",
maxWidth: "none",
height: 'inherit',
marginLeft: offset+'px'
}
)
}

return (
<>
<Html
Expand All @@ -267,8 +283,8 @@ const ARProvider = forwardRef(
width={width}
videoConstraints={{
facingMode: isWebcamFacingUser ? "user" : "environment",
aspectRatio: ratio,
}}
style={fixStyle()}
/>
</Html>
{children}
Expand Down

0 comments on commit f9c7818

Please sign in to comment.