diff --git a/AGENTS.md b/AGENTS.md index eac080b..f849b4a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -95,16 +95,25 @@ set the other labels, and set `publish=true` **last**. - **3D models** (`scripts/3d_model_viewer.js`): renders `.step`/`.stp`/`.stl` as file notes (title ends in the extension), inline attachment links, or links to published model file notes from text notes (resolved via `window.blogData`). The viewer is **full-bleed** - (`~100vw`, `height: min(70vh, 900px)`, ResizeObserver), with a loading progress bar and a - caption that always shows `name · size · triangle count`. STEP is parsed by occt-import-js - (OpenCascade WASM) in a **Web Worker** (non-blocking) with - `linearDeflection: 0.0002, angularDeflection: 0.1`. Libraries hosted as local notes via + (`~100vw`, `height: min(70vh, 900px)`, ResizeObserver), with a loading progress bar, a + caption that shows `name · size · triangle count`, and a **debug line** under the box that + logs the step (`loading`/`parsing`/`done`/`error`) for on-device diagnosis. STEP is parsed + by **occt-wasm** (OpenCASCADE **V8**, MIT/Apache-2.0) in a **module worker** + (`new Worker(url, {type:"module"})`, non-blocking) with + `linearDeflection: 0.4, angularDeflection: 0.2`. Libraries hosted as local notes via `__THREE_ID__`/`__THREE_ORBIT_ID__`/`__THREE_STL_ID__`/`__OCCT_JS_ID__`/`__OCCT_WASM_ID__`. User guide: `docs/embed-3d-model.md`. + - **Mobile gotchas (both were real bugs)**: (1) mesh >65535 vertices must be split into + chunks with `Uint16` indices (`chunkGeometry`) or mobile GPUs without + `OES_element_index_uint` render nothing; (2) `geometry.setIndex(rawTypedArray)` in + three r128 leaves `geometry.index` WITHOUT `.count` → always wrap: + `setIndex(new THREE.BufferAttribute(index, 1))`; (3) tighten camera `near`/`far` from the + model size after `fit()` (`near=d·0.05, far=d·10`) for 16-bit depth buffers. - **3D viewer in the Trilium app** (independent of the blog): `app/3d-model-viewer-app.jsx` (widget, `#widget=3dModelViewer`, `parent: note-detail-pane`) + `app/3d-worker.js` (STEP - worker, loaded from a code note instead of a Blob so the app CSP allows it). The widget - renders the viewer for file notes whose title ends in `.step`/`.stp`/`.stl`. + module worker that imports the occt-wasm bundle from a code note, so it works under the + app's CSP). The widget renders the viewer for file notes whose title ends in + `.step`/`.stp`/`.stl`. - 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 diff --git a/README.md b/README.md index b268a32..0450641 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,12 @@ no external dependencies (except `highlight.js`, vendored in `lib/`). - **Widget rendering** for Mermaid, Excalidraw (canvas) and MindElixir (mind map) notes, with a collapsible, highlighted "Source" block and copy button. - **3D models**: `.step` / `.stp` / `.stl` files (as file notes, as inline attachments, or linked - from text notes) render in an interactive three.js viewer (STEP via occt-import-js, OpenCascade - WASM, parsed in a **Web Worker** so the page stays responsive). The viewer is **full-bleed** - (~`100vw`) with a viewport-based height, drag to rotate / scroll to zoom, rounded 8px box, a - loading progress bar and a caption that always shows `name · size · triangle count`. - STEP tessellation is dense (≈0.1–1 M+ triangles for assemblies). See - [docs/embed-3d-model.md](docs/embed-3d-model.md). + from text notes) render in an interactive three.js viewer (STEP via **occt-wasm**, OpenCASCADE + V8, parsed in a non-blocking **module worker**). The viewer is **full-bleed** (~`100vw`) with a + viewport-based height, drag to rotate / scroll to zoom, rounded 8px box, a loading progress bar, + a caption showing `name · size · triangle count`, and a small debug line. Large meshes are + split into `Uint16` chunks so mobile GPUs render them too (≈480k triangles for the demo + battery module). See [docs/embed-3d-model.md](docs/embed-3d-model.md). - **3D viewer inside Trilium (app widget)**: the same viewer runs in the Trilium app itself (independent of the blog) via a `note-detail-pane` widget – see `app/`. - Code highlighting (highlight.js + line numbers) and copy buttons on all code boxes. @@ -69,7 +69,7 @@ no external dependencies (except `highlight.js`, vendored in `lib/`). | `theme/favicon.svg` | default site favicon | code (SVG) | | `theme/cookie.woff2` | "Cookie" font for the Buy me a coffee button | file, `font/woff2` | | `lib/highlight.js` | vendored highlight.js | code, `application/javascript` | -| `lib/3d/*` | three.js + OrbitControls + STLLoader + occt-import-js (WASM) for the 3D viewer | code / file | +| `lib/3d/*` | three.js + OrbitControls + STLLoader + occt-wasm (OCCT V8 bundle + WASM) for the 3D viewer | code / file | | `lib/hljs_line_numbers.js` | highlight.js line-numbers plugin | code | | `scripts/*.js` | frontend share snippets (content is pasted **verbatim** into a code note, including the `