I create a cubemap in the editor, how can I load it in the engine?

I create a cubemap in the editor, and I download the file into my project .
how can I load it in the engine ?
and how to set it as skybox ?

I saw the issue in the github : Support loading cubemap json · Issue #317 · playcanvas/engine · GitHub
when will it be fixed , or do I have any way to load a skybox in the engine ?

In the engine, you can create assets for the textures:

  var data = {
    "name": "forest",
    "cubemap": "your cubemap",
    "textures": [
      "texture1.jpg",
      "texture2.jpg",
      "texture3.jpg",
      "texture4.jpg",
      "texture5.jpg",
      "texture6.jpg",
    ]
  };

var textures = data.textures.map(t => {
  var asset = new pc.Asset(t, 'texture',
    { url: t },
    { addressu: 'repeat', addressv : 'repeat' }
  );
  app.assets.add(asset);
  return asset.id;
});

var cubemap = new pc.Asset(data.name, 'cubemap',
    data.cubemap ? { url: data.cubemap } : null, 
    {
        anisotropy: 1,
        magFilter: 1,
        minFilter: 5,
        rgbm: true,
        textures: textures
    }
);

app.setSkybox(cubemap);
1 Like

thanks for you help

I tried this code , but it doesn’t work, without any error

thanks for your help , I want to use the cubemap in engine-only

I’ve tested on codepen, it works well.