3D viewer overhaul: full-bleed + responsive, Web Worker STEP parse, progress bar, caption stats, inline models in text notes, STL fix, app widget; weekday dates (dateText); fix shields badge escaping; docs + licenses

This commit is contained in:
trilium-share-gruvbox
2026-08-28 18:15:50 +02:00
parent 3968011e3c
commit 41ec295954
9 changed files with 544 additions and 56 deletions
+38
View File
@@ -0,0 +1,38 @@
self.onmessage = function (e) {
var d = e.data;
if (d.type === 'loadLib') {
try { importScripts(d.libUrl); } catch (err) {
self.postMessage({ type: 'error', message: 'importScripts: ' + (err && err.message || err) }); return;
}
if (typeof self.occtimportjs !== 'function') {
self.postMessage({ type: 'error', message: 'STEP parser not found.' }); return;
}
self.occtimportjs({ locateFile: function () { return 'occt.wasm'; }, wasmBinary: d.wasm }).then(function (occt) {
self.occt = occt;
self.postMessage({ type: 'ready' });
}).catch(function (err) {
self.postMessage({ type: 'error', message: 'STEP init: ' + (err && err.message || err) });
});
return;
}
if (d.type === 'parse' && self.occt) {
try {
var result = self.occt.ReadStepFile(d.data, d.params);
var meshes = [];
(result.meshes || []).forEach(function (m) {
if (!m.attributes || !m.attributes.position) return;
var out = { position: m.attributes.position.array, color: m.color };
if (m.attributes.index && m.attributes.index.array) out.index = m.attributes.index.array;
meshes.push(out);
});
var transfer = [];
meshes.forEach(function (m) {
if (m.position && m.position.buffer) transfer.push(m.position.buffer);
if (m.index && m.index.buffer) transfer.push(m.index.buffer);
});
self.postMessage({ type: 'done', success: !!result.success, meshes: meshes }, transfer);
} catch (err) {
self.postMessage({ type: 'error', message: 'parse: ' + (err && err.message || err) });
}
}
};