Non-StandardMaterial mesh cannot be clipped/picked

I got a big 3d model(.glb/.babylon) which contained around 100 nodes and 100 relative materials. I can check the whole model structure on sandbox scene explorer. Actually I want to realize 3 things as below

  1. Acquire the original material/texture rendering.
  2. every submesh can be clipplaned.
  3. every submesh can be picked/selected.

But seems calling ImportMesh without further process cannot make it happen. So I try the following original specified material. It works for 1) but not for 2) and 3).(materials[i] keep all 100 materials name I got from sandbox scene explorer)

SceneLoader.ImportMesh("", "/models/", "abc.babylon", scene,  (newMeshes) => {
  for (let i = 0; i < newMeshes.length; i++) {
    newMeshes[i].material = scene.getMaterialByName(materials[i]);
    }
  }

Then I also try the following code snippet to apply default/Standard Material. And now it works for 2) and 3) but not for 1). Meaning that the whole mesh not looks beautiful/real as I saw in sandbox. Something like white model.

SceneLoader.ImportMesh("", "/models/", "abc.babylon", scene,  (newMeshes) => {
  for (let i = 0; i < newMeshes.length; i++) {
    newMeshes[i].material = new StandardMaterial("derrickMaterial", scene);
    }
  }

Would you please help me for a way out? Thanks

Using a standard or a PBR material (which is what you get from a .gltf file) should not change anything regarding picking / clipping.

Are you able to setup a repro in the Playground so that we can have a better look?

3 Likes

Yes, @Evgeni_Popov you are right.
I just confirmed that the first and some of meshes have no material in glb/babylon so that newMeshes[i].material is null. At the same time I missed “try catch” block for which cause the running failed before clipping process.
Just removed the no-material parts can make it work. I will try to specify material to the parts later.

Thanks a lot

1 Like