I'm new to R3F and I'm trying to learn some basic fundamentals, basically what I'm trying to do is render a car model from a .glb file and then render a circular button on the door of car which would trigger an click event.
However, I could not render the button no matter what I tried, I tried <mesh>, <Sprite/>, <Geometry/>, and the <Html/> tag from @react-fiber/drei. My requirements are:
- It must be a circle.
- It must have a fixed size, even after zooming in and out.
- It must be positioned correctly. For some reason, when I tried to position
<Sprite/>just by 5 pixels, It was moved significantly far from its original position. - Optionally, it must appear "in front" of other elements, kinda like having
z-index: 9999.
function ClickableSprite() {
return (
<>
<sprite
position={spritePosition}
ref={pulsingSpriteRef}
material={texture}
{...rest}
/>
<sprite position={spritePosition}
translateX={10} translateY={10} translateZ={10} {...rest}/>
<Html
onAfterRender={console.log}
position={spritePosition}
transform
occlude
// distanceFactor={10}
style={{
width: "10px",
height: "10px",
borderRadius: "50%",
background: "red",
}}
/>
</>
);
}