EnvironmentHelper not loading before AssetManager is finished!

Hi everyone,

I am using createDefaultEnvironment method and AssetManager in my scene.

I start with scene creation like this:

scene.lights[0].intensity = 1

const helper = scene.createDefaultEnvironment({
  skyboxSize: 1500,
  groundShadowLevel: 0.5,
  enableGroundMirror: true,
helper.setMainColor(new Color3(2.8, 2.8, 2.8));

engine.runRenderLoop(() => {

Only after this i create AssetManager, add some tasks and load them:

const assetsManager = new AssetsManager(scene);
assetsManager.useDefaultLoadingScreen = false;
this.meshesConfig.forEach(config => assetsManager.addMeshTask( ... )

assetsManager.onProgress = (remainingCount, totalCount) => this.props.onProgress(remainingCount, totalCount)

assetsManager.onFinish = () => this.props.onLoaded()


This is on purpose and I also use assetsManager.useDefaultLoadingScreen = false; because I want scene to start rendering and meshes to show up incrementally as they load.

The problem is, it seems that enviroment helper is loaded only after all meshes are loaded. Rendering starts because I can see the default bluish/purple color of babylon scene, but ground, skybox and mainColor that I set before are shown only after all meshes are in the scene.

Does anybody know why is that and how to fix it? I’ve been trying for some time…

Hello, we will need a repro in the playground to be able to help :slight_smile:

I created a playground with copy of my code… Only difference is I used skull mesh instead of mine, but it seems the problem doesnt persist in the playground. https://playground.babylonjs.com/#PC8XG0#5

Dont know where to look further…

Ok so it is either in your code or you are not using the 4.1rc9 maybe?

I realised what is the problem. It seems backgroundSkybox.dds and backgroundGround.png from createDefaultEnvironment take significantly more time to load than any of my meshes. Thats why environment shows up only after. All the time I thought that createDefaultEnvironment method is completely synchronous.

1 Like

@Deltakosh is it possible to not load backgroundGround.png and still retain mirror effect with createDefaultEnvironment ? because when i set groundTexture: undefined, image doesnt load from babylon CDN but i dont get ground mirror. I only need standard material on the ground + mirrorTexture, dont need any texture with images?.

What you can do is nullifying the groundMaterial.diffuseTexture afterwards: