Class: Renderable<T>
Renderable represents something that can be rendered. Contains information for rendering.
Type parameters
Name |
---|
T |
Hierarchy
-
↳ Renderable
Implements
Table of contents
Constructors
Properties
Methods
Constructors
constructor
+ new Renderable<T>(zOrder
: number, vertices
: Polygon, modelMatrix
: Matrix4D, material
: Material, drawMode
: DrawMode, camera
: IEntity, payload?
: T): Renderable<T>
Type parameters:
Name |
---|
T |
Parameters:
Name | Type |
---|---|
zOrder |
number |
vertices |
Polygon |
modelMatrix |
Matrix4D |
material |
Material |
drawMode |
DrawMode |
camera |
IEntity |
payload? |
T |
Returns: Renderable<T>
Inherited from: Pooled
Properties
camera
• camera: IEntity
The camera to draw the renderable to.
Implementation of: IRenderable.camera
drawMode
• drawMode: DrawMode
The draw mode of the renderable, specifying how it will be rendered.
Implementation of: IRenderable.drawMode
material
• material: Material
The material of the object to render, containing render information about texture and shaders.
Implementation of: IRenderable.material
modelMatrix
• modelMatrix: Matrix4D
The model matrix (position, scale, rotation) of the object to render.
Implementation of: IRenderable.modelMatrix
objectInPool
• objectInPool: boolean= false
objectInPool is true if an object is made available in the object pool. If it is false it is not currently available in the object pool. This is used to avoid adding the same object to the same object pool multiple times if there are successive calls to free the the same object.
Implementation of: IRenderable.objectInPool
Inherited from: Pooled.objectInPool
payload
• Optional
payload: undefined | T
An optional payload of additional data.
vertices
• vertices: Polygon
The vertices of the object to render.
Implementation of: IRenderable.vertices
zOrder
• zOrder: number
The Z-Order of the object, the order at which the object will appear infront or behind other objects. A higher Z-Order means in front, a lower Z-Order means behind.
Implementation of: IRenderable.zOrder
pools
▪ Protected
Static
pools: Map<string, [number, IPoolable[]]>
pools is the global, static mapping of string keys to object pools. An object pool contains two pieces of data, the maximum size of the pool (first value), and the objects that make up the pool as an array (second value).
Methods
Free
▸ Free(): void
Free releases an object or it's constituent parts back into any available object pools.
Returns: void
Implementation of: IRenderable
Recycle
▸ Recycle(zOrder
: number, vertices
: Polygon, modelMatrix
: Matrix4D, material
: Material, drawMode
: DrawMode, camera
: IEntity, payload
: T): Renderable<T>
Parameters:
Name | Type |
---|---|
zOrder |
number |
vertices |
Polygon |
modelMatrix |
Matrix4D |
material |
Material |
drawMode |
DrawMode |
camera |
IEntity |
payload |
T |
Returns: Renderable<T>
Free
▸ Static
Free<T>(obj
: Renderable<T>): void
Type parameters:
Name |
---|
T |
Parameters:
Name | Type |
---|---|
obj |
Renderable<T> |
Returns: void
Init
▸ Static
Init(size
: number): void
Parameters:
Name | Type |
---|---|
size |
number |
Returns: void
New
▸ Static
New<T>(zOrder
: number, vertices
: Polygon, modelMatrix
: Matrix4D, material
: Material, drawMode
: DrawMode, camera
: IEntity, payload?
: T): Renderable<T>
Type parameters:
Name |
---|
T |
Parameters:
Name | Type |
---|---|
zOrder |
number |
vertices |
Polygon |
modelMatrix |
Matrix4D |
material |
Material |
drawMode |
DrawMode |
camera |
IEntity |
payload? |
T |
Returns: Renderable<T>
free
▸ Protected
Static
free(poolKey
: string, obj
: IPoolable): void
free is used to mark a provided object as free in the pool provided. This method can be called multiple times with the same object, it will only add one entry to the pool.
Parameters:
Name | Type | Description |
---|---|---|
poolKey |
string | The key of the pool to add the object to. |
obj |
IPoolable | The object to add to the pool. |
Returns: void
Inherited from: Pooled
init
▸ Protected
Static
init(poolKey
: string, emptyGenerator
: () => IPoolable, size
: number): void
init is used to initialize an object pool to a certain size. This method takes a key of the pool to initialize, an 'empty generator' which is a function that should return an empty/blank instance of the object being pooled which can be overwritten at a later point, and the maximum size of the pool (which it will be initialized to at the start using the empty generator).
Parameters:
Name | Type |
---|---|
poolKey |
string |
emptyGenerator |
() => IPoolable |
size |
number |
Returns: void
Inherited from: Pooled
new
▸ Protected
Static
newpoolKey
: *string*, type
: (...args
: *any*) => T, ...args
: any): T
new is used to request a new object from the pool specified, if the pool is unavailable or empty it will use the type to provision a new object through a constructor. This is a generic method, it includes a cast to the generic type provided - this cast can fail if the objects returned from the pool are not the type expected.
Type parameters:
Name | Type |
---|---|
T |
IPoolable |
Parameters:
Name | Type | Description |
---|---|---|
poolKey |
string | The key of the pool to retrieve from. |
type |
(...args : any) => T |
The fallback constructor to use if the pool is not initialized/empty. |
...args |
any | The args to use when creating/recycling the object. |
Returns: T
Inherited from: Pooled