← Commit history

Merge PR #218: adom-3d: load the model when the frame opens (the wiki slot is already the click)

John Lauer ·97252c9abc ·9d ago ·parent badf20d
1 file changed +5−3
widgets/model-3d-widget.js+5−3
@@ -9,9 +9,10 @@  * - poster: optional still shown until the reader asks for 3D (a render or screenshot of the same model).  * - heading: optional title over the view; caption: optional line under it.  *- * Nothing heavy loads on the page path: no viewer bundle, no WebGL context and no GLB until the reader clicks- * "Load 3D model" (adom/wiki#1292). Scrolling it well offscreen, unloading it or leaving the page disposes the- * viewer and releases the WebGL context. The model is fetched as bytes and handed to loadModelBytes, and the+ * Nothing heavy loads on the page path (adom/wiki#1292): the wiki puts every widget in a click-to-load slot, so+ * this frame only exists once the reader asked for it, and the model then loads straight away (one click, not+ * two). Unload, scrolling it well offscreen or leaving the page disposes the+ * viewer and releases the WebGL context; Load 3D model brings it back. The model is fetched as bytes and handed to loadModelBytes, and the  * GLB's embedded textures are given out as data: URLs, because the frame's img-src forbids blob:.  */ (() => {@@ -59,6 +60,7 @@         for (const e of es) if (!e.isIntersecting && this._viewer && !this._loading) this._unload('offscreen');       }, { rootMargin: '600px 0px' });       this._io.observe(this);+      if (this._src) this._load();   // the wiki slot already was the reader's click     }     disconnectedCallback() { this._io && this._io.disconnect(); this._unload('removed'); }