How can I add the gltf model I imported to the reflection probe?

Hello. I imported a gltf model. I want to give the floor its reflection. I tried to do this with Reflection Probe but failed to reflect the gltf model.

my codes are like this

let groundMaterial = new BABYLON.StandardMaterial("Ground Material", scene);
    ground.material = groundMaterial;
    groundMaterial.roughness = 0;
    groundMaterial.metallic = 0;
...

var model = BABYLON.SceneLoader.Append("", "model.gltf", scene, function (container) {
        var meshes = container.meshes;    
});

var probe = new BABYLON.ReflectionProbe("main", 512, scene);
    probe.renderList.push(scene.getMeshByName("Plane004"));
    " " " "... and others.

    groundMaterial.reflectionTexture = probe.cubeTexture;
    groundMaterial.reflectionFresnelParameters = new BABYLON.FresnelParameters();
    groundMaterial.reflectionFresnelParameters.bias = 0.02;
    groundMaterial.realTimeFiltering = true;


how can i solve this problem?

Hi @fcozsargin and welcome to the community!

It would be helpful if you made a playground that shows the issue you are having.

But looking at your code above, the probe is being created and meshes likely added to the probe’s render list before the mesh has finished loading. At that point in time, there’s no mesh named "Plane004" to find yet. If you move the probe creation and mesh finding and adding to probe’s render list into the SceneLoader.Append() success callback, it should work. Something like …

BABYLON.SceneLoader.Append("", "model.gltf", scene, function (scene) {
  // Do something with the scene

  // Create reflection probe and add meshes to render list
  var probe = new BABYLON.ReflectionProbe("main", 512, scene);
  probe.renderList.push(scene.getMeshByName("Plane004"));
});
3 Likes