On this sandbox, you can see turning planets:
The position of each one is updated from the parent component with :
useFrame(() => {
...
sphereApi.position.set(
radius * Math.cos((sphereX * 2 * Math.PI) / image.periode),
0,
radius * Math.sin((sphereX * 2 * Math.PI) / image.periode)
);
...
}
When a planet is hovered, I would like a other useFrame inside the final component to update a mesh. The mesh is a three drei component containing the name of the planet to look at the camera. This mesh follows the planet itself.
This seems to work but only once:
useFrame(({ gl, scene, camera }) => {
if (hoveredd && myMesh2.current && myMesh.current ) {
myMesh.current.parent.lookAt(0, camera.position[1], 0);
}
}, 1);
Can you look at what is going on ? I think there is competition betwenn useFrame even if the properties impacted are not the same. (or is there a problem with the lookAt function ?)
The two useFrame concerned are in the component Planet and TextPlanet where you can find the two codes shown above.
Thanks for your help.