Skybox environment working locally but not remote

I have this strange issue. I’m replicating the sandbox environment i.e. loading a GLB then assigning an environment texture the the default skybox. It works fine locally but not remotely. Using the following code on a remote server, the GLB loads but the scene is totally dark and the only console error is “BJS - [09:53:36]: Unable to load from ./path/to/model.glb: Error in onSuccess callback

SceneLoader.Append("", "./path/to/model.glb", this._scene, () => {
    const envTexture = CubeTexture.CreateFromPrefilteredData("./path/to/environmentSpecular.env", this._scene);
    this._scene.environmentTexture = envTexture;
    this._scene.createDefaultSkybox(envTexture, true, (this._scene.activeCamera!.maxZ - this._scene.activeCamera!.minZ) / 2, 0.3, false);

In Chrome dev tools there are no resource load errors in the network tab.

Note also: If I don’t add the //@ts-ignore then the TS compiler complains "Property 'createDefaultSkybox' does not exist on type 'Scene'.ts(2339)"

If you are using ES6 packages you need to import the helpers to use createDefaultSkybox from Helpers/sceneHelpers

This would also explain your ignored warning :wink:


Thanks @sebavan

import "@babylonjs/core/Helpers/sceneHelpers";

That solved both problems - the warning and the remote deploy.

I’ve been tripped up by this sort of thing a few times as it works in a local dev environment but not built production files. If there are no meaningful errors and no TS auto importer for this sort of thing, is there anyway to determine what and when this is required? Is it documented anywhere when extra packages need to be pulled in?

We so have a section here ES6 - Babylon.js Documentation that tries to keep the most common ones and unfortunately it is impossible to automate without introducing lot of breaking changes.

1 Like