How to load Environment settings with Scenes?

I’m setting up a multi scene system and can’t seem to figure out how to get the skybox and fog settings to load with the scene. Is this possible?

Original Post on Discord

by user 300386587278049291

Hello @BMAN have you had a look at the multi scene example in the samples? It doesnt switch fog but i think it also switches the skybox.

Its definitely possible (altough i haven’t tried with fog)

Yes that was the first place I looked…but that example is simply loading prefabs, not actual scenes…and no skybox change

by user 300386587278049291

heres an example for how to load scenes, it’s basically the same and you just tell the component compiler that you want to export SceneAssets instead of Prefabs. Script Examples | Needle Engine Documentation

You can also just reference a cubemap in any of your scripts and set it as the scene.background or environment

Thanks I did follow that for how to specify scene files, I was just hoping since it was a scene and not a prefab that it would load in the env things. Sounds like I’ll have to make a custom component that will store a cube map and fog settings for each scene?

by user 300386587278049291

Not really, when you export scenes they bring the cubemap / skybox with them (if you dont disable it) and fog settings should also be included (as said I havent tried that yet so let me know how it goes with the fog).

For a quick test add a camera with the MainCamera tag to an external scene that you load. It should switch to that camera when the scene has loaded and also apply the environment settings

Should I have the GLTF Object script on the sceneRoot in the external scene? I had to remove it to get the scene to load

by user 300386587278049291

No you dont need it if you reference and load it yourself

looking at my setup, the external scene does have a camera with MainCamera tag

by user 300386587278049291

I’ll try to do a simpler test

by user 300386587278049291

by user 300386587278049291

by user 300386587278049291

I also tested with a new scene, default everything, it did not load the skybox

by user 300386587278049291

also when I log the scene asset, I don’t see environment data anywhere in the object

by user 300386587278049291

That data is in an extension in the glb json root. It’s not loaded as a threejs object (a GltfLoader extension takes care of that)

gotcha. When you said:

when you export scenes they bring the cubemap / skybox with them (if you dont disable it)
how would I even disable it?

by user 300386587278049291

using this toggle
image.png

ok but that’s why I asked earlier if I need the GLTF Object script, you said not to include it on the external scene?

by user 300386587278049291

I mean you wouldnt need it, only if you want to disable exporting the skybox with the scene