Add local 3D model viewer (three.js + occt-import-js) for STEP/STL, 8px box + caption; embed guide; licenses

This commit is contained in:
trilium-share-gruvbox
2026-08-28 15:24:56 +02:00
parent 11216f8996
commit e13a5433d9
11 changed files with 1752 additions and 1 deletions
+9
View File
@@ -22,6 +22,7 @@ CSS file (Gruvbox, light + dark, theme toggle without reload).
| `theme/blog_share_theme.css` | `blog_share_theme.css` (`shareCss`) | the entire Gruvbox theme |
| `theme/favicon.svg`, `theme/cookie.woff2` | `favicon`, `Cookie` | site icon + BMC font |
| `lib/highlight.js`, `lib/hljs_line_numbers.js` | `highlight.js`, `hljs line numbers plugin` | code highlighting |
| `lib/3d/*` | three.js, OrbitControls, STLLoader, occt-import-js (WASM) | local libraries for the 3D model viewer |
| `scripts/*.js` | one code note each (`.blog`), attached via `~shareHtml` | frontend snippets (verbatim content incl. `<script>`) |
| `templates/blog_article.html` | `Blog Article` | article template with promoted labels |
| `examples/*` | ignis8 icons/script | sample category logo |
@@ -80,6 +81,12 @@ CSS file (Gruvbox, light + dark, theme toggle without reload).
- Embedded images: `#content img:not(.blog-thumb) { border-radius:8px }`.
- **Figure captions**: `#content figcaption` is a Gruvbox chip (secondary bg, highlight
border, 8px radius, muted italic text, centered).
- **3D models** (`scripts/3d_model_viewer.js`): `.step`/`.stp`/`.stl` file notes (title ends
in the extension) or inline attachment links (link text ends in the extension) get an
interactive three.js viewer (drag/zoom), 8px rounded box + caption. STEP is parsed by
occt-import-js (OpenCascade WASM). All five libraries are hosted as local notes and
referenced via `__THREE_ID__`/`__THREE_ORBIT_ID__`/`__THREE_STL_ID__`/`__OCCT_JS_ID__`/
`__OCCT_WASM_ID__`. User guide: `docs/embed-3d-model.md`.
- Images in the share are served full-size only (no resize endpoint) → keep the
`_thumb` child-note convention for small thumbnails.
- Built-in share footer navigation and book children list are hidden
@@ -92,6 +99,8 @@ CSS file (Gruvbox, light + dark, theme toggle without reload).
`fs`, `child_process`, `http` etc. are blocked. Therefore **image resizing inside a
backend script is impossible** without patching Trilium source. Do not attempt to add
sharp-based code to the generator.
- `occt-import-js` / OpenCASCADE (used by the 3D viewer) is **LGPL-2.1** (see
`THIRD_PARTY_LICENSES.md`); three.js is MIT. Both are hosted locally under `lib/3d/`.
- Triggering the generator via an attribute change on the **blog root itself** is ignored
by the self-trigger guard (`isGeneratedNoteId(BLOG_ROOT_ID) → true`). To force a full
regeneration, change an attribute/content on a **published article** instead.