Change skybox and ground dynamically

Hi, I want to change skybox dynamically from the .hdr file . Is there any functionality in babylonjs?
Other thing that I want to dispose the skybox or may be set false in the viewer by javascript.

Also, I want to export the model from the scene, currently I’m using

    GLTF2Export.GLBAsync(viewer.sceneManager.scene, "scene").then(
                (glb) => {

but it’s giving me the whole scene including skybox and ground that I have set true in babylonjs viewer tag.
I just want to change the skybox and ground dynamically (or dispose in this case from the scene when it’s going to download/export the file).

Note: I don’t want to permanently off skybox and ground for babylonjs viewer.

Kindly help me in this regard
@RaananW @Deltakosh

As for the dynamic skybox change you may check this example Babylon.js sample code
It is just prototype but seems it answers your question.

Hi, @labris thanks for your time and quick response. But it’s viewer and inspector. where can I find functionality/code ? because I don’t know :smiley:

It is JS, you can write your own code to change:

	changeSkybox = function (path-to-hdr-file) {
    var hdrTexture = new BABYLON.CubeTexture(path-to-hdr-file, scene);
    scene.environmentTexture = hdrTexture;
    console.log("hdrTexture = " + hdrTexture); }
1 Like

Thanks for your help and what about to dispose it from the scene. because when I use scene.environmentTexture.dispose() it does not remove the skybox from the scene

Skybox is just a mesh. So you dispose like a mesh.

1 Like

Ooops yeah got it. So, first I have to get the skybox mesh with it’s name ? right?
Thanks a lot , I’m getting close :smiley: