A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat: add loading overlay during editor initialization
esengineaf918384bdcb
diff --git a/desktop/src/main.ts b/desktop/src/main.tsindex 1bf679100..bb205d833 100644--- a/desktop/src/main.ts+++ b/desktop/src/main.ts@@ -5,7 +5,7 @@import 'dockview-core/dist/styles/dockview.css';import '@esengine/editor/styles';-import { createEditor, ProjectLauncher, LauncherBridge, setPlatformAdapter, setEditorContext, loadProjectConfig, showToast, dismissToast, showProgressToast, updateToast, getSettingsValue, type Editor } from '@esengine/editor';+import { createEditor, ProjectLauncher, LauncherBridge, setPlatformAdapter, setEditorContext, loadProjectConfig, showToast, dismissToast, showProgressToast, updateToast, getSettingsValue, LoadingOverlay, type Editor } from '@esengine/editor';import { TauriPlatformAdapter } from './TauriPlatformAdapter';import { nativeFS, nativeShell } from './native-fs';import { invoke } from '@tauri-apps/api/core';@@ -91,19 +91,41 @@ async function loadPhysicsFactory(editor: Editor): Promise<void> {async function openEditor(container: HTMLElement, projectPath: string): Promise<void> {const editor = createEditor(container, { projectPath });- console.log('ESEngine Editor opened project:', projectPath);-- const module = await loadWasmModule();- if (module) {- const app: App = {- wasmModule: module,- } as App;- editor.setApp(app);- }+ const overlay = new LoadingOverlay(container);++ try {+ overlay.setStatus('Loading engine...');+ const [module] = await Promise.all([+ loadWasmModule(),+ loadProjectConfig(projectPath),+ ]);++ if (module) {+ const app: App = {+ wasmModule: module,+ } as App;+ editor.setApp(app);+ }++ overlay.setStatus('Loading physics...');+ await loadPhysicsFactory(editor);- const config = await loadProjectConfig(projectPath);+ overlay.setStatus('Scanning assets...');+ await editor.waitForAssetLibrary();- await loadPhysicsFactory(editor);+ overlay.setStatus('Initializing scripts...');+ await editor.waitForScripts();++ overlay.setStatus('Restoring scene...');+ await editor.waitForSceneRestore();++ overlay.setStatus('Ready');+ await new Promise(resolve => setTimeout(resolve, 300));+ overlay.dismiss();+ } catch (e) {+ overlay.setStatus(`Error: ${e instanceof Error ? e.message : String(e)}`);+ console.error('Editor initialization failed:', e);+ }checkForUpdate();}diff --git a/editor/src/Editor.ts b/editor/src/Editor.tsindex dc50367e7..6a1b56bf0 100644--- a/editor/src/Editor.ts+++ b/editor/src/Editor.ts@@ -83,6 +83,10 @@ export class Editor {private multiWindowService_!: MultiWindowService;private mcpBridge_: McpBridge | null = null;+ private assetLibraryReady_: Promise<void> = Promise.resolve();+ private scriptsReady_: Promise<void> = Promise.resolve();+ private sceneRestoreReady_: Promise<void> = Promise.resolve();+constructor(container: HTMLElement, options?: EditorOptions) {this.container_ = container;this.projectPath_ = options?.projectPath ?? null;@@ -130,11 +134,13 @@ export class Editor {if (this.projectPath_) {this.extensionService_.setupEditorGlobals();const assetReady = this.projectService_.initializeAssetLibrary();+ this.assetLibraryReady_ = assetReady;this.sceneService_.setAssetLibraryReady(assetReady);const scriptsReady = this.initializeAllScripts_();+ this.scriptsReady_ = scriptsReady;this.sceneService_.setScriptsReady(scriptsReady);this.projectService_.initProjectSettingsSync();- this.sceneService_.restoreLastScene();+ this.sceneRestoreReady_ = this.sceneService_.restoreLastScene();}}@@ -170,6 +176,18 @@ export class Editor {this.spineService_.onSpineVersionChange(handler);}+ waitForAssetLibrary(): Promise<void> {+ return this.assetLibraryReady_;+ }++ waitForScripts(): Promise<void> {+ return this.scriptsReady_;+ }++ waitForSceneRestore(): Promise<void> {+ return this.sceneRestoreReady_;+ }+// =========================================================================// Plugin system// =========================================================================diff --git a/editor/src/index.ts b/editor/src/index.tsindex 1b2792de3..676a3931d 100644--- a/editor/src/index.ts+++ b/editor/src/index.ts@@ -224,6 +224,8 @@ export {type ToastAction,} from './ui/Toast';+export { LoadingOverlay } from './ui/LoadingOverlay';+// =============================================================================// Utils// =============================================================================diff --git a/editor/src/styles/index.css b/editor/src/styles/index.cssindex 68d368b1d..f5aeb119b 100644--- a/editor/src/styles/index.css+++ b/editor/src/styles/index.css@@ -16,4 +16,5 @@@import './frame-debugger.css';@import './extensions.css';@import './tile-palette.css';+@import './loading-overlay.css';diff --git a/editor/src/styles/loading-overlay.css b/editor/src/styles/loading-overlay.cssnew file mode 100644index 000000000..a92698c45--- /dev/null+++ b/editor/src/styles/loading-overlay.css@@ -0,0 +1,65 @@+.es-loading-overlay {+ position: absolute;+ inset: 0;+ z-index: 10000;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ gap: 24px;+ background: var(--es-bg-primary);+ font-family: var(--es-font-family);+ opacity: 1;+ transition: opacity 400ms ease-out;+}++.es-loading-overlay--fade-out {+ opacity: 0;+ pointer-events: none;+}++.es-loading-logo {+ display: flex;+ align-items: center;+ justify-content: center;+}++.es-loading-logo svg {+ border-radius: var(--es-radius-xl);+}++.es-loading-progress {+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 12px;+ width: 200px;+}++.es-loading-bar-track {+ width: 100%;+ height: 3px;+ background: var(--es-bg-tertiary);+ border-radius: var(--es-radius-full);+ overflow: hidden;+}++.es-loading-bar-fill {+ height: 100%;+ width: 30%;+ background: var(--es-accent);+ border-radius: var(--es-radius-full);+ animation: es-loading-slide 1.2s ease-in-out infinite;+}++@keyframes es-loading-slide {+ 0% { transform: translateX(-100%); }+ 50% { transform: translateX(250%); }+ 100% { transform: translateX(-100%); }+}++.es-loading-status {+ font-size: var(--es-font-sm);+ color: var(--es-text-secondary);+ letter-spacing: 0.3px;+}diff --git a/editor/src/ui/LoadingOverlay.ts b/editor/src/ui/LoadingOverlay.tsnew file mode 100644index 000000000..b45dd80d0--- /dev/null+++ b/editor/src/ui/LoadingOverlay.ts@@ -0,0 +1,33 @@+import { icons } from '../utils/icons';++export class LoadingOverlay {+ private el_: HTMLElement;+ private statusEl_: HTMLElement;++ constructor(container: HTMLElement) {+ this.el_ = document.createElement('div');+ this.el_.className = 'es-loading-overlay';+ this.el_.innerHTML = `+ <div class="es-loading-logo">${icons.logo(56)}</div>+ <div class="es-loading-progress">+ <div class="es-loading-bar-track">+ <div class="es-loading-bar-fill"></div>+ </div>+ <div class="es-loading-status">Loading...</div>+ </div>+ `;+ this.statusEl_ = this.el_.querySelector('.es-loading-status')!;+ container.appendChild(this.el_);+ }++ setStatus(text: string): void {+ this.statusEl_.textContent = text;+ }++ dismiss(): void {+ this.el_.classList.add('es-loading-overlay--fade-out');+ this.el_.addEventListener('transitionend', () => {+ this.el_.remove();+ }, { once: true });+ }+}