useModel
useModel is a variant of useAsset, that returns the nodes for the asset in
question. By using the Node component, we can attach event handlers to
individual nodes inside our asset.
const [nodes] = useModel({ id: 'uuid', refkey: 'my-model', configuration: {} });
const meshes = nodes.filter((n) => n.type === 'PolyMesh');
<Asset refkey="my-model">
{meshes.map(({ id, name }) => (
<Node key={id} id={id} onClick={() => console.log('Clicked', name)} />
))}
</Asset>;