[SOLVED] Skymap is blurry after setting via script

Hey Guys,

i’m working on a project where a different skybox/cubemap needs to be set at scene load depending on player choices.
However the new map will always be blurry, even though mip is set to 1.

image

I reproduced this error in this mockup:
https://playcanvas.com/editor/scene/1404161

I reckon the error lies in the way i load my asset, but i just can’t figure it out.

var cubeMapAsset = this.cubeMaps[1];

var onAssetReady = function(asset) {

    // Show the entity when the material asset is loaded
    //console.log("cubemap ready");
    self.app.scene.setSkybox(asset.resources);

};

// Start async loading the material asset
cubeMapAsset.ready(onAssetReady);

self.app.assets.load(cubeMapAsset);

Thanks :slight_smile:

Wow @jvAW, coolest repro ever. Thanks so much! Taking a look now…

1 Like

Ahh yes this is an unfortunate quirk of the cubemap system.

Please add the following line after:

    cubeMapAsset.ready(onAssetReady);
    cubeMapAsset.loadFaces = true;        // set loadFaces flag, ugh
    self.app.assets.load(cubeMapAsset);

If you don’t set loadFaces flag on the asset it will refrain from loading them.

4 Likes

Thank you so much @slimbuck !
That’s a supringingly easy fix, works perfectly.
Glad you liked the repro :smiley:

1 Like