← All Pull Requests

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

Merged opened by John Lauer 2026-10-11

The wiki wraps every widget in its own click-to-load slot, so readers had to click twice: the wiki's "Load adom-3d", then the widget's "Load 3D model". The widget now starts loading as soon as its frame opens; Unload, offscreen disposal and Load 3D model to bring it back are unchanged.

🤖 Generated with Claude Code

Diff Skip to comments

--- a/widgets/model-3d-widget.js+++ b/widgets/model-3d-widget.js@@ -1,124 +1,127 @@⋯ 8 unchanged lines ⋯  * - 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:.  */ (() => {⋯ 41 unchanged lines ⋯         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'); } ⋯ 57 unchanged lines ⋯   }   if (!customElements.get('adom-3d')) customElements.define('adom-3d', Adom3D); })();+

Comments

No comments yet.

Log in to comment.