The use of envAtlas is to solve the following problem
There is an issue with HDR disappearing when embedding PlayCanvas through a webview on iOS
On the ios device, there is a problem with the envAtlas set when using webview to access, the car has no ambient light, and the default skyBox does not appear. Most of the time there is no problem, the probability of it happening is very low, but it happened. And there is no error.
Below is my code, which works fine
var LoadEnvAtlas = pc.createScript('loadEnvAtlas');
LoadEnvAtlas.attributes.add('envAsset',{type:"asset",assetType:"texture"});
LoadEnvAtlas.prototype.initialize = function() {
let url = this.envAsset.getFileUrl();
try{
url = url.replace(ASSET_PREFIX, "")
} catch{
url = url .substr(5);
}
const asset = new pc.Asset(
"helipad-env-atlas",
"texture",
{ url: url},
{ type: pc.TEXTURETYPE_RGBP }
);
asset.ready(()=>{
const res = asset.resource;
this.app.scene.envAtlas = res;
})
this.app.assets.add(asset);
this.app.assets.load(asset);
};