Skip to main content

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

NameTypeDefault valueDescription
systemSystemundefinedThe system to add
fixedbooleanfalseWether 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

NameType
eMouseEvent

Returns

void

Defined in

src/blaze.ts:37


fixedUpdate

โ–ธ Static fixedUpdate(): void

Blaze's fixed update loop.

Fixed update is called every this.fixedTimeStepms 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

Color

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

TimeStep

The most recent fixed time step

Defined in

src/blaze.ts:376


getPhysics

โ–ธ Static getPhysics(): Physics

Gets the current scene's Physics world.

Returns

Physics

THe current scene's physics world

Defined in

src/blaze.ts:300


getScene

โ–ธ Static getScene(): Scene

Gets the engine's scene.

Returns

Scene

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

ThreadPool

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

TimeStep

The most recent fixed time step

Defined in

src/blaze.ts:367


getWorld

โ–ธ Static getWorld(): World

Gets the current scene's World.

Returns

World

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

NameTypeDefault valueDescription
canvasHTMLCanvasElementundefinedThe canvas to use to create the renderer
optsBlazeOptionsdefaultOptsThe 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

NameTypeDefault valueDescription
fixedbooleanfalseWether 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

NameTypeDescription
systemSystemThe 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

NameTypeDescription
colorColorThe Color instance to set the engine's bg color to

Returns

Color

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

NameTypeDescription
colorColorLikeThe ColorLike representation to use when instantiating the bg color

Returns

Color

The set Color instance

Defined in

src/blaze.ts:318


setScene

โ–ธ Static setScene(scene): void

Sets the engine's scene.

Parameters

NameTypeDescription
sceneSceneThe 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

NameTypeDescription
zLevelsnumberThe 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