var scene, cam, controls var app = (function() { var app = {} var last_t = 0, initial_t = 0 app.init = function() { app.bind() app.build() // check if we're in an iframe if (window.self === window.top) { app.ready() } } app.bind = function() { $(window).resize(app.resize) } app.build = function() { if ($.browser.msie || ! has3d()) { return app.fallback() } scene = new MX.Scene().addTo('#scene') cam = scene.camera app.resize() window.scrollTo(0,0) environment.init() } app.ready = function() { if (last_t) return setTimeout(function () { $("html").removeClass("loading") }, 100) app.animate(0) } app.animate = function (t) { requestAnimationFrame(app.animate) if (! initial_t) { initial_t = t return } t -= initial_t var dt = t - last_t last_t = t environment.update(t, dt) } app.resize = function () { scene.width = window.innerWidth scene.height = window.innerHeight scene.perspective = Math.min(window.innerWidth, scene.height) scene.update() } app.fallback = function(){ $('body').addClass('fallback') } return app })() document.addEventListener('DOMContentLoaded', app.init)