Class: Blaze
blaze.Blaze
Represents the Blaze engine.
Constructors
constructor
โข new Blaze()
Properties
bgColor
โช Static
Private
bgColor: Color
The color used to clear the Renderer.
Defined in
src/blaze.ts:45
canvas
โช Static
Private
canvas: BlazeElement
<HTMLCanvasElement
>
The webgl canvas used by blaze.
Defined in
src/blaze.ts:36
editor
โช Static
editor: Editor
The editor.
Defined in
src/blaze.ts:93
fixedDt
โช Static
fixedDt: number
The minimum time in ms between each fixed update.
Defined in
src/blaze.ts:71
fixedSystems
โช Static
Private
fixedSystems: System
[] = []
Defined in
src/blaze.ts:59
fixedTimeStep
โช Static
Private
fixedTimeStep: TimeStep
The TimeStep for fixed updates.
Defined in
src/blaze.ts:83
maxFixedDt
โช Static
maxFixedDt: number
The maximum fixed delta time step in ms.
If the time since the last fixed update exceeds this amount then it will be clamped.
Defined in
src/blaze.ts:78
renderController
โช Static
renderController: RenderController
Defined in
src/blaze.ts:56
scene
โช Static
Private
scene: Scene
The current Scene.
Defined in
src/blaze.ts:88
systems
โช Static
Private
systems: System
[] = []
Defined in
src/blaze.ts:58
threadPool
โช Static
Private
threadPool: ThreadPool
Defined in
src/blaze.ts:61
timeStep
โช Static
Private
timeStep: TimeStep
The TimeStep for normal updates.
Defined in
src/blaze.ts:66
zLevels
โช Static
Private
zLevels: number
= 100
This value represents the number of Z positions that can be used within the world space.
Allows the user to specify zIndexes as integer values (-1, 1, 2, 3) that are scaled into a -1.0 - 1.0 range.
The higher this value the more zIndexes the camera will be able to see.
Defined in
src/blaze.ts:54
Methods
addSystem
โธ Static
addSystem(system
, fixed?
): void
Adds a system to the engine.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
system | System | undefined | The system to add |
fixed | boolean | false | Wether the system will run in the fixed update or normal update loop |
Returns
void
Defined in
src/blaze.ts:224
canvasContextMenuListener
โธ Static
canvasContextMenuListener(e
): void
Parameters
Name | Type |
---|---|
e | MouseEvent |
Returns
void
Defined in
src/blaze.ts:37
fixedUpdate
โธ Static
fixedUpdate(): void
Blaze's fixed update loop.
Fixed update is called every this.fixedTimeStep
ms using setTimeout,
due to how the JS event loop works and any other tasks being ran on the main thread this may not always be the case.
To account for the possible variations in time between each update a seperate delta time value is calculated for the fixed update loop.
Fixed update calls update
on all systems in this.fixedSystems
.
Fixed update also steps the Physics engine.
Returns
void
Defined in
src/blaze.ts:170
getBgColor
โธ Static
getBgColor(): Color
Gets the engine's current bg color.
Returns
The engine's current bg color
Defined in
src/blaze.ts:335
getCanvas
โธ Static
getCanvas(): BlazeElement
<HTMLCanvasElement
>
Gets the canvas used by blaze.
Returns
BlazeElement
<HTMLCanvasElement
>
The BlazeElement for blaze's canvas
Defined in
src/blaze.ts:262
getFixedSystems
โธ Static
getFixedSystems(): System
[]
Gets the fixed systems added to the engine.
Returns
System
[]
The engine's fixed systems
Defined in
src/blaze.ts:214
getFixedTimeStep
โธ Static
getFixedTimeStep(): TimeStep
Gets the TimeStep between each fixed update.
Returns
The most recent fixed time step
Defined in
src/blaze.ts:376
getPhysics
โธ Static
getPhysics(): Physics
Gets the current scene's Physics world.
Returns
THe current scene's physics world
Defined in
src/blaze.ts:300
getScene
โธ Static
getScene(): Scene
Gets the engine's scene.
Returns
The engine's scene
Defined in
src/blaze.ts:282
getSystems
โธ Static
getSystems(): System
[]
Gets the systems added to the engine.
Returns
System
[]
The engine's top level systems
Defined in
src/blaze.ts:205
getThreadPool
โธ Static
getThreadPool(): ThreadPool
Gets the current thread pool being used.
Returns
The thread pool in use by the engine
Defined in
src/blaze.ts:385
getTimeStep
โธ Static
getTimeStep(): TimeStep
Gets the TimeStep between each update.
Returns
The most recent fixed time step
Defined in
src/blaze.ts:367
getWorld
โธ Static
getWorld(): World
Gets the current scene's World.
Returns
The current scene's world
Defined in
src/blaze.ts:291
getZLevels
โธ Static
getZLevels(): number
Gets the current number of zLevels the engine is set to support.
Returns
number
The number of zLevels for the engine
Defined in
src/blaze.ts:358
init
โธ Static
init(canvas
, opts?
): void
Initializes the engine and creates the renderer.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
canvas | HTMLCanvasElement | undefined | The canvas to use to create the renderer |
opts | BlazeOptions | defaultOpts | The options to use when setting up the engine |
Returns
void
Defined in
src/blaze.ts:101
nextTimestep
โธ Static
Private
nextTimestep(fixed?
): void
Updates the engine's timestep to the current time.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
fixed | boolean | false | Wether or not to set the fixed time step |
Returns
void
Defined in
src/blaze.ts:188
removeSystem
โธ Static
removeSystem(system
): boolean
Removes a system from the engine.
Will search for the system in both the fixed and normal system arrays.
If the system is in both the fixed and normal system arrays then it will only be removed from the normal array. Another call to removeSystem will remove it from the fixed array.
Parameters
Name | Type | Description |
---|---|---|
system | System | The system to remove |
Returns
boolean
Wether or not the system was removed
Defined in
src/blaze.ts:241
setBgColor
โธ Static
setBgColor(color
): Color
Sets the clear color to be used when clearing the webgl buffer, mimics having a bg color.
Parameters
Name | Type | Description |
---|---|---|
color | Color | The Color instance to set the engine's bg color to |
Returns
The set Color instance
Defined in
src/blaze.ts:310
โธ Static
setBgColor(color
): Color
Sets the clear color to be used when clearing the webgl buffer, mimics having a bg color.
Parameters
Name | Type | Description |
---|---|---|
color | ColorLike | The ColorLike representation to use when instantiating the bg color |
Returns
The set Color instance
Defined in
src/blaze.ts:318
setScene
โธ Static
setScene(scene
): void
Sets the engine's scene.
Parameters
Name | Type | Description |
---|---|---|
scene | Scene | The scene to use |
Returns
void
Defined in
src/blaze.ts:271
setZLevels
โธ Static
setZLevels(zLevels
): void
Sets the amount of zLevels the engine (physics, world, renderer) will use.
throws
When zLevels is < 0 or zLevels is a floating point number.
Parameters
Name | Type | Description |
---|---|---|
zLevels | number | The number to set zLevels to |
Returns
void
Defined in
src/blaze.ts:346
start
โธ Static
start(): void
Starts Blaze's update/render loop.
i.e. calls this.update
Returns
void
Defined in
src/blaze.ts:121
update
โธ Static
update(): void
Blaze's update loop.
Update is called on every animation frame using requestAnimationFrame.
Update clears the Renderer with the set background color and calls update
on any systems in this.systems
.
Update also updates the engine's current Scene.
At the end of the update the Renderer queue is flushed, drawing anything that was queued for rendering during the frame.
Returns
void
Defined in
src/blaze.ts:140