3D viewer: switch STEP engine to occt-wasm (OCCT V8, module worker); fix mobile rendering (Uint16 chunking, index wrapping, tight near/far); state-coloured box + debug line; app widget parity; licenses/docs
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user