Cull
class Cull
Provides a simple, configurable mechanism for culling a subtree of your scene graph.
If your scene graph is not static, culling needs to be done before rendering. You
can run it on the prerender
event fired by the renderer.
Constructor
new Cull(options: Partial<ICullOptions>) → {}
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options | Partial<ICullOptions> | |||
options.recursive |
<optional> |
whether culling should be recursive |
||
options.toggle |
<optional> |
'renderable' |
which property of display-object was be set to indicate
its culling state. It should be one of |
Summary
Methods from Cull
this |
Adds a display-object to the culling list |
this |
Adds all the display-objects to the culling list |
this |
Clears the culling list |
this |
|
this |
Removes the display-object from the culling list |
this |
Removes all the passed display-objects from the culling list |
this |
Sets all display-objects to the unculled state. |
void |
Recursively culls the subtree of |
void |
Recursively unculls the subtree of |
Public Methods
add(target: PIXI.DisplayObject) → {this}
Adds a display-object to the culling list
Name | Type | Description |
---|---|---|
target | PIXI.DisplayObject |
the display-object to be culled |
Type | Description |
---|---|
this |
this |
addAll(targets: PIXI.DisplayObject[]) → {this}
Adds all the display-objects to the culling list
Name | Type | Description |
---|---|---|
targets | PIXI.DisplayObject[] |
the display-objects to be culled |
Type | Description |
---|---|
this |
this |
cull(rect: PIXI.Rectangle, skipUpdate: boolean) → {this}
Name | Type | Default | Description |
---|---|---|---|
rect | PIXI.Rectangle |
the rectangle outside of which display-objects should be culled |
|
skipUpdate | boolean | false |
whether to skip unculling, transform update, bounds calculation. It is highly recommended you enable this by calling this.uncull() and root.getBounds(false) manually before your render loop. |
Type | Description |
---|---|
this |
this |
remove(target: PIXI.DisplayObject) → {this}
Removes the display-object from the culling list
Name | Type | Description |
---|---|---|
target | PIXI.DisplayObject |
the display-object to be removed |
Type | Description |
---|---|
this |
this |
removeAll(targets: PIXI.DisplayObject[]) → {this}
Removes all the passed display-objects from the culling list
Name | Type | Description |
---|---|---|
targets | PIXI.DisplayObject[] |
the display-objects to be removed |
Type | Description |
---|---|
this |
this |
uncull() → {this}
Sets all display-objects to the unculled state.
This happens regardless of whether the culling toggle was set by this.cull
or manually. This
is why it is recommended to one of visible
or renderable
for normal use and the other for culling.
Type | Description |
---|---|
this |
this |
Protected Methods
protected cullRecursive(rect: PIXI.Rectangle, displayObject: PIXI.DisplayObject, skipUpdate: boolean) → {void}
Recursively culls the subtree of displayObject
.
Name | Type | Attributes | Description |
---|---|---|---|
rect | PIXI.Rectangle |
the visiblity rectangle |
|
displayObject | PIXI.DisplayObject |
the root of the subtree to cull |
|
skipUpdate | boolean |
<optional> |
whether to skip bounds calculation. However, transforms are expected to be updated by the caller. |
Type | Description |
---|---|
void |
protected uncullRecursive(displayObject: PIXI.DisplayObject) → {void}
Recursively unculls the subtree of displayObject
.
Name | Type | Description |
---|---|---|
displayObject | PIXI.DisplayObject |
Type | Description |
---|---|
void |