Class: BatchGenerator

.brend~BatchGenerator

Used to generate discrete groups/batches of display-objects that can be drawn together. It also keeps a parallel buffer of textures.

This class ensures that the WebGL states are equivalent and the texture count doesn't become greater than the no. of texture registers on the GPU. You can extend it and add constraints by overriding onPut.

WARNING: BatchRenderer does not support geometry packing with texture reduction disabled.

new BatchGenerator (textureIncrement, textureLimit, textureProperty, enableTextureReduction)

Name Type Default Description
textureIncrement number

textures per object

textureLimit number

no. of texture registers in GPU

textureProperty string

property where texture is kept

enableTextureReduction boolean true optional

whether same textures aren't counted multiple times. This reduces draw calls and can draw huge amounts of objects at the same time. For example, if 1000 objects use the same texture, then they can be drawn together. Further more if 1000 object use the same 8 textures randomly, then they can be drawn together. (provided other constraints like state are satisfied.)

Members

enableTextureReduction protected

Methods

finalize (batch)

Finalize this batch by getting its data into a Batch object.

Name Type Description
batch PIXI.brend.Batch

onPut (targetObject) protected

Overridable method that is called before an object is put into this batch. It should check compatibility with other objects, and return true/false accordingly.

Name Type Description
targetObject PIXI.DisplayObject

object being added

put (targetObject, state)boolean

Put an object into this batch.

Name Type Description
targetObject PIXI.DisplayObject

object to add

state PIXI.State

state required by that object

Returns:
Type Description
boolean whether the object was added to the batch. If it wasn't, you should finalize it.