2022-03-05 06:34:36 +08:00
|
|
|
Interface.page_wrapper = document.getElementById('page_wrapper');
|
|
|
|
Interface.work_screen = document.getElementById('work_screen');
|
2022-03-11 01:12:59 +08:00
|
|
|
Interface.center_screen = document.getElementById('center');
|
2022-03-05 06:34:36 +08:00
|
|
|
Interface.right_bar = document.getElementById('right_bar');
|
|
|
|
Interface.left_bar = document.getElementById('left_bar');
|
2022-03-11 01:12:59 +08:00
|
|
|
Interface.preview = document.getElementById('preview');
|
2019-12-16 03:04:31 +08:00
|
|
|
|
|
|
|
CustomTheme.setup()
|
|
|
|
|
2020-04-26 02:25:07 +08:00
|
|
|
StateMemory.init('dialog_paths', 'object')
|
|
|
|
|
2019-12-16 03:04:31 +08:00
|
|
|
initCanvas()
|
|
|
|
animate()
|
|
|
|
|
|
|
|
Blockbench.browser = 'electron'
|
|
|
|
if (isApp === false) {
|
|
|
|
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
|
|
|
|
Blockbench.browser = 'firefox'
|
|
|
|
} else if (!!window.chrome && !!window.chrome.webstore) {
|
|
|
|
Blockbench.browser = 'chrome'
|
|
|
|
} else if ((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
|
|
|
|
Blockbench.browser = 'opera'
|
|
|
|
} else if (/constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification))) {
|
|
|
|
Blockbench.browser = 'safari'
|
|
|
|
} else if (!!document.documentMode) {
|
|
|
|
Blockbench.browser = 'internet_explorer'
|
2020-07-25 03:13:25 +08:00
|
|
|
} else if (!!window.chrome && window.navigator.userAgent.toLowerCase().includes('edg')) {
|
2019-12-16 03:04:31 +08:00
|
|
|
Blockbench.browser = 'edge'
|
2020-07-25 03:13:25 +08:00
|
|
|
} else if (!!window.StyleMedia) {
|
|
|
|
Blockbench.browser = 'proprietary_edge'
|
|
|
|
} else if (!!window.chrome && !window.chrome.webstore) {
|
|
|
|
Blockbench.browser = 'chromium'
|
2019-12-16 03:04:31 +08:00
|
|
|
}
|
2020-07-25 03:13:25 +08:00
|
|
|
if (navigator.appVersion.indexOf("Win") != -1) Blockbench.operating_system = 'Windows';
|
|
|
|
if (navigator.appVersion.indexOf("Mac") != -1) Blockbench.operating_system = 'MacOS';
|
|
|
|
if (navigator.appVersion.indexOf("Linux") != -1) Blockbench.operating_system = 'Linux';
|
|
|
|
if (['proprietary_edge', 'internet_explorer'].includes(Blockbench.browser)) {
|
2019-12-16 03:04:31 +08:00
|
|
|
alert(capitalizeFirstLetter(Blockbench.browser)+' does not support Blockbench')
|
|
|
|
}
|
|
|
|
$('.local_only').remove()
|
|
|
|
} else {
|
|
|
|
$('.web_only').remove()
|
|
|
|
}
|
|
|
|
BARS.setupActions()
|
|
|
|
BARS.setupToolbars()
|
|
|
|
BARS.setupVue()
|
|
|
|
MenuBar.setup()
|
|
|
|
translateUI()
|
|
|
|
|
2020-09-16 17:36:07 +08:00
|
|
|
console.log(`Three.js r${THREE.REVISION}`)
|
2020-03-05 03:56:17 +08:00
|
|
|
console.log('%cBlockbench ' + appVersion + (isApp
|
2019-12-16 03:04:31 +08:00
|
|
|
? (' Desktop (' + Blockbench.operating_system +')')
|
2021-02-21 23:46:06 +08:00
|
|
|
: (' Web ('+capitalizeFirstLetter(Blockbench.browser) + (Blockbench.isPWA ? ', PWA)' : ')'))),
|
2021-06-27 20:52:49 +08:00
|
|
|
'border: 2px solid #3e90ff; padding: 4px 8px; font-size: 1.2em;'
|
2020-03-05 03:56:17 +08:00
|
|
|
)
|
2022-08-27 19:05:17 +08:00
|
|
|
Blockbench.startup_count = parseInt(localStorage.getItem('startups')||0) + 1;
|
|
|
|
localStorage.setItem('startups', Blockbench.startup_count);
|
2019-12-16 03:04:31 +08:00
|
|
|
|
2021-05-22 05:48:39 +08:00
|
|
|
document.getElementById('blackout').addEventListener('click', event => {
|
2021-06-13 18:35:48 +08:00
|
|
|
if (typeof open_interface.cancel == 'function') {
|
2021-05-22 05:48:39 +08:00
|
|
|
open_interface.cancel(event);
|
|
|
|
} else if (typeof open_interface == 'string' && open_dialog) {
|
|
|
|
$('dialog#'+open_dialog).find('.cancel_btn:not([disabled])').trigger('click');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-12-16 03:04:31 +08:00
|
|
|
if (isApp) {
|
|
|
|
updateRecentProjects()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isApp) {
|
|
|
|
async function registerSW() {
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
try {
|
|
|
|
await navigator.serviceWorker.register('./service_worker.js');
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
registerSW();
|
|
|
|
}
|
|
|
|
|
2021-03-08 19:56:02 +08:00
|
|
|
if (!Blockbench.isWeb || !Blockbench.isPWA) {
|
|
|
|
$.ajaxSetup({ cache: false });
|
|
|
|
}
|
|
|
|
|
2020-07-16 15:32:59 +08:00
|
|
|
Blockbench.on('before_closing', (event) => {
|
|
|
|
if (!Blockbench.hasFlag('no_localstorage_saving')) {
|
|
|
|
Settings.saveLocalStorages()
|
|
|
|
}
|
|
|
|
})
|
2019-12-16 03:04:31 +08:00
|
|
|
|
|
|
|
setInterval(function() {
|
|
|
|
Prop.fps = framespersecond;
|
|
|
|
framespersecond = 0;
|
|
|
|
}, 1000)
|
|
|
|
|
2021-11-13 23:34:47 +08:00
|
|
|
updateProjectResolution()
|
|
|
|
|
|
|
|
setupInterface()
|
|
|
|
setupDragHandlers()
|
|
|
|
|
2019-12-16 03:04:31 +08:00
|
|
|
onVueSetup.funcs.forEach((func) => {
|
|
|
|
if (typeof func === 'function') {
|
|
|
|
func()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
if (isApp) {
|
|
|
|
initializeDesktopApp();
|
|
|
|
} else {
|
|
|
|
initializeWebApp();
|
|
|
|
}
|
|
|
|
|
2021-01-24 06:24:14 +08:00
|
|
|
localStorage.setItem('last_version', Blockbench.version);
|
|
|
|
|
2021-07-02 18:04:05 +08:00
|
|
|
(function() {
|
|
|
|
// Promise.any workaround
|
|
|
|
let proceeded = false;
|
|
|
|
function proceed() {
|
|
|
|
if (proceeded) return;
|
|
|
|
if (isApp) {
|
|
|
|
loadOpenWithBlockbenchFile();
|
|
|
|
} else {
|
|
|
|
loadInfoFromURL();
|
|
|
|
}
|
|
|
|
proceeded = true;
|
2020-08-14 04:50:54 +08:00
|
|
|
}
|
2021-07-02 18:04:05 +08:00
|
|
|
loadInstalledPlugins().then(proceed);
|
|
|
|
setTimeout(proceed, 1200);
|
|
|
|
})()
|
2019-12-23 00:33:55 +08:00
|
|
|
|
2021-07-07 19:08:56 +08:00
|
|
|
setStartScreen(true);
|
|
|
|
|
|
|
|
document.getElementById('page_wrapper').classList.remove('invisible');
|
2020-04-26 02:25:07 +08:00
|
|
|
|
2019-12-16 03:04:31 +08:00
|
|
|
Blockbench.setup_successful = true;
|