Stage WebGL scene loading

This commit is contained in:
2026-06-07 12:08:13 +02:00
parent 1b593c8c7b
commit de81a7c5c5
7 changed files with 73 additions and 16 deletions
+12 -7
View File
@@ -10,7 +10,7 @@ const DEFAULT_BOOK_PROGRESS = 0.5;
class WebGLBookSceneModule extends BaseModule {
constructor() {
super('webgl-book-scene', 'WebGL Book Scene');
this.dependencies = ['persistence-manager', 'localization'];
this.dependencies = ['persistence-manager', 'localization', 'book-texture-renderer'];
this.persistenceManager = null;
this.localization = null;
this.mode = '2d';
@@ -73,6 +73,8 @@ class WebGLBookSceneModule extends BaseModule {
this.reportProgress(35, 'Creating WebGL host');
this.ensureShell();
this.installPreferenceBridge();
this.reportProgress(45, 'Loading WebGL scene modules');
await this.initializeScene();
this.reportProgress(100, 'WebGL book host ready');
return true;
@@ -173,7 +175,10 @@ class WebGLBookSceneModule extends BaseModule {
window.WebGLBookInitialState = {
appMode: true,
pageCount,
progress
progress,
reportProgress: (percent, message) => {
this.reportProgress(percent, message);
}
};
}
@@ -293,6 +298,10 @@ class WebGLBookSceneModule extends BaseModule {
const cacheBuster = window.MODULE_CACHE_BUSTER || Date.now();
this.labImportPromise = import(`/js/webgl-book-lab.js?v=${encodeURIComponent(cacheBuster)}`);
await this.labImportPromise;
this.reportProgress(94, 'Uploading initial book page textures');
window.BookTextureRenderer?.publishSpread?.();
await new Promise(resolve => requestAnimationFrame(resolve));
this.reportProgress(96, 'Binding WebGL page controls');
this.installTextureEventBridge();
this.triggerTextureRefresh();
return this.labImportPromise;
@@ -459,11 +468,7 @@ class WebGLBookSceneModule extends BaseModule {
if (this.mode === '3d') {
this.createLabHost();
this.installPreferenceBridge();
this.initializeScene()
.then(() => this.triggerTextureRefresh())
.catch((error) => {
console.error('WebGLBookScene: Failed to initialize procedural scene', error);
});
if (this.labImportPromise) this.triggerTextureRefresh();
}
const title = document.getElementById('game_title')?.textContent?.trim();
const label = document.getElementById('lab_title');