Created
March 27, 2018 18:31
-
-
Save stewet/8663a7b46a25612e10b20b059a0ed251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
// register the application module | |
b4w.register("windturbine_app", function(exports, require) { | |
// import modules used by the app | |
var m_app = require("app"); | |
var m_cfg = require("config"); | |
var m_data = require("data"); | |
var m_preloader = require("preloader"); | |
var m_ver = require("version"); | |
// detect application mode | |
var DEBUG = (m_ver.type() == "DEBUG"); | |
// automatically detect assets path | |
var APP_ASSETS_PATH = m_cfg.get_assets_path("windturbine"); | |
/** | |
* export the method to initialize the app (called at the bottom of this file) | |
*/ | |
exports.init = function() { | |
m_app.init({ | |
canvas_container_id: "main_canvas_container", | |
callback: init_cb, | |
show_fps: DEBUG, | |
console_verbose: DEBUG, | |
autoresize: true | |
}); | |
} | |
/** | |
* callback executed when the app is initialized | |
*/ | |
function init_cb(canvas_elem, success) { | |
if (!success) { | |
console.log("b4w init failure"); | |
return; | |
} | |
m_preloader.create_preloader(); | |
// ignore right-click on the canvas element | |
canvas_elem.oncontextmenu = function(e) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
return false; | |
}; | |
load(); | |
} | |
/** | |
* load the scene data | |
*/ | |
function load() { | |
m_data.load(APP_ASSETS_PATH + "windturbine.json", load_cb, preloader_cb); | |
} | |
/** | |
* update the app's preloader | |
*/ | |
function preloader_cb(percentage) { | |
m_preloader.update_preloader(percentage); | |
/* After LoadScreen*/ | |
if (percentage == 100) { | |
document.getElementById('ldiv').style.display = 'block'; | |
document.getElementById('rdiv').style.display = 'block'; | |
} | |
} | |
/** | |
* callback executed when the scene data is loaded | |
*/ | |
function load_cb(data_id, success) { | |
if (!success) { | |
console.log("b4w load failure"); | |
return; | |
} | |
m_app.enable_camera_controls(); | |
} | |
// place your code here | |
function fv(x) { | |
alert(x.id); | |
} | |
}); | |
// import the app module and start the app by calling the init method | |
b4w.require("windturbine_app").init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment