Hi
I have a scene. It have a few meshes. But the moment I call
const cubeTextureUrl = this._skyBoxConfig["cubeTextureUrl"];
if (!cubeTextureUrl) return;
const texture = new BABYLON.CubeTexture(cubeTextureUrl, this._scene, null, null, null, () => {
this._scene.render();
});
const skybox = this._scene.createDefaultSkybox(
texture,
this._skyBoxConfig["pbr"],
this._skyBoxConfig["scale"],
this._skyBoxConfig["blur"],
this._skyBoxConfig["setGlobalEnvTexture"]
);
and everything is hidden from the scene and I must press on the canvas with the mouse or resize the window for the scene to be redraw.
I have tried adding
() => {
this._scene.render();
});
as the final argument of the new BABYLON.CubeTexture but I seem the actual issue is with createDefaultSkybox.
What should I do after I call createDefautlSkybox for the meshes to appear again?
Thanks
Update 1
If I do
setTimeout(()=> {
this._scene.getEngine().resize();
this._scene.render();
}, 1000)
Then it works. I trigger the resize manually and the element is shown. But I guess there is something else I am missing.
Update 2:
This does not work
skybox.onAfterRenderObservable.addOnce(()=> {
this._scene.getEngine().resize();
this._scene.render();
})
The skybox still hides everything and the observer is not called event once.
Update 3:
This is what worked. I kind of understand why, but can’t I just call ‘this._scene.render()’
this._skyboxRenderLoopCounter = 0
this._skyboxRenderLoop = () => {
this._skyboxRenderLoopCounter++;
this._scene.render();
if(this._skyboxRenderLoop >= 1) {
this._scene.getEngine().stopRenderLoop(this._skyboxRenderLoop)
}
};
this._scene.getEngine().runRenderLoop(this._skyboxRenderLoop);