I'm trying to position sprites at the bottom center of the orthographic camera.
This is what I have currently -
The object:
function Obj() {
const texture = useLoader(THREE.TextureLoader, loadedimg);
const spriteRef = useRef();
return (
<group>
<sprite
position={[1, ???, 0]}
ref={spriteRef}
scale={[texture.image.width * 1.5, texture.image.height * 1.5, 1]}
>
<spriteMaterial
attach="material"
map={texture}
sizeAttenuation={false}
/>
</sprite>
</group>
);
}
The camera rendering:
<Canvas orthographic camera>
<Suspense fallback={<React.Fragment>loading...</React.Fragment>}>
<Obj />
</Suspense>
</Canvas
I've tried to come up with a calculation that could work for all different sprites (they all have different heights so for example one of them would be positioned at the bottom by setting position={[1, -128, 0]}
while for the other those coordinates would just leave it floating due to it being shorter in height). I looked at the documentation and the center
attribute for sprites doesn't seem to do what I'd like it to, all of the examples I've seen position it at the corners of the screen or right in the middle.
Thanks for your help !