diff options
| author | pepperpepperpepper <pepper@scannerjammer.com> | 2015-10-28 17:00:52 -0700 |
|---|---|---|
| committer | pepperpepperpepper <pepper@scannerjammer.com> | 2015-10-28 17:00:52 -0700 |
| commit | 3d17f2b534c04ffa3996cd309056180e72408c01 (patch) | |
| tree | f420b255bb567fabb91fef31d5b98f06cdd87a7b /assets/javascripts/app.js | |
Diffstat (limited to 'assets/javascripts/app.js')
| -rw-r--r-- | assets/javascripts/app.js | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js new file mode 100644 index 0000000..dd68726 --- /dev/null +++ b/assets/javascripts/app.js @@ -0,0 +1,90 @@ + +if (is_mobile) { + $("html").addClass("mobile") +} +else { + $("html").addClass("desktop") +} + + +var scene, cam, map; + +var app = new function(){} + +app.mode = { editor: false, builder: false } + +app.init = function () { + app.launch() +} + +app.launch = function () { + if ($.browser.msie || ! has3d()) { return app.fallback() } + + scene = new MX.Scene().addTo('#scene') + + $(window).resize(app.resize) + app.resize() + + cam = scene.camera + + var last_t = 0 + function animate (t) { + var dt = t - last_t + last_t = t + requestAnimationFrame(animate) + environment.update(t) + // app.movements.update(dt || 0) + } + + var loader = new Loader(function(){ + $("#loader").hide() + window.environment && window.environment.init() + animate() + }) + + // loader.preloadImages([]) + loader.ready() + + window.scrollTo(0,0) +} + +app.resize = function () { + scene.width = window.innerWidth + scene.height = window.innerHeight + scene.perspective = min(window.innerWidth, scene.height) + scene.update() +} + +app.fallback = function(){ + app.unsupported = true + var msg = "Sorry, your browser is not supported.<br><br>" + + "Please use <a href='http://chrome.com/'>Chrome</a> or <a href='https://www.apple.com/safari/'>Safari</a> or <a href='http://getfirefox.com/'>Firefox</a>." + var $fallback = $("<div>") + $fallback.attr('id', 'fallback') + $fallback.html(msg) + $('body').append($fallback) +} + +app.on = function(){ + app.tube.on.apply(app.tube, arguments) +} + +app.off = function(){ + app.tube.off.apply(app.tube, arguments) +} + +app.position = function(obj){ + var pos = { + x: obj.x, + y: obj.y, + z: obj.z, + rotationX: obj.rotationX, + rotationY: obj.rotationY + } + if (obj.scale !== 1) { + pos.scale = obj.scale + } + return pos +} + +document.addEventListener('DOMContentLoaded', app.init) |
