Per Introduction to Physically Based Rendering | Babylon.js Documentation if I apply a simple PBRMetallicRoughnessMaterial to all the meshes in my model I get this weird error:
const mat = new PBRMetallicRoughnessMaterial( `${worktop.sku}_stainless`, scene );
worktopModel.getChildMeshes( true ).forEach( mesh => mesh.material = mat );
mat.baseColor = Color3.Red();
mat.metallic = 1;
mat.roughness = 1;
onSceneReady TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Mesh'
| property '_parentContainer' -> object with constructor 'AssetContainer'
| property 'meshes' -> object with constructor 'Array'
--- index 0 closes the circle
Funny thing is, the error stops if I simply dont assign this particular material to the mesh:
const mat = new PBRMetallicRoughnessMaterial( `${worktop.sku}_stainless`, scene );
worktopModel.getChildMeshes( true ).forEach( mesh => mesh.material = null );//mat );
mat.baseColor = Color3.Red();
mat.metallic = 1;
mat.roughness = 1;
… even though Ive defined the material exactly as the linked tutorial dictates.
It also throws no error if I instead use PBRMaterial:
const mat = new PBRMaterial( `${Math.random()}`, scene );
//const mat = new PBRMetallicRoughnessMaterial( `${worktop.sku}_stainless`, scene );
worktopModel.getChildMeshes( true ).forEach( mesh => mesh.material = mat );
//mat.baseColor = Color3.Red();
mat.metallic = 1;
mat.roughness = 1;
Why does PBRMetallicRoughnessMaterial hate me? Im just trying to get a simple stainless-steel-looking material, but even the simplest PBRMetallicRoughnessMaterial tutorial blows up on me.