I tried to set unique materials to a specific fragmentMesh. However, it turns out that the fragmentMesh can have multiple instances and thus the material is being applied to all its instances.
const raycaster = viewer.raycaster;
const intersect: Intersection | null =
raycaster.castRay([
...this.components.meshes,
]);
const obj3d = intersect.object;
regards
Apparently, the OBC.MaterialManager class from the library doesn't provide a way to set the material color for an individual instance. https://github.com/ThatOpen/engine_components/blob/main/src/core/MaterialManager/index.ts#L57
Indeed, the fragmentMesh extends from the instancedMesh class and the quick solution is to use the pure threejs library: sample here: https://github.com/mrdoob/three.js/blob/master/examples/webgl_instancing_raycast.html