Example #1
0
function check_fullscreen() {
    var fullscreen_on_button = document.querySelector("#fullscreen_on_button");

    if (!m_app.check_fullscreen())
        fullscreen_on_button.parentElement.removeChild(fullscreen_on_button);
}
Example #2
0
function init_cb(canvas_element, success) {
    if (!success) {
        var url_params = m_app.get_url_params();

        if (url_params && url_params["fallback_image"]) {
            var image_wrapper = document.createElement("div");
            image_wrapper.className = "image_wrapper";
            document.body.appendChild(image_wrapper);
            preloader_container.style.display = "none";
            image_wrapper.style.backgroundImage = 'url(' + url_params["fallback_image"] + ')';
        } else
            report_app_error("Browser could not initialize WebGL", "For more info visit",
                          "https://www.blend4web.com/troubleshooting")

        return;
    }

    m_main.pause();

    set_quality_button();

    init_control_buttons();

    if (!m_app.check_fullscreen())
        fullscreen_on_button.parentElement.removeChild(fullscreen_on_button);

    // search source file
    var file = SCENE_PATH;

    var module_name = m_cfg.get("built_in_module_name");

    if (b4w.module_check(module_name)) {
        var bd = require(module_name);
        var file = bd["data"]["main_file"];

        remove_built_in_scripts();
    } else {
        var url_params = m_app.get_url_params();

        logo_container.style.display = "block";

        if (url_params && url_params["load"]) {
            var file_exist = check_file_exist(url_params["load"]);

            if (file_exist)
                file = url_params["load"];
            else {
                report_app_error("Could not load the scene",
                                       "For more info visit",
                                       "https://www.blend4web.com/troubleshooting");
                return null;
            }
        } else {
            report_app_error("Please specify a scene to load",
                                   "For more info visit",
                                   "https://www.blend4web.com/troubleshooting");
            return null;
        }
    }

    anim_elem(logo_container, "opacity", LOGO_SHOW_DELAY, 1, 0, "", "", function() {
        preloader_caption.style.display = "block";
        anim_elem(preloader_caption, "opacity", CAPTION_SHOW_DELAY, 1, 0, "", "", function() {
            m_main.resume();
        });
    })

    // load
    m_data.load(file, loaded_callback, preloader_callback, false);
    m_app.enable_controls(canvas_element);

    window.addEventListener("resize", on_resize, false);
    on_resize();
}