StdBatchFactory

class StdBatchFactory

Factory for producing "standard" (based on state, geometry, & textures) batches of display-objects.

NOTE: Instead of "building" batches, this factory actually keeps the batches in a buffer so they can be accessed together at the end.

Shared Textures: If display-objects in the same batch use the same base-texture, then that base-texture is not uploaded twice. This allows for more better batch density when you use texture atlases (textures with same base-texture). This is one reason why textures are treated as "special" uniforms.

Constructor


new StdBatchFactory(renderer: BatchRenderer) → {}
Parameters:
Name Type Description
renderer BatchRenderer

Summary


Methods from StdBatchFactory

Array<object>
access()
void
build(batch: number)
boolean
put(targetObject: PIXI.DisplayObject, state: PIXI.State)

Puts the display-object into the current batch, if possible.

boolean
ready()
void
reset()

Clears the batch pool.

number
size()

Size of the batch pool built since last reset.

void
protected _buildBatch(batch: object)
object
protected _newBatch()
any
protected _nextBatch(geometryOffset: number)
boolean
protected _put(displayObject: PIXI.DisplayObject)

Public Properties


_batchBuffer StdBatchFactory.ts:27
_batchBuffer: Array<PIXI.DisplayObject>
_textureBuffer StdBatchFactory.ts:71
_textureBuffer: object
_textureCount StdBatchFactory.ts:53
_textureCount: number

Textures per display-object

_textureLimit StdBatchFactory.ts:65
_textureLimit: number

Max. no of textures per batch (should be <= texture units of GPU)

_textureProperty StdBatchFactory.ts:59
_textureProperty: string

Property in which textures are kept of display-objects

Protected Properties


_batchBuffer StdBatchFactory.ts:79
protected _batchBuffer

Display-objects in current batch

_batchCount StdBatchFactory.ts:92
protected _batchCount: number = 0

Number of batches created since last reset.

_batchPool StdBatchFactory.ts:85
protected _batchPool: Array

Pool to batch objects into which data is fed.

_renderer StdBatchFactory.ts:47
protected _renderer

Public Methods


access StdBatchFactory.ts:183
access() → {Array<object>}

Returns the built batch pool. The array returned may be larger than the pool itself.

Returns:
Type Description
Array<object>
build StdBatchFactory.ts:145
build(batch: number) → {void}

Creates the batch object and pushes it into the pool This also resets any state so that a new batch can be started again.

Parameters:
Name Type Description
batch number
Returns:
Type Description
void
put StdBatchFactory.ts:109
put(targetObject: PIXI.DisplayObject, state: PIXI.State) → {boolean}

Puts the display-object into the current batch, if possible.

Parameters:
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 "build" it.

ready StdBatchFactory.ts:166
ready() → {boolean}
Returns:
Type Description
boolean
  • whether this factory is ready to start a new batch from "start". If not, then the current batch must be built before starting a new one.
reset StdBatchFactory.ts:175
reset() → {void}

Clears the batch pool.

Returns:
Type Description
void
size StdBatchFactory.ts:194
size() → {number}

Size of the batch pool built since last reset.

Returns:
Type Description
number

Protected Methods


_buildBatch StdBatchFactory.ts:250
protected _buildBatch(batch: object) → {void}

Should add any information required to render the batch. If you override this, you must call super._buildBatch and clear any state.


 _buildBatch(batch: any): void
 {
      super._buildBatch(batch);
      batch.depth = this.generateDepth();

      // if applicable
      this.resetDepthGenerator();
 }
Parameters:
Name Type Description
batch object
Returns:
Type Description
void
_newBatch StdBatchFactory.ts:218
protected _newBatch() → {object}

 _newBatch(): CustomBatch
 {
      return new CustomBatch();
 }
Returns:
Type Description
object

a new batch

_nextBatch StdBatchFactory.ts:232
protected _nextBatch(geometryOffset: number) → {any}
Parameters:
Name Type Attributes Description
geometryOffset number

<optional>

Returns:
Type Description
any
_put StdBatchFactory.ts:202
protected _put(displayObject: PIXI.DisplayObject) → {boolean}

Should store any information from the display-object to be put into the batch.

Parameters:
Name Type Description
displayObject PIXI.DisplayObject
Returns:
Type Description
boolean
  • whether the display-object was "compatible" with other display-objects in the batch. If not, it should not have been added.

Powered by webdoc!