can you give me the simplest transformInstance function to make the code below works ? I can’t succeed doing this.
Thanks
<Sampler
weight={"normal"} // the name of the attribute to be used as sampling weight
transform={transformInstance} // a function that transforms each instance given a sample. See the examples for more.
count={16} // Number of samples
>
<mesh>
<sphereGeometry args={[2]} />
</mesh>
<instancedMesh args={[null, null, 1_000]}>
<sphereGeometry args={[0.1]} />
</instancedMesh>
</Sampler>
<Sampler
weight={"normal"} // the name of the attribute to be used as sampling weight
transform={transformInstance} // a function that transforms each instance given a sample. See the examples for more.
count={count} // Number of samples
>
<mesh>
<sphereGeometry args={[1]} />
<meshStandardMaterial color="blue" wireframe />
</mesh>
I believe in general the <Sampler/> abstraction is designed to mount instances of one mesh on the surface of another mesh. not a collection of nodes on the surface of another collection of nodes. that’s how THREE.MeshSurfaceSampler works anyway, unless <Sampler /> adds something else to handle node subtrees.
like @donmccurdy said, the MeshSurfaceSampler operates on one single mesh. not a group, or a mesh inside an empty mesh (like in your example). a mesh in threejs has a geometry and a material, if it doesn’t it’s basically a group.
if you want to sample the whole model with all its parts you have to join and possibly bake materials into one in blender.