Main Blend4Web module.
Implements methods to initialize and change the global params of the engine.
- Source:
Summary
Methods
- append_loop_cb(callback)
- canvas_data_url(callback, formatopt, qualityopt, auto_revokeopt)
- clear_fps_callback()
- clear_render_callback()
- detect_mobile() → {boolean}
- get_renderer_info() → {RendererInfo|Null}
- init(elem_canvas_webgl, elem_canvas_hudopt) → {WebGLRenderingContext|Null}
- is_paused() → {boolean}
- pause()
- remove_loop_cb(callback)
- reset()
- resume()
- set_fps_callback(fps_cb)
- set_render_callback(callback)
Type Definitions
Detailed Description
Methods
append_loop_cb(callback)
Append a callback to be executed every frame
(even if the rendering is paused). Its purpose is to perform actions
non-related to the actual rendering, e.g html/css manipulation.
This method allows registration of multiple callbacks.
Parameters:
Name | Type | Description |
---|---|---|
callback |
LoopCallback | Callback |
- Source:
canvas_data_url(callback, formatopt, qualityopt, auto_revokeopt)
Register one-time callback to return DataURL of rendered canvas element.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
BlobURLCallback | BlobURL callback. | ||
format |
string |
<optional> |
"image/png" | The image format ("image/png", "image/jpeg", "image/webp" and so on). |
quality |
number |
<optional> |
1.0 | Number between 0 and 1 for types: "image/jpeg", "image/webp". |
auto_revoke |
boolean |
<optional> |
true | Automatically revoke blob object. If auto_revoke is false then application must revoke blob URL via the following call URL.revokeObjectURL(blobURL). |
- Source:
clear_fps_callback()
Remove the callback for the FPS counter
- Source:
clear_render_callback()
Remove the rendering callback.
- Source:
detect_mobile() → {boolean}
get_renderer_info() → {RendererInfo|Null}
Return renderer info.
Returns:
Renderer info.
- Type
- RendererInfo | Null
- Source:
init(elem_canvas_webgl, elem_canvas_hudopt) → {WebGLRenderingContext|Null}
Create the WebGL context and initialize the engine.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elem_canvas_webgl |
HTMLCanvasElement | Canvas element for WebGL | |
elem_canvas_hud |
HTMLCanvasElement |
<optional> |
Canvas element for HUD |
Returns:
WebGL context or null
- Type
- WebGLRenderingContext | Null
- Source:
is_paused() → {boolean}
pause()
Pause the engine
- Source:
remove_loop_cb(callback)
reset()
Reset the engine.
Unloads the scene and releases the engine's resources.
- Source:
resume()
Resume the engine (after pausing)
- Source:
set_fps_callback(fps_cb)
Set the callback for the FPS counter
Parameters:
Name | Type | Description |
---|---|---|
fps_cb |
FPSCallback | FPS callback |
- Source:
set_render_callback(callback)
Set the rendering callback which is executed for every frame just before the
rendering. Only one callback is allowed.
Parameters:
Name | Type | Description |
---|---|---|
callback |
RenderCallback | Render callback |
- Source:
Type Definitions
FPSCallback(fps_avg, phy_fps_avg)
FPS callback
Parameters:
Name | Type | Description |
---|---|---|
fps_avg |
number | Averaged rendering FPS. |
phy_fps_avg |
number | Averaged physics FPS. |
- Source:
LoopCallback(timeline, delta)
Loop callback.
Parameters:
Name | Type | Description |
---|---|---|
timeline |
number | Timeline |
delta |
number | Delta |
- Source:
RenderCallback(delta, timeline)
Rendering callback.
Parameters:
Name | Type | Description |
---|---|---|
delta |
number | Delta |
timeline |
number | Timeline |
- Source: