I would like to control the scale, rotation of a Mesh (react component using R3F) from another component.
I made a codesandbox as follows:
Basically, when the user hits “Initialize button”, I would like the shape component (in this case, Sphere or Cube or Cylinder) to have a scale of [1,1,1] and rotation of [0, 0, 0] after the user have made all kind of changes to the shape. But I would like to keep the same position where the user have raycasted.
Any help would be much appreciated
PS: thanks drcmda for your valuable R3F examples !
i don’t think it’s generally a good idea to dig into the scene and mutate stuff outside of where you’re at, i would consider this an anti pattern. instead you change the state model by adding the position, and particular object xyz reacts to it. the rest of your sandbox works that way, why deviate.
Sorry to come back to this again,
I can’t find a way to update my transformation (scale and rotation) arrays in my state to capture the changes that the user has made to the “Shape” react component.
The purpose is to send this data (i.e. position, rotation and scale) to a database once the user hits the submit button.
Thanks for your help