LogoPixi’VN
pixi-jsInterfaces

Interface: RenderLayerOptions

Defined in: node_modules/pixi.js/lib/scene/layers/RenderLayer.d.ts:39

Options for configuring a RenderLayer. A RenderLayer allows control over rendering order independent of the scene graph hierarchy.

Example

// Basic layer with automatic sorting
const layer = new RenderLayer({
    sortableChildren: true
});

// Layer with custom sort function
const customLayer = new RenderLayer({
    sortableChildren: true,
    sortFunction: (a, b) => {
        // Sort by y position
        return a.position.y - b.position.y;
    }
});

// Add objects to layer while maintaining scene graph parent
const sprite = new Sprite(texture);
container.addChild(sprite);      // Add to scene graph
layer.attach(sprite);            // Add to render layer

// Manual sorting when needed
const manualLayer = new RenderLayer({
    sortableChildren: false
});
manualLayer.attach(sprite1, sprite2);
manualLayer.sortRenderLayerChildren(); // Sort manually

Standard

Properties

sortableChildren?

> optional sortableChildren?: boolean

Defined in: node_modules/pixi.js/lib/scene/layers/RenderLayer.d.ts:54

If true, the layer's children will be sorted by zIndex before rendering. If false, you can manually sort the children using sortRenderLayerChildren when needed.

Default

false

Example

const layer = new RenderLayer({
    sortableChildren: true // Automatically sorts children by zIndex
});

See


sortFunction?

> optional sortFunction?: (a, b) => number

Defined in: node_modules/pixi.js/lib/scene/layers/RenderLayer.d.ts:74

Custom sort function to sort layer children. Default sorts by zIndex.

Parameters

a

Container

First container to compare

b

Container

Second container to compare

Returns

number

Negative if a should render before b, positive if b should render before a

Example

const layer = new RenderLayer({
    sortFunction: (a, b) => {
        // Sort by y position
        return a.position.y - b.position.y;
    }
});

See

Default

(a, b) => a.zIndex - b.zIndex