SpriteBatch
Extends InstancedMesh
A spritebatch allows for easy, performant, z sorted and camera facing sprites
Constructors
SpriteBatch:newSpriteBatch(texture, emissionTexture, normalTexture)
Creates a new sprite batch
Arguments
texture (Texture) optional
emissionTexture (Texture) optional
normalTexture (Texture) optional
Methods
SpriteBatch:clear()
Clear the batch
SpriteBatch:add(x, y, z, rot, sx, sy, emission)
Add a new sprite to this batch, uses current color state
Arguments
x (number)
y (number)
z (number)
rot (number) rotation at the Z axis, 0 by default
sx (number) horizontal scale, default 1
sy (number) vertical scale, or sx
emission (number) optional emission factor, requires set emission texture
SpriteBatch:addQuad(quad, x, y, z, rot, sx, sy, emission)
Add a new sprite with given quad to this batch, uses current color state
Arguments
quad (Quad)
x (number)
y (number)
z (number)
rot (number) rotation at the Z axis, 0 by default
sx (number) horizontal scale, default 1
sy (number) vertical scale, or sx
emission (number) optional emission factor, requires set emission texture
SpriteBatch:set(index, x, y, z, rot, sx, sy, emission)
Sets an existing sprite
Arguments
index (any)
x (any)
y (any)
z (any)
rot (any)
sx (any)
sy (any)
emission (any)
SpriteBatch:setQuad(index, quad, x, y, z, rot, sx, sy, emission)
Sets an existing sprite
Arguments
index (any)
quad (any)
x (any)
y (any)
z (any)
rot (any)
sx (any)
sy (any)
emission (any)
SpriteBatch:resize(size)
Resizes the spritebatch, usually called automatically
Arguments
size (number)
SpriteBatch:setAlpha(enabled)
A helper function to set whether alpha mode (true) or cutout (false) should be used. The later one will disable sorting as it is not required.
Arguments
enabled (boolean)
SpriteBatch:setSorting(sorting)
Sorting only makes sense when alpha mode is enabled, and the texture is not single colored
Arguments
sorting (boolean)
SpriteBatch:getSorting()
Returns
(boolean)
SpriteBatch:setVertical(vertical)
A verticalness of 1 draws the sprites aligned to the Y coordinate, a value of 0 fully faces the camera
Arguments
vertical (number)
SpriteBatch:getVertical()
Gets the verticalness
Returns
(number)
InstancedMesh:getInstancesCount()
Returns the current amount of instances
Returns
(number)
InstancedMesh:clear()
Clear all instances
InstancedMesh:resize(count)
Resize the instanced mesh, preserving previous entries
Arguments
count (number)
InstancedMesh:addInstance(transform, index)
Add another instance
Arguments
transform (Mat4) a mat3x4 matrix, instances do not support shearing, e.g. the last row
index (number) Optional index, else it will append
InstancedMesh:setInstances(instances)
Place instances from an array of mat3x4 transformations, represented as a flat array (mat3 rotation, vec3 position, basically a transposed DreamMat4 with missing last row)
Arguments
instances (number[]) [][]
InstancedMesh:updateBoundingSphere()
Updates the bounding sphere from scratch, called internally when needed
InstancedMesh:extendBoundingSphere(instance)
Extend the bounding sphere by another instance, called internally
Arguments
instance (Mat4)
Mesh:setMaterial(material)
Sets the meshes material
Arguments
material (Material)
Mesh:getMaterial()
Returns
(Material)
Mesh:setVisible(visibility)
Arguments
visibility (boolean)
Mesh:setRenderVisibility(visibility)
Arguments
visibility (boolean)
Mesh:getRenderVisibility()
Mesh:setShadowVisibility(visibility)
Arguments
visibility (boolean)
Mesh:getShadowVisibility()
Mesh:setSkeleton(skeleton)
Arguments
skeleton (Skeleton)
Mesh:getSkeleton()
Mesh:getPixelShader()
Mesh:getVertexShader()
Mesh:getWorldShader()
Mesh:updateBoundingSphere()
Updates the bounding sphere based on mesh data
Mesh:cleanup()
Mesh:preload(force)
Load textures and similar
Arguments
force (boolean) Bypass threaded loading and immediately load things
Mesh:clearMesh()
Deletes the mesh, will regenerate next time needed
Mesh:getMesh(name)
Get a mesh, load automatically if required
Arguments
name (string) optional, default “mesh”
Mesh:applyTransform(transform)
Apply a transformation matrix to all vertices
Arguments
transform (Mat4)
Mesh:applyBones(skeleton)
Apply joints to mesh data directly
Arguments
skeleton (Skeleton) optional
Mesh:getJointMatrix(skeleton, jointIndex)
Returns the final joint transformation based on vertex weights
Arguments
skeleton (Skeleton)
jointIndex (number)
Returns
(Mat4)
Mesh:recalculateTangents()
Mesh:createVertexMap()
Mesh:getMeshFormat()
Returns the required mesh format set by the current pixel shader
Returns
Mesh:create()
Makes this mesh render-able
Mesh:separate()
Separates by loose parts and returns a list of new meshes
Returns
(Mesh[])
Mesh:setMeshDrawMode(meshDrawMode)
Sets the current meshDrawMode, rarely makes sense to set manually
Arguments
meshDrawMode (MeshDrawMode)
Mesh:getMeshDrawMode()
Gets the current meshDrawMode
Returns
(MeshDrawMode)
Mesh:getOrCreateBuffer(name)
Gets or creates an dynamic, typeless buffer
Arguments
name (string) name of buffer
Clonable:clone()
Slow and deep clone
Clonable:instance()
Creates an fast instance
HasShaders:setPixelShader(shader)
Arguments
shader (Shader)
HasShaders:setVertexShader(shader)
Arguments
shader (Shader)
HasShaders:setWorldShader(shader)
Arguments
shader (Shader)
IsNamed:setName(name)
A name has no influence other than being able to print more nicely
Arguments
name (string)
IsNamed:getName()
Gets the name, or “unnamed”
Returns
(string)