# Class: Culler

The Culler class is responsible for managing and culling containers.
Culling optimizes rendering performance by skipping objects outside the visible area.

> [!IMPORTANT] culling is not always a golden bullet, it can be more expensive than rendering
> objects that are not visible, so it is best used in scenarios where you have many objects
> that are not visible at the same time, such as in large scenes or games with many sprites.

## Example

```ts
import { Culler, Container, Rectangle } from 'pixi.js';

// Create a culler and container
const culler = new Culler();
const stage = new Container();

// Set up container with culling
stage.cullable = true;
stage.cullArea = new Rectangle(0, 0, 800, 600);

// Add some sprites that will be culled
for (let i = 0; i < 1000; i++) {
    const sprite = Sprite.from('texture.png');
    sprite.x = Math.random() * 2000;
    sprite.y = Math.random() * 2000;
    sprite.cullable = true;
    stage.addChild(sprite);
}

// Cull objects outside view
culler.cull(stage, {
    x: 0,
    y: 0,
    width: 800,
    height: 600
});

// Only visible objects will be rendered
renderer.render(stage);
```

## See

 - [CullerPlugin](app.CullerPlugin.html.md) For automatic culling in applications
 - [CullingMixinConstructor](scene.CullingMixinConstructor.html.md) For culling properties

## Constructors

### Constructor

> **new Culler**(): `Culler`

#### Returns

`Culler`

## Properties

### shared

> `static` **shared**: `Culler`

A shared instance of the Culler class. Provides a global culler instance for convenience.

#### Example

```ts
// Use the shared instance instead of creating a new one
Culler.shared.cull(stage, {
    x: 0,
    y: 0,
    width: 800,
    height: 600
});
```

#### See

[CullerPlugin](app.CullerPlugin.html.md) For automatic culling using this instance

## Methods

### cull()

> **cull**(`container`, `view`, `skipUpdateTransform`): `void`

Culls the children of a specific container based on the given view rectangle.
This determines which objects should be rendered and which can be skipped.

#### Parameters

##### container

[`Container`](scene.Container.html.md)

The container to cull. Must be a Container instance.

##### view

[`RectangleLike`](utils.RectangleLike.html.md)

The view rectangle that defines the visible area

##### skipUpdateTransform

`boolean` = `true`

Whether to skip updating transforms for better performance

#### Returns

`void`

#### Example

```ts
// Basic culling with view bounds
const culler = new Culler();
culler.cull(stage, {
    x: 0,
    y: 0,
    width: 800,
    height: 600
});

// Culling to renderer screen
culler.cull(stage, renderer.screen, false);
```

#### Remarks

- Recursively processes all cullable children
- Uses cullArea if defined, otherwise calculates bounds
- Performance depends on scene complexity

#### See

 - [CullingMixinConstructor.cullable](scene.CullingMixinConstructor.html#cullable) For enabling culling on objects
 - [CullingMixinConstructor.cullArea](scene.CullingMixinConstructor.html#cullarea) For custom culling boundaries
