Module: app

Application add-on. Provides generic routines for the engine's initialization, UI and I/O.

Summary

Methods

Type Definitions

Detailed Description

Methods

attr_animate(elem, attr_name, from, to, timeout, opt_callbackopt)

Animate html tag attribute.
Parameters:
Name Type Attributes Description
elem HTMLElement HTML-element.
attr_name String Animated attribute name.
from Number Value from.
to Number Value to.
timeout Number Time for animation.
opt_callback GenericCallback <optional>
Finish callback function.
Source:

check_fullscreen() → {Boolean}

Check whether fullscreen mode is available.
Returns:
Result of the check.
Type
Boolean
Source:

css_animate(elem, prop, from, to, timeout, opt_prefixopt, opt_suffixopt, opt_callbackopt)

Animate css-property value.
Parameters:
Name Type Attributes Description
elem HTMLElement HTML-element.
prop String Animated css-property.
from Number Value from.
to Number Value to.
timeout Number Time for animation.
opt_prefix String <optional>
Prefix of css-property (" scale(", "%" and etc).
opt_suffix String <optional>
Suffix of css-property (" px", "%" and etc).
opt_callback GenericCallback <optional>
Finish callback function.
Source:

disable_camera_controls()

Disable controls for the active camera.
Source:
Example
var m_app = require("app");
m_app.disable_camera_controls();

disable_controls()

Disable engine controls.
Deprecated:
  • Not need anymore.
Source:

disable_object_controls(obj)

Remove controls from the non-camera object.
Parameters:
Name Type Description
obj Object3D Object.
Source:

enable_camera_controls(disable_default_pivotopt, disable_letter_controlsopt, disable_zoomopt, elementopt, allow_element_exitopt)

Assign keyboard and mouse controls to the active camera. (arrow keys, ADSW, wheel and others)
Parameters:
Name Type Attributes Default Description
disable_default_pivot Boolean <optional>
false Do not use the possible camera-defined pivot point
disable_letter_controls Boolean <optional>
false Disable keyboard letter controls (only arrow keys will be used to control the camera)
disable_zoom Boolean <optional>
false Disable zoom
element HTMLElement <optional>
Canvas container element HTML element to add event listeners to
allow_element_exit Boolean <optional>
false Continue receiving mouse events even when the mouse is leaving the HTML element
Source:
Example
var m_app = require("app");
m_app.enable_camera_controls();

enable_controls(allow_element_exitopt)

Enable engine controls. Registers common event listeners for input sensors. If you need different set of event handlers/parameters, register event listeners manually by using register_* functions from module:controls.
Parameters:
Name Type Attributes Default Description
allow_element_exit Boolean <optional>
false Continue receiving mouse events even when the mouse is leaving the HTML element.
Deprecated:
  • Not need anymore.
Source:

enable_debug_controls()

Enable debug controls:
  • K - make camera debug shot
  • L - make light debug shot
  • M - flashback messages
Source:

enable_object_controls(obj, elementopt)

Assign some controls to the non-camera object.
Parameters:
Name Type Attributes Default Description
obj Object3D Object 3D
element HTMLElement <optional>
Canvas container element HTML element
Source:

exit_fullscreen()

Exit fullscreen mode.
Source:

get_camera_smooth_factor() → {Number}

Get smooth factor for camera rotation.
Returns:
Smooth factor
Type
Number
Source:

get_url_params(allow_param_arrayopt) → {Object|Null}

Retrieve parameters of the page's URL.
Parameters:
Name Type Attributes Default Description
allow_param_array Boolean <optional>
false Create arrays of parameters if they share the same name.
Returns:
URL parameters in a key-value format.
Type
Object | Null
Source:

init(optionsopt)

Initialize the engine. The "options" object may be extended by adding properties from the engine's configuration (see config module). In that case they will be applied before engine initialization.
Parameters:
Name Type Attributes Default Description
options Object <optional>
{} Initialization options.
Properties
Name Type Attributes Default Description
canvas_container_id String <optional>
null Canvas container ID.
callback AppInitCallback <optional>
function(){} Initialization callback.
error_purge_elements Boolean <optional>
null Remove interface elements after error.
show_hud_debug_info Boolean <optional>
false Show HUD with developer info.
show_fps Boolean <optional>
false Show FPS counter.
fps_elem_id String <optional>
null Custom fps counter id.
fps_wrapper_id String <optional>
null Show FPS wrapper with current id.
report_init_failure Boolean <optional>
true Show elements with info about init failure
pause_invisible Boolean <optional>
true Pause engine simulation if page is not visible (in other tab or minimized).
key_pause_enabled Boolean <optional>
true Enable key pause
autoresize Boolean <optional>
false Automatically resize canvas to match the size of container element.
force_container_ratio Number <optional>
0 Automatically resize canvas container height, based on its width and passed ratio value.
min_capabilities Boolean <optional>
false Set min capability mode
Source:

queue_animate(queue)

Animate queue of the html elements.
Parameters:
Name Type Description
queue Array.<module:app~QueueObject> Array of the queue objects.
Source:

report_app_error(text_message, link_message, link, purge_elements)

Report an application error. Creates standard HTML elements with error info and inserts them in the page body.
Parameters:
Name Type Description
text_message String Message to place on upper element.
link_message String Message to place on bottom element.
link String Link to place on bottom element.
purge_elements Array.<HTMLElement> Array of elements to destroy just before the error elements are inserted.
Source:

request_fullscreen(elem, enabled_cb, disabled_cb)

Request fullscreen mode. Security issues: execute by user event.
Parameters:
Name Type Description
elem HTMLElement Element
enabled_cb FullscreenEnabledCallback Enabled callback
disabled_cb FullscreenDisabledCallback Disabled callback
Source:

resize_to_container()

Fit canvas elements to match the size of container element.
Deprecated:
Source:

set_camera_move_style(move_style)

Set the movement style for the active camera and reload controls assigned by enable_camera_controls().
Parameters:
Name Type Description
move_style CameraMoveStyle New camera movement style.
Deprecated:
Source:

set_camera_smooth_factor(value)

Set smooth factor for camera rotation.
Parameters:
Name Type Description
value Number New smooth factor
Source:

Type Definitions

AnimFinishCallback()

Animation finish callback.
Source:

AppInitCallback(canvas, success)

Application initialization callback.
Parameters:
Name Type Description
canvas HTMLElement Initialized canvas element.
success Boolean Success flag.
Source:

QueueObject

Queue object params.
Type:
  • Object
Properties:
Name Type Attributes Default Description
type String Animation type.
elem HTMLElement Animated html element.
prop String Animated property.
from Number Initial property value.
to Number Target property value.
duration Number Animation duration in ms.
opt_prefix String <optional>
'' Prefix for the css property.
opt_suffix String <optional>
'' Prefix for the css property.
cb AnimFinishCallback <optional>
function(){} Animation finish callback.
Source: