It seems that after using BABYLON.Mesh.MergeMeshes() the PBR material does not appear in the Inspector’s Scene Explorer, although they still exist in the merge objects (see the left panel):
Also, it can happen that these materials, after using BABYLON.Mesh.MergeMeshes() are not rendered; the objects using these materials will appear in black on the screen. For instance, I am in a situation where the materials are working on Chrome but not on Firefox:
Chrome:
Firefox:
However, before hand, I was in a situation where I had to merge more objects, and then I had the same “black object” issue in Chrome.
One important thing to note is that if you go in the material properties of one of the black objects in the inspector and change one of its PBR parameter (let’s say “roughness”), then the black objects are updated and rendered as they should be. Hence it seems to me that BabylonJS forgot about these materials and need the user to move a parameter to make BabylonJS aware of that material.
You can find a better history of the issue and details I gather in this thread:
(I thought it was best to open a new thread that focus on the black objects issue).
However, I don’t succeed to run my code because I don’t see how to disable all strict type-checking from TypeScript (the option "strict":true in tsconfig.json).
I need these checks to be disabled to use Nodes/Mesh/AbstractMesh/TransformNode easily
You can still cast them to any to avoid this issue
I want to keep the strictness on to help creating correct code
all the bjs code is compiled with all TS strict options on
Ok… but don’t you think that this is a shame that I can’t even write that:
scene.activeCamera = camera;
which leads to the error:
Type ‘ArcRotateCamera’ is not assignable to type ‘Camera’.
or that:
scene.activeCamera = <BABYLON.Camera> camera;
which leads to the error:
Conversion of type ‘ArcRotateCamera’ to type ‘Camera’ may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to ‘unknown’ first.
Property ‘_restoreStateValues’ is private in type ‘ArcRotateCamera’ but not in type ‘Camera’.
I think that the second “error” is especially annoying, as far as I know ArcRotateCamera should be a subclass of Camera and Typescript should take care of its own ass instead of blocking the execution of my code.
To convert to unknown first seems superfluous.
EDIT: Note also that BabylonJS does not allow us to do simple things like the following when TS is strict:
I think there is currently a problem with the Playground, as your first PG does not raise the “Promise” error in my local copy of Babylon / Playground.
Maybe someone in the Babylon team is currently working on the live Playground code?
Everything seems to work fine for now.
So I am not sure I understand why it works Maybe I should try to randomise which tile I instantiate (I only use one tile in this example), but I could not find a quick way to do it.
NOTE: that I still get this weird behaviour where the materials of my tiles do not appear in the inspector list of materials by the way.