{"version":3,"file":"RenderContainer.mjs","sources":["../../../src/scene/container/RenderContainer.ts"],"sourcesContent":["import { ViewContainer } from '../view/ViewContainer';\n\nimport type { Point } from '../../maths/point/Point';\nimport type { Instruction } from '../../rendering/renderers/shared/instructions/Instruction';\nimport type { Renderer } from '../../rendering/renderers/types';\nimport type { Bounds, BoundsData } from './bounds/Bounds';\nimport type { ContainerOptions } from './Container';\n\n/**\n * A function that takes a renderer and does the custom rendering logic.\n * This is the function that will be called each frame.\n * @param renderer - The current renderer\n * @example\n * ```js\n * import { RenderContainer } from 'pixi.js';\n *\n * // create a new render container\n * const renderContainer = new RenderContainer((renderer) => {\n *     // custom render logic here\n *     renderer.clear({\n *         clearColor: 'green', // clear the screen to green when rendering this item\n *     });\n * });\n * ```\n * @category scene\n * @advanced\n */\nexport type RenderFunction = (renderer: Renderer) => void;\n\n/**\n * Options for the {@link RenderContainer} constructor.\n * @category scene\n * @advanced\n * @noInheritDoc\n */\nexport interface RenderContainerOptions extends ContainerOptions\n{\n    /** the optional custom render function if you want to inject the function via the constructor */\n    render?: RenderFunction;\n    /** how to know if the custom render logic contains a point or not, used for interaction */\n    containsPoint?: (point: Point) => boolean;\n    /** how to add the bounds of this object when measuring */\n    addBounds?: (bounds: BoundsData) => void;\n}\n\n/**\n * A container that allows for custom rendering logic. Its essentially calls the render function each frame\n * and allows for custom rendering logic - the render could be a WebGL renderer or WebGPU render or even a canvas render.\n * Its up to you to define the logic.\n *\n * This can be used in two ways, either by extending the class and overriding the render method,\n * or by passing a custom render function\n * @example\n * ```js\n * import { RenderContainer } from 'pixi.js';\n *\n * // extend the class\n * class MyRenderContainer extends RenderContainer\n * {\n *    render(renderer)\n *    {\n *      renderer.clear({\n *         clearColor: 'green', // clear the screen to green when rendering this item\n *      });\n *   }\n * }\n *\n * // override the render method\n * const renderContainer = new RenderContainer(\n * (renderer) =>  {\n *     renderer.clear({\n *       clearColor: 'green', // clear the screen to green when rendering this item\n *     });\n * })\n * ```\n * @category scene\n * @advanced\n */\nexport class RenderContainer extends ViewContainer implements Instruction\n{\n    /** @internal */\n    public override readonly renderPipeId: string = 'customRender';\n    /** @internal */\n    public batched = false;\n\n    /**\n     * Adds the bounds of this text to the bounds object.\n     * @param bounds - The output bounds object.\n     */\n    public addBounds: (bounds: Bounds) => void;\n\n    /**\n     * @param options - The options for the container.\n     */\n    constructor(options: RenderContainerOptions | RenderFunction)\n    {\n        if (typeof options === 'function')\n        {\n            options = { render: options };\n        }\n\n        const { render, ...rest } = options;\n\n        super({\n            label: 'RenderContainer',\n            ...rest,\n        });\n\n        if (render) this.render = render;\n\n        this.containsPoint = options.containsPoint ?? (() => false);\n        this.addBounds = options.addBounds ?? (() => false);\n    }\n\n    /** @private */\n    protected updateBounds(): void\n    {\n        // NOTE: this is for backwards compatibility with the old bounds system\n        this._bounds.clear();\n        this.addBounds(this._bounds);\n    }\n\n    /**\n     * An overridable function that can be used to render the object using the current renderer.\n     * @param _renderer - The current renderer\n     */\n    public render(_renderer: Renderer): void\n    {\n        // override me!\n    }\n}\n"],"names":[],"mappings":";;;AA8EO,MAAM,wBAAwB,aAAA,CACrC;AAAA;AAAA;AAAA;AAAA,EAeI,YAAY,OAAA,EACZ;AACI,IAAA,IAAI,OAAO,YAAY,UAAA,EACvB;AACI,MAAA,OAAA,GAAU,EAAE,QAAQ,OAAA,EAAQ;AAAA,IAChC;AAEA,IAAA,MAAM,EAAE,MAAA,EAAQ,GAAG,IAAA,EAAK,GAAI,OAAA;AAE5B,IAAA,KAAA,CAAM;AAAA,MACF,KAAA,EAAO,iBAAA;AAAA,MACP,GAAG;AAAA,KACN,CAAA;AAzBL;AAAA,IAAA,IAAA,CAAyB,YAAA,GAAuB,cAAA;AAEhD;AAAA,IAAA,IAAA,CAAO,OAAA,GAAU,KAAA;AAyBb,IAAA,IAAI,MAAA,OAAa,MAAA,GAAS,MAAA;AAE1B,IAAA,IAAA,CAAK,aAAA,GAAgB,OAAA,CAAQ,aAAA,KAAkB,MAAM,KAAA,CAAA;AACrD,IAAA,IAAA,CAAK,SAAA,GAAY,OAAA,CAAQ,SAAA,KAAc,MAAM,KAAA,CAAA;AAAA,EACjD;AAAA;AAAA,EAGU,YAAA,GACV;AAEI,IAAA,IAAA,CAAK,QAAQ,KAAA,EAAM;AACnB,IAAA,IAAA,CAAK,SAAA,CAAU,KAAK,OAAO,CAAA;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,OAAO,SAAA,EACd;AAAA,EAEA;AACJ;;;;"}