{"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\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\nexport function 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":";;;;;AAQgB,SAAA,kBAAA,CAAmB,IAAiB,EAAA,MAAA,EAAgB,SACpE,EAAA;AACI,EAAM,MAAA,YAAA,GAAe,WAAW,GAAI,EAAA,CAAA;AAEpC,EAAA,IAAA,CAAK,UAAa,GAAA,IAAA,CAAA;AAElB,EAAA,MAAM,UAAa,GAAA,UAAA,CAAW,GAAI,EAAA,CAAE,QAAS,EAAA,CAAA;AAE7C,EAAA,MAAM,YAAe,GAAA,yBAAA,CAA0B,IAAM,EAAA,SAAA,EAAW,UAAU,CAAA,CAAA;AAE1E,EAAe,cAAA,CAAA,IAAA,EAAM,cAAc,YAAY,CAAA,CAAA;AAE/C,EAAA,IAAA,CAAK,UAAa,GAAA,KAAA,CAAA;AAElB,EAAA,MAAA,CAAO,cAAc,YAAY,CAAA,CAAA;AAEjC,EAAA,UAAA,CAAW,OAAO,UAAU,CAAA,CAAA;AAC5B,EAAA,UAAA,CAAW,OAAO,YAAY,CAAA,CAAA;AAClC,CAAA;AAEgB,SAAA,yBAAA,CAA0B,MAAmB,EAAA,IAAA,EAAiB,MAC9E,EAAA;AACI,EAAA,IAAI,CAAC,MACL,EAAA;AAGI,IAAA,IAAA,CAAK,0DAA0D,CAAA,CAAA;AAG/D,IAAO,OAAA,MAAA,CAAA;AAAA,GACX;AAEA,EAAA,IAAI,WAAW,IACf,EAAA;AACI,IAA0B,yBAAA,CAAA,MAAA,CAAO,MAAQ,EAAA,IAAA,EAAM,MAAM,CAAA,CAAA;AAErD,IAAA,MAAA,CAAO,oBAAqB,EAAA,CAAA;AAE5B,IAAO,MAAA,CAAA,MAAA,CAAO,OAAO,cAAc,CAAA,CAAA;AAAA,GACvC;AAEA,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}