Randomly set point on model's surface #2125
-
Hello, I am creating a React project and I want to add a 3D model that the user can interact with. Unfortunately, I cannot find the method to be applied in the Three Fiber documentation. Thank you for your time ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
I think your best bet is to do the mesh sampling imperatively in a It's pretty common to work imperatively when working with instanced meshes. Basically, you'd setup the mesh sampler by passing a reference to a mesh into it. Then, in useFrame or useEffect, adding/updating the meshes to the sampled points. You could generalize this to a component to reuse.
I'll see if I can squeeze in an example today. |
Beta Was this translation helpful? Give feedback.
I think your best bet is to do the mesh sampling imperatively in a
useEffect()
oruseMemo()
It's pretty common to work imperatively when working with instanced meshes.
Basically, you'd setup the mesh sampler by passing a reference to a mesh into it. Then, in useFrame or useEffect, adding/updating the meshes to the sampled points.
You could generalize this to a component to reuse.
I'll see if I can squeeze in an example today.