Class: Batcher

Batcher

A batcher is used to batch together objects with the same texture. It is an abstract class that must be extended. see DefaultBatcher for an example.

Members

attributeBuffer ViewableBuffer

The buffer containing attribute data for all elements in the batch.

attributeSize number

The current size of the attribute data in the batch.

batches Batch[]

An array of all batches created during the current rendering process.

batchIndex number

The current index of the batch being processed.

Default Value:
  • 0

dirty boolean

Indicates whether the batch data has been modified and needs updating.

Default Value:
  • true

elementSize number

The total number of elements currently in the batch.

elementStart number

The starting index of elements in the current batch.

geometry Geometry

The geometry used by this batcher. Must be implemented by subclasses.

indexBuffer IndexBufferArray

The buffer containing index data for all elements in the batch.

indexSize number

The current size of the index data in the batch.

maxTextures number readonly

The maximum number of textures per batch.

name string

The name of the batcher. Must be implemented by subclasses.

shader Shader

The shader used by this batcher. Must be implemented by subclasses. this can be shared by multiple batchers of the same type.

uid number readonly

unique id for this batcher

vertexSize number protected

The vertex size of the batcher. Must be implemented by subclasses.

Methods

break (instructionSet)

breaks the batcher. This happens when a batch gets too big, or we need to switch to a different type of rendering (a filter for example)

Name Type Description
instructionSet InstructionSet

ensureAttributeBuffer (size)

Resizes the attribute buffer to the given size (1 = 1 float32)

Name Type Description
size number

the size in vertices to ensure (not bytes!)

ensureIndexBuffer (size)

Resizes the index buffer to the given size (1 = 1 float32)

Name Type Description
size number

the size in vertices to ensure (not bytes!)

packAttributes (element, float32View, uint32View, index, textureId) void abstract

Packs the attributes of a BatchableMeshElement into the provided views. Must be implemented by subclasses.

Name Type Description
element BatchableMeshElement

The BatchableMeshElement to pack.

float32View Float32Array

The Float32Array view to pack into.

uint32View Uint32Array

The Uint32Array view to pack into.

index number

The starting index in the views.

textureId number

The texture ID to use.

packQuadAttributes (element, float32View, uint32View, index, textureId) void abstract

Packs the attributes of a BatchableQuadElement into the provided views. Must be implemented by subclasses.

Name Type Description
element BatchableQuadElement

The BatchableQuadElement to pack.

float32View Float32Array

The Float32Array view to pack into.

uint32View Uint32Array

The Uint32Array view to pack into.

index number

The starting index in the views.

textureId number

The texture ID to use.