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
Deprecated
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_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, disable_gamepad_controlsopt)

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>
HTML element to add event listeners to. The canvas container will be use by default.
allow_element_exit boolean <optional>
false Continue receiving mouse events even when the mouse is leaving the HTML element
disable_gamepad_controls boolean <optional>
false Disable gamepad controls
Source:
Example
var m_app = require("app");
m_app.enable_camera_controls();

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.
Deprecated
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
debug_loading boolean <optional>
false Print loading info into the console
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 into 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
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: