I'm building a Next.js app that lets users design their own hoodies. One of the features is the addition of text.
For this, I'm using drei's <Text> component inside a <RenderTexture> (full code below).
At first glance it works as it should, but the text is also shown in a mirrored way on the back of the model (and it shimmers through on the sides when turning the model).
My code:
<Decal
position={[x, y, -0.1]}
rotation={[0, 0, 0]}
scale={[-1, 1, 1]}
>
<meshBasicMaterial
transparent
polygonOffset
polygonOffsetFactor={-100}
>
<RenderTexture attach='map' anisotropy={16}>
<PerspectiveCamera
makeDefault
aspect={1 / 1}
position={[0, 0, 1]}
/>
<Text
color={hex}
fontSize={0.01 * size}
font={`/fonts/${font}.ttf`}
>
{content}
</Text>
</RenderTexture>
</meshBasicMaterial>
</Decal>
I tried various ways to fix this, including:
- setting the
sideproperty on themeshBasicMaterial - tweaking the
polygonOffsetFactor - tweaking the
positionandrotation - setting up a variable to check when the backside is viewed and hide it
- setting up a second decal on the back to otherwise cover the area
- adjusting UV settings on the model (in
three, not in Blender)