Static
sharedA shared instance of the Culler class. Provides a global culler instance for convenience.
// Use the shared instance instead of creating a new one
Culler.shared.cull(stage, {
x: 0,
y: 0,
width: 800,
height: 600
});
CullerPlugin For automatic culling using this instance
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.
The container to cull. Must be a Container instance.
The view rectangle that defines the visible area
Whether to skip updating transforms for better performance
// 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);
The Culler class is responsible for managing and culling containers. Culling optimizes rendering performance by skipping objects outside the visible area.
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
See