Data API. Used to load/unload exported JSON data files.
- Source:
Summary
Methods
- activate_media()
- is_idle() → {boolean}
- is_primary_loaded() → {boolean}
- load(path, loaded_cbopt, stageload_cbopt, wait_complete_loadingopt, load_hiddenopt) → {number}
- prefetch(path, loaded_cbopt, stageload_cbopt)
- set_debug_resources_root(debug_resources_root)
- unfetch()
- unload(data_idopt)
Type Definitions
Detailed Description
Methods
activate_media()
Activate media data context.
Activation of audio/video contexts is required for mobile platforms which
disable media playback without explicit user interaction. This method
should be executed inside some input event listener.
- Source:
is_idle() → {boolean}
Check if the engine has finished all of the scheduled loading actions.
Returns:
Check result
- Type
- boolean
- Source:
is_primary_loaded() → {boolean}
Check if the engine primary data (main scene) is loaded (detect the last loading stage).
Returns:
Check result
- Type
- boolean
- Source:
load(path, loaded_cbopt, stageload_cbopt, wait_complete_loadingopt, load_hiddenopt) → {number}
Load data from the json file exported from Blender.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
path |
string | Path to JSON file | ||
loaded_cb |
LoadedCallback |
<optional> |
null | Callback to be executed right after load |
stageload_cb |
StageloadCallback |
<optional> |
null | Callback to report about the loading progress |
wait_complete_loading |
boolean |
<optional> |
false | Wait until all resources are loaded |
load_hidden |
boolean |
<optional> |
false | Hide loaded and disable physics objects |
Returns:
ID of loaded data.
- Type
- number
- Source:
prefetch(path, loaded_cbopt, stageload_cbopt)
Preload scene's resources and put them into cache.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
path |
string | Path to JSON file | ||
loaded_cb |
LoadedCallback |
<optional> |
null | Callback to be executed right after load |
stageload_cb |
StageloadCallback |
<optional> |
null | Callback to report about the loading progress |
- Source:
set_debug_resources_root(debug_resources_root)
Set the root which contains the resources, for debug purposes.
Enables the checking of loading paths, so if the resources are not loaded from
the app root, there will be a warning in m_print.
Parameters:
Name | Type | Description |
---|---|---|
debug_resources_root |
string | App root directory. |
- Source:
unfetch()
Clear loading cache.
- Source:
unload(data_idopt)
Unload the previously loaded data.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
data_id |
number |
<optional> |
0 | ID of unloaded data. Unload all data if data_id is zero. |
- Source:
Type Definitions
LoadedCallback(data_id, success)
Data loaded callback.
Executed when the data loading process has been completed.
Parameters:
Name | Type | Description |
---|---|---|
data_id |
number | Data ID |
success |
boolean | Load success |
- Source:
StageloadCallback(percentage, load_time, data_id)
Loading stage callback.
Used to implement loading progress indicators (preloaders).
Parameters:
Name | Type | Description |
---|---|---|
percentage |
number | Loading progress (0-100). |
load_time |
number | Loading time in ms. |
data_id |
number | Data ID |
- Source: