Blender exporter Materials to PBRMaterials Typescript type conflict

Generics ??

That was my initial suggestion :slight_smile:

This would not change anything as the list contains a mix of materials. You will still need to cast at some points to filter. As this would force to duplicate the list or use generators not supported on every browsers there is nothing we should change on our side that i am aware of in ts if you do please make a PR so that we could discuss it.

I do not have time to make a pr and look at your code. Thats why Iā€™m reporting this to you. Im not a creator. Iā€™m a user of Babylon.

That will make me do a type check but not a type cast.

If you just want type checking, you know that this works already ?

for (let i = 0; i < scene.materials.length; i += 1) {
  const m = scene.materials[i];
  if (m instanceof PBRMaterial) {
    m.ambientColor = null;
  }
}

This would work in your case and is similar to the cast but through type inference it is just a syntax differenceā€¦ and does not change how the code runs.

The only diff is perf hence the proposal with getClassName() but it is all on your side and nothing to change in Babylon.

Seriously, you will have to be REALLY cautious with this kind of comment. Like REALLY REALLYā€¦

2 Likes

No he does not because he is not listeningā€¦