Module: main

Main Blend4Web module. Implements methods to initialize and change the global params of the engine.
Source:

Summary

Methods

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}

Check using device.
Returns:
Checking result.
Type
Boolean
Source:

get_canvas_elem() → {HTMLCanvasElement}

Return the main canvas element.
Returns:
Canvas element
Type
HTMLCanvasElement
Deprecated:
Source:

get_renderer_info() → {RendererInfo|Null}

Return renderer info.
Returns:
Renderer info.
Type
RendererInfo | Null
Source:

global_timeline() → {Number}

Return the engine's global timeline value
Returns:
Floating-point number of seconds elapsed since the engine start-up
Type
Number
Deprecated:
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}

Check if the engine is paused
Returns:
Paused flag
Type
Boolean
Source:

pause()

Pause the engine
Source:

remove_loop_cb(callback)

Remove loop callback.
Parameters:
Name Type Description
callback LoopCallback Callback
Source:

reset()

Reset the engine. Unloads the scene and releases the engine's resources.
Source:

resize(width, height, update_canvas_cssopt)

Resize the rendering canvas.
Parameters:
Name Type Attributes Default Description
width Number New canvas width
height Number New canvas height
update_canvas_css Boolean <optional>
true Change canvas CSS width/height
Deprecated:
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: