{"version":3,"file":"addMaskLocalBounds.mjs","sources":["../../../../src/rendering/mask/utils/addMaskLocalBounds.ts"],"sourcesContent":["import { getLocalBounds } from '../../../scene/container/bounds/getLocalBounds';\nimport { boundsPool, matrixPool } from '../../../scene/container/bounds/utils/matrixAndBoundsPool';\nimport { warn } from '../../../utils/logging/warn';\n\nimport type { Matrix } from '../../../maths/matrix/Matrix';\nimport type { Bounds } from '../../../scene/container/bounds/Bounds';\nimport type { Container } from '../../../scene/container/Container';\n\n/**\n * @param mask\n * @param bounds\n * @param localRoot\n * @internal\n */\nexport function addMaskLocalBounds(mask: Container, bounds: Bounds, localRoot: Container): void\n{\n    const boundsToMask = boundsPool.get();\n\n    mask.measurable = true;\n\n    const tempMatrix = matrixPool.get().identity();\n\n    const relativeMask = getMatrixRelativeToParent(mask, localRoot, tempMatrix);\n\n    getLocalBounds(mask, boundsToMask, relativeMask);\n\n    mask.measurable = false;\n\n    bounds.addBoundsMask(boundsToMask);\n\n    matrixPool.return(tempMatrix);\n    boundsPool.return(boundsToMask);\n}\n\nfunction getMatrixRelativeToParent(target: Container, root: Container, matrix: Matrix): Matrix\n{\n    if (!target)\n    {\n        // we have reach the top of the tree!\n        // #if _DEBUG\n        warn('Mask bounds, renderable is not inside the root container');\n        // #endif\n\n        return matrix;\n    }\n\n    if (target !== root)\n    {\n        getMatrixRelativeToParent(target.parent, root, matrix);\n\n        target.updateLocalTransform();\n\n        matrix.append(target.localTransform);\n    }\n\n    return matrix;\n}\n"],"names":[],"mappings":";;;;;AAcO,SAAS,kBAAA,CAAmB,IAAA,EAAiB,MAAA,EAAgB,SAAA,EACpE;AACI,EAAA,MAAM,YAAA,GAAe,WAAW,GAAA,EAAI;AAEpC,EAAA,IAAA,CAAK,UAAA,GAAa,IAAA;AAElB,EAAA,MAAM,UAAA,GAAa,UAAA,CAAW,GAAA,EAAI,CAAE,QAAA,EAAS;AAE7C,EAAA,MAAM,YAAA,GAAe,yBAAA,CAA0B,IAAA,EAAM,SAAA,EAAW,UAAU,CAAA;AAE1E,EAAA,cAAA,CAAe,IAAA,EAAM,cAAc,YAAY,CAAA;AAE/C,EAAA,IAAA,CAAK,UAAA,GAAa,KAAA;AAElB,EAAA,MAAA,CAAO,cAAc,YAAY,CAAA;AAEjC,EAAA,UAAA,CAAW,OAAO,UAAU,CAAA;AAC5B,EAAA,UAAA,CAAW,OAAO,YAAY,CAAA;AAClC;AAEA,SAAS,yBAAA,CAA0B,MAAA,EAAmB,IAAA,EAAiB,MAAA,EACvE;AACI,EAAA,IAAI,CAAC,MAAA,EACL;AAGI,IAAA,IAAA,CAAK,0DAA0D,CAAA;AAG/D,IAAA,OAAO,MAAA;AAAA,EACX;AAEA,EAAA,IAAI,WAAW,IAAA,EACf;AACI,IAAA,yBAAA,CAA0B,MAAA,CAAO,MAAA,EAAQ,IAAA,EAAM,MAAM,CAAA;AAErD,IAAA,MAAA,CAAO,oBAAA,EAAqB;AAE5B,IAAA,MAAA,CAAO,MAAA,CAAO,OAAO,cAAc,CAAA;AAAA,EACvC;AAEA,EAAA,OAAO,MAAA;AACX;;;;"}