/** * Copyright (C) 2014-2016 Triumph LLC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ "use strict"; /** * API for the engine's global configuration. * *

Use the set()/get() method to change/get the value of a property. * Use the reset() method to reset all properties to their default state. * Any change in configuration must occur before engine initialization. Keep in * mind that some of the properties are affected by the quality profile and * the user's hardware/browser. In the former case use the CUSTOM profile * in order to change such properties.

* *

Normally, the users should not alter these parameters.

* *

Configuration Parameters Available

*
*
allow_cors *
Boolean, allow cross-origin resource sharing. *
allow_hidpi *
Boolean, allow HIDPI mode on supported devices (use the CUSTOM profile * in order to change this parameter). *
alpha *
Boolean, enable WebGL canvas transparency. *
alpha_sort *
Boolean, enable z-sorting for transparent materials. *
alpha_sort_threshold *
Number, camera distance threshold for transparency z-sorting. *
anaglyph_use *
Boolean, enable anaglyph stereo rendering. Deprecated, use stereo * instead. *
animation_framerate *
Number, animation framerate. *
anisotropic_filtering *
Boolean, enable anisotropic filtering *
antialiasing *
Boolean, enable postprocess-based anti-aliasing (use the CUSTOM profile * in order to change this parameter). *
assets_path *
String, path to assets directory (for get_assets_path() and get_std_assets_path()). *
assets_dds_available *
Boolean, allow the engine to use compressed DDS textures. *
assets_pvr_available *
Boolean, allow the engine to use compressed PVRST textures. * textures should be present near the source textures in order to be picked up. *
assets_min50_available *
Boolean, allow the engine to use halved textures. The halved * textures should be present near the source textures in order to be picked up. *
audio *
Boolean, enable Web Audio. *
background_color *
Array, RGBA values to use as a background color for the WebGL * canvas. *
built_in_module_name *
String, name of the module which stores exported data (HTML export only). *
canvas_resolution_factor *
Boolean, set the resolution factor for the canvas. *
console_verbose *
Boolean, print more debug info in the browser console. *
compositing *
Boolean, enable compositing. *
dof *
Boolean, enable DOF *
god_rays *
Boolean, enable god rays *
bloom *
Boolean, enable bloom *
motion_blur *
Boolean, enable motion_blur *
do_not_load_resources *
Boolean, disable loading of assets (textures and sounds). *
enable_selectable *
Boolean, enable selecting of objects. *
enable_outlining *
Boolean, enable outlining of object. *
is_mobile_device *
Boolean, check mobile device. *
max_fps *
Number, maximum FPS limit *
max_fps_physics *
Number, maximum physics FPS limit *
media_auto_activation *
Boolean, activate media data context on mobile devices using popup dialog. *
outlining_overview_mode *
Boolean, make all objects selectable, enable outlining and * outlining on select. *
physics_enabled *
Boolean, use the uranium.js physics engine. *
physics_uranium_path *
String, path to the uranium.js file. If not specified, search in the * directory with the engine's sources. *
physics_calc_fps *
Boolean, return physics FPS in {@link module:main~FPSCallback|FPS * callback}. *
physics_use_workers *
Boolean, simulate physics in workers (default) or not. *
precision *
String, preferred GLSL floating point precision (use the CUSTOM profile * in order to change this parameter). *
prevent_caching *
Boolean, prevent assets caching by appending timestamp suffix to their * URLs (default) or not. *
quality *
Number, preferred rendering quality profile (one of P_LOW, P_HIGH, * P_ULTRA, P_CUSTOM enums). *
reflections *
Boolean, enable reflections *
refractions *
Boolean, enable refractions *
sfx_mix_mode *
Boolean, enable the mixer mode in the SFX subsystem. *
shaders_path *
String, path to the shaders directory (developer version only). *
shadows *
Boolean, enable shadows *
show_hud_debug_info *
Boolean, show HUD with debug information. *
smaa *
Boolean, enable SMAA anti-aliasing (use the CUSTOM profile * in order to change this parameter). *
smaa_search_texture_path *
String, path to the SMAA "search" texture. If not specified, search in * the directory with the engine's sources. *
smaa_area_texture_path *
String, path to the SMAA "area" texture. If not specified, search in the * directory with the engine's sources. *
ssao *
Boolean, enable SSAO *
stereo *
String, stereoscopic mode: "ANAGLYPH", "HMD" or "NONE". *
debug_view *
Boolean, enable debug view mode. *
use_min50 *
Boolean, enable min50 textures. *
gl_debug *
Boolean, enable gl errors check. Very slow. *
* @module config * @local QualityProfile * @cc_externs allow_cors allow_hidpi alpha alpha_sort * @cc_externs alpha_sort_threshold anaglyph_use animation_framerate * @cc_externs antialiasing assets_path assets_dds_available assets_min50_available audio * @cc_externs background_color built_in_module_name canvas_resolution_factor * @cc_externs console_verbose compositing do_not_load_resources enable_selectable * @cc_externs enable_outlining media_auto_activation outlining_overview_mode * @cc_externs physics_enabled physics_uranium_path physics_calc_fps physics_use_workers * @cc_externs precision prevent_caching quality * @cc_externs sfx_mix_mode shaders_path show_hud_debug_info * @cc_externs smaa smaa_search_texture_path smaa_area_texture_path * @cc_externs debug_view url_params stereo gl_debug max_fps max_fps_physics * @cc_externs use_min50 anisotropic_filtering shadows reflections refractions * @cc_externs ssao dof god_rays bloom motion_blur is_mobile_device */ b4w.module["config"] = function(exports, require) { var m_cfg = require("__config"); var m_compat = require("__compat"); var m_debug = require("__debug"); var m_data = require("__data"); var m_print = require("__print"); /** * Quality profile enum. One of {@link module:config.P_LOW|P_LOW}, {@link module:config.P_HIGH|P_HIGH}, {@link module:config.P_ULTRA|P_ULTRA}, {@link module:config.P_CUSTOM|P_CUSTOM}. * @typedef QualityProfile * @type {Number} */ /** * Low quality profile: maximize engine performance, minimize memory consumption. * @const {QualityProfile} module:config.P_LOW */ exports.P_LOW = m_cfg.P_LOW; /** * High quality profile: use all requested features. * @const {QualityProfile} module:config.P_HIGH */ exports.P_HIGH = m_cfg.P_HIGH; /** * Ultra quality profile: use all requested features and maximize quality. * @const {QualityProfile} module:config.P_ULTRA */ exports.P_ULTRA = m_cfg.P_ULTRA; /** * Custom quality profile: use engine defaults, allow customization. * @const {QualityProfile} module:config.P_CUSTOM */ exports.P_CUSTOM = m_cfg.P_CUSTOM; /** * Auto quality profile: cannot be used directly, only for quality * auto configurators. * @const {QualityProfile} module:config.P_AUTO */ exports.P_AUTO = m_cfg.P_AUTO; /** * Set the value of the config property of the engine. * @method module:config.set * @param {String} prop Property name * @param {*} value New property value */ exports.set = m_cfg.set; /** * Get the value of the config property of the engine. * @method module:config.get * @param {String} prop Property name * @returns {*} Value of property */ exports.get = m_cfg.get; /** * Reset all the engine's config properties to defaults. * @method module:config.reset */ exports.reset = m_cfg.reset; /** * Reset context limit properties to minimum. * @method module:config.reset_limits */ exports.reset_limits = m_cfg.reset_limits; /** * Get the path to the standard assets directory inside the SDK. * @method module:config.get_std_assets_path * @returns {String} Path to assets */ exports.get_std_assets_path = m_cfg.get_assets_path; /** * Get the path to the project's assets directory. * @see https://www.blend4web.com/doc/en/developers.html#loading-application-assets * @method module:config.get_assets_path * @param {String} name Name of the project * @returns {String} Path to assets */ exports.get_assets_path = m_cfg.get_assets_path; /** * Set the engine's quality profile. * @method module:config.apply_quality * @param {QualityProfile} quality Quality profile */ exports.apply_quality = function(quality) { if (m_data.is_primary_loaded()) { m_print.error("Cannot change quality profile after a scene is loaded."); return; } m_cfg.set("quality", quality); var gl = m_debug.get_gl(); // initialized if (gl) { m_cfg.apply_quality(); m_compat.set_hardware_defaults(m_debug.get_gl(), false); } } }