[SOLVED] Changing HDRI/cubemap/skybox script

Hi everyone,

Is it possible to change the skybox in runtime? I have found ways of managing cubemaps but not for adding them to the sky. Do someone know how to do this?

Thank you a lot

Hi @practicas_imas,

You can set your skybox cubemaps at any point using the following method:

https://developer.playcanvas.com/api/pc.Scene.html#setSkybox

It’s available on the active scene:

this.app.scene.setSkybox(this.cubemap.resources);
1 Like

where is that ā€œthis.cubemap.resourcesā€ assigning an specific cubemap? it is

this.cubemap.resources.*NAMEOFTHECUBEMAP*

you have to assign it as an attribute? or is it another thing?

So this.cubemap is a cubemap asset and resources is the property you need to pass.

Yup, it worked

Thank you!

1 Like

This is not ā€œsolvedā€ and the linked project does not exist.
I have 6 skybox faces. How do I, using script only, create a ā€œcubemap resourceā€? pc.cubemap() does not exist. I’m unclear how to do this in code, can anyone please provide a working example?

see this example: PlayCanvas Examples

search for ā€˜loadFaces’ there. That should work for what you need.