Change default object material

Hi, I have a problem changing the material. I am loading some glb object with default material settings (physical material from 3ds max). But when I want to change this material, nothing happens. No error, unchanged material. Where can be the mistake?

var metal = new BABYLON.PBRMaterial(“metal”, scene);
var sphereMetal = null;

BABYLON.SceneLoader.ImportMesh("", “https://pedagogicka-stredni.cz/”, “test.glb”, scene, function (newMeshes) {

sphereMetal = newMeshes[0];

metal.directIntensity = 0.3;

metal.environmentIntensity = 0.7;

metal.cameraExposure = 0.55;

metal.cameraContrast = 1.6;

metal.microSurface = 0.96;

metal.reflectivityColor = new BABYLON.Color3(0.9, 0.9, 0.9);

metal.albedoColor = new BABYLON.Color3(1, 1, 1);

sphereMetal.material = metal;

sphereMetal.visibility = 1;

});

Hi,
newMeshes[0] is a wrapper mesh named “_ root _” created by babylonJs (to rescale all the meshes of the glb file to set the z axis properly) :
https://doc.babylonjs.com/resources/blender_to_gltf
So, your sphere is a child of this root mesh.

1 Like