BatchGeometryFactory
class BatchGeometryFactory extends IBatchGeometryFactory
Factory class that generates the geometry for a whole batch by feeding on the individual display-object geometries. This factory is reusable, i.e. you can build another geometry after a build call.
Optimizations: To speed up geometry generation, this compiles an optimized packing function that pushes attributes without looping through the attribute redirects.
Default Format: If you are not using a custom draw-call issuer, then the batch geometry must have an interleaved attribute data buffer and one index buffer.
Customization: If you want to customize the batch geometry, then you must also define your draw call issuer.
inBatchID Support: If you specified an inBatchID
attribute in the batch-renderer,
then this will support it automatically. The aggregate-uniforms pipeline doesn't need a custom
geometry factory.
Constructor
new BatchGeometryFactory(renderer: BatchRenderer) → {}
Name | Type | Description |
---|---|---|
renderer | BatchRenderer |
Summary
Properties from BatchGeometryFactory
PIXI.Geometry |
Batch geometries that can be reused. |
Resolvable<number> |
|
IGeometryMerger |
|
Methods from BatchGeometryFactory
void |
|
PIXI.Geometry |
|
void |
|
void |
|
PIXI.ViewableBuffer |
Allocates an attribute buffer with sufficient capacity to hold |
Uint16Array |
Allocates an index buffer ( |
Protected Properties
protected _geometryPool: PIXI.Geometry
Batch geometries that can be reused.
protected _indexCountProperty: Resolvable<number>
protected geometryMerger: IGeometryMerger
This lazy getter returns the geometry-merger function. This function takes one argument - the display-object to be appended to the batch - and pushes its geometry to the batch geometry.
You can overwrite this property with a custom geometry-merger function
if customizing BatchGeometryFactory
.
Public Methods
append(targetObject: PIXI.DisplayObject, batch_: any) → {void}
Append's the display-object geometry to this batch's geometry. You must override this you need to "modify" the geometry of the display-object before merging into the composite geometry (for example, adding an ID to a special uniform)
Name | Type | Description |
---|---|---|
targetObject | PIXI.DisplayObject | |
batch_ | any |
Type | Description |
---|---|
void |
build() → {PIXI.Geometry}
build(): PIXI.Geometry
{
// Make sure you're not allocating new geometries if _geometryPool has some
// already. (Otherwise, a memory leak will result!)
const geom: ExampleGeometry = (this._geometryPool.pop() || new ExampleGeometry(
// ...your arguments... //)) as ExampleGeometry;
// Put data into geometry's buffer
return geom;
}
Type | Description |
---|---|
PIXI.Geometry |
the generated batch geometry |
init(verticesBatched: number, indiciesBatched: number) → {void}
Ensures this factory has enough space to buffer the given number of vertices and indices. This should be called before feeding display-objects from the batch.
Name | Type | Attributes | Description |
---|---|---|---|
verticesBatched | number | ||
indiciesBatched | number |
<optional> |
Type | Description |
---|---|
void |
release(geom: PIXI.Geometry) → {void}
Name | Type | Description |
---|---|---|
geom | PIXI.Geometry |
releases back the geometry to be reused. It is expected that it is not used externally again. |
Type | Description |
---|---|
void |
Protected Methods
protected getAttributeBuffer(size: number) → {PIXI.ViewableBuffer}
Allocates an attribute buffer with sufficient capacity to hold size
elements.
Name | Type | Description |
---|---|---|
size | number |
Type | Description |
---|---|
PIXI.ViewableBuffer |
protected getIndexBuffer(size: number) → {Uint16Array}
Allocates an index buffer (Uint16Array
) with sufficient capacity to hold size
indices.
Name | Type | Description |
---|---|---|
size | number |
Type | Description |
---|---|
Uint16Array |