PBR Materials not appearing in Inspector Material; and not being rendered

Hello!

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).

Summoning @sebavan

Anwered on PBR Material: how to make roughness work as in Blender 2.80?

Yep, now that I have some suspicion that it might come from the mergeMeshes() function, it is worth a try to repro in the playground to confirm.

I let you know how it goes.

So I am trying to start a repro here:
https://www.babylonjs-playground.com/#K6HZYE#6

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 :confused:

@Deltakosh is there a way to change the option "strict":true in tsconfig.json of the playground?

You can still cast them to any to avoid this issue
I want to keep the strictness on to help creating correct code :slight_smile:
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:

mesh.parent.position.x

It seems that I have now a new issue with the Playground:

Cannot find global value ‘Promise’.

See: https://www.babylonjs-playground.com/#K6HZYE#6
Not sure what it means, can’t we use Promise in the Playground?

I started a new Playground here; using only cubes instead of loading assets:
https://www.babylonjs-playground.com/#K6HZYE#9

But for some reason I get an error:

createScene function must return a scene.

While I do return a scene…
Is BabylonJS broken or is my brain broken? I never struggled so much with it :disappointed_relieved:

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?

I’m currently working on the TS side of the PG. I will be done soon and all the problem will be gone :slight_smile:

We recently migrated to the latest version of Monaco (the code editor) and this generates some issues

Stay tuned!

Ok now this ones has REAL errors: https://www.babylonjs-playground.com/#K6HZYE#6

And here we are for the second one: https://www.babylonjs-playground.com/#K6HZYE#10
(You cannot have global functions, you must hold them inside a class)

1 Like

Ok so here are my tests in the playground.

WARNING!! the link below are computationally heavy, as I am crash-testing the mergeMeshes() function.

With cubes and the textures I use:
https://www.babylonjs-playground.com/#K6HZYE#15

With the actual tiles and textures (wip):
https://www.babylonjs-playground.com/#K6HZYE#19

Everything seems to work fine for now.
So I am not sure I understand why it works :smiley: 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.