pixi.js
    Preparing search index...

    Interface RenderLayerOptions

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

    // 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
    interface RenderLayerOptions {
        sortableChildren?: boolean;
        sortFunction?: (a: Container, b: Container) => number;
    }
    Index

    Properties

    sortableChildren?: boolean

    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.

    false
    
    const layer = new RenderLayer({
    sortableChildren: true // Automatically sorts children by zIndex
    });
    sortFunction?: (a: Container, b: Container) => number

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

    Type declaration

      • (a: Container, b: Container): number
      • Parameters

        Returns number

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

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