Coloring imported 3dm objects in react-three-fiber

Hello everyone! I`m a complete noob in react-three-fiber and three.js and I got stuck trying to color an imported rhino3dm object. Is there any way to do that?


Thanks in advance!

you do not need to wrap rhinodm into a mesh, that mesh will act as an empty group that’s all, it’s just this

function Model({ color, ...props }) {
  const scene = useLoader(.......)
  useLayoutEffect(() => {
    scene.traverse(child => {
      if (child.isMesh) {
        child.material.color.set(color)
      }
    })
  }, [color])
  return <primitive object={scene} {...props} />
}

...

<Model color="hotpink" position={[1, 2, 3]} scale={2} />

here’s an example Rhino3dmLoader in react-three-fiber (forked) - CodeSandbox

Thank you!