How do I create a new layer in script?

…and if possible assign its order within the layer composition?

I tried unsuccessfully:
this.app.scene.layers.push("NewLayerTest");

Cheers

Hi @Grimmy,

Check this engine example, it showcases exactly that:

        // Create a new layer to put in front of everything
        const layer = new pc.Layer({
            name: "Front Layer",
        });

        // get the world layer index
        const worldLayer = app.scene.layers.getLayerByName("World");
        const idx = app.scene.layers.getTransparentIndex(worldLayer);

        // insert the new layer after the world layer
        app.scene.layers.insert(layer, idx + 1);

https://playcanvas.github.io/#/graphics/layers

Thanks. But does it create a transparent AND Opaque version of the layer? If so, how can I can modify the positions of each one in the array?

If it just creates either a transparent or opaque type layer, how can I specify this when creating the layer?
Something like this ???:

const layer = new pc.Layer({
            name: "CountedLayer", 
            type:opaque
        });

This is the variable/argument I need to access:
image

app.scene.layers is of LayerComposition type … see what APIs are available on it:
https://developer.playcanvas.com/en/api/pc.LayerComposition.html