{"version":3,"file":"getRenderableBounds.js","sources":["../../../../src/scene/container/bounds/getRenderableBounds.ts"],"sourcesContent":["import { Matrix } from '../../../maths';\n\nimport type { Renderable } from '../../../rendering/renderers/shared/Renderable';\nimport type { Bounds } from './Bounds';\n\n/**\n * This matrix is used for calculations of the bounds for renderables placed inside cacheAsTexture render groups.\n * @ignore\n * @internal\n */\nconst tempProjectionMatrix: Matrix = new Matrix();\n\n/**\n * @param renderables\n * @param bounds\n * @internal\n */\nexport function getGlobalRenderableBounds(renderables: Renderable[], bounds: Bounds): Bounds\n{\n    bounds.clear();\n\n    // instead of copying the matrix each time we are assigning it in bounds\n    // this is a performance hack :D\n    // so we need to restore the matrix after we are done\n\n    const actualMatrix = bounds.matrix;\n\n    for (let i = 0; i < renderables.length; i++)\n    {\n        const renderable = renderables[i];\n\n        if (renderable.globalDisplayStatus < 0b111)\n        {\n            continue;\n        }\n\n        const renderGroup = renderable.renderGroup ?? renderable.parentRenderGroup;\n\n        if (renderGroup?.isCachedAsTexture)\n        {\n            bounds.matrix = tempProjectionMatrix.copyFrom(renderGroup.textureOffsetInverseTransform)\n                .append(renderable.worldTransform);\n        }\n        else if (renderGroup?._parentCacheAsTextureRenderGroup)\n        {\n            bounds.matrix = tempProjectionMatrix\n                .copyFrom(renderGroup._parentCacheAsTextureRenderGroup.inverseWorldTransform)\n                .append(renderable.groupTransform);\n        }\n        else\n        {\n            bounds.matrix = renderable.worldTransform;\n        }\n\n        bounds.addBounds(renderable.bounds);\n    }\n\n    bounds.matrix = actualMatrix;\n\n    return bounds;\n}\n"],"names":["Matrix"],"mappings":";;;;;;AAUA,MAAM,oBAAA,GAA+B,IAAIA,aAAO,EAAA,CAAA;AAOhC,SAAA,yBAAA,CAA0B,aAA2B,MACrE,EAAA;AACI,EAAA,MAAA,CAAO,KAAM,EAAA,CAAA;AAMb,EAAA,MAAM,eAAe,MAAO,CAAA,MAAA,CAAA;AAE5B,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,WAAA,CAAY,QAAQ,CACxC,EAAA,EAAA;AACI,IAAM,MAAA,UAAA,GAAa,YAAY,CAAC,CAAA,CAAA;AAEhC,IAAI,IAAA,UAAA,CAAW,sBAAsB,CACrC,EAAA;AACI,MAAA,SAAA;AAAA,KACJ;AAEA,IAAM,MAAA,WAAA,GAAc,UAAW,CAAA,WAAA,IAAe,UAAW,CAAA,iBAAA,CAAA;AAEzD,IAAA,IAAI,aAAa,iBACjB,EAAA;AACI,MAAO,MAAA,CAAA,MAAA,GAAS,qBAAqB,QAAS,CAAA,WAAA,CAAY,6BAA6B,CAClF,CAAA,MAAA,CAAO,WAAW,cAAc,CAAA,CAAA;AAAA,KACzC,MAAA,IACS,aAAa,gCACtB,EAAA;AACI,MAAO,MAAA,CAAA,MAAA,GAAS,qBACX,QAAS,CAAA,WAAA,CAAY,iCAAiC,qBAAqB,CAAA,CAC3E,MAAO,CAAA,UAAA,CAAW,cAAc,CAAA,CAAA;AAAA,KAGzC,MAAA;AACI,MAAA,MAAA,CAAO,SAAS,UAAW,CAAA,cAAA,CAAA;AAAA,KAC/B;AAEA,IAAO,MAAA,CAAA,SAAA,CAAU,WAAW,MAAM,CAAA,CAAA;AAAA,GACtC;AAEA,EAAA,MAAA,CAAO,MAAS,GAAA,YAAA,CAAA;AAEhB,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}