Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix culling not working with projection transforms #8844

Merged
merged 2 commits into from Nov 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions packages/display/src/Container.ts
@@ -1,9 +1,11 @@
import { MASK_TYPES, settings, utils } from '@pixi/core';
import { MASK_TYPES, Matrix, settings, utils } from '@pixi/core';
import { DisplayObject } from './DisplayObject';

import type { MaskData, Renderer, Matrix, Rectangle } from '@pixi/core';
import type { MaskData, Renderer, Rectangle } from '@pixi/core';
import type { IDestroyOptions } from './DisplayObject';

const tempMatrix = new Matrix();

function sortChildren(a: DisplayObject, b: DisplayObject): number
{
if (a.zIndex === b.zIndex)
Expand Down Expand Up @@ -561,6 +563,22 @@ export class Container<T extends DisplayObject = DisplayObject> extends DisplayO
bounds = this.getBounds(true);
}

// Prepend the transform that is appended to the projection matrix.
const projectionTransform = renderer.projection.transform;

if (projectionTransform)
{
if (transform)
{
transform = tempMatrix.copyFrom(transform);
transform.prepend(projectionTransform);
}
else
{
transform = projectionTransform;
}
}

// Render the container if the source frame intersects the bounds.
if (bounds && sourceFrame.intersects(bounds, transform))
{
Expand Down