@preference-sl/pref-viewer 2.13.0-beta.10 → 2.13.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/gltf-resolver.js +2 -1
- package/src/gltf-storage.js +20 -1
package/package.json
CHANGED
package/src/gltf-resolver.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FileStorage from "./file-storage.js";
|
|
2
|
-
import { initDb, loadModel } from "./gltf-storage.js";
|
|
2
|
+
import { closeDb, initDb, loadModel } from "./gltf-storage.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* GLTFResolver - Utility class for resolving, decoding, and preparing glTF/GLB assets from various sources.
|
|
@@ -240,6 +240,7 @@ export default class GLTFResolver {
|
|
|
240
240
|
dispose() {
|
|
241
241
|
this.#fileStorage?.dispose?.();
|
|
242
242
|
this.#fileStorage = null;
|
|
243
|
+
closeDb();
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
/**
|
package/src/gltf-storage.js
CHANGED
|
@@ -94,12 +94,31 @@ export function loadModel(modelId, storeName) {
|
|
|
94
94
|
|
|
95
95
|
// Descargar archivo desde base64
|
|
96
96
|
export function downloadFileFromBytes(fileName, bytesBase64, mimeType) {
|
|
97
|
+
let objectURL = null;
|
|
97
98
|
const link = document.createElement("a");
|
|
98
99
|
link.download = fileName;
|
|
99
|
-
|
|
100
|
+
try {
|
|
101
|
+
const decoded = atob(bytesBase64);
|
|
102
|
+
const bytes = new Uint8Array(decoded.length);
|
|
103
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
104
|
+
bytes[i] = decoded.charCodeAt(i);
|
|
105
|
+
}
|
|
106
|
+
const blob = new Blob([bytes], { type: mimeType || "application/octet-stream" });
|
|
107
|
+
objectURL = URL.createObjectURL(blob);
|
|
108
|
+
link.href = objectURL;
|
|
109
|
+
} catch {
|
|
110
|
+
// Fallback if base64 decoding fails for any reason.
|
|
111
|
+
link.href = `data:${mimeType};base64,${bytesBase64}`;
|
|
112
|
+
}
|
|
100
113
|
document.body.appendChild(link);
|
|
101
114
|
link.click();
|
|
115
|
+
link.href = "";
|
|
102
116
|
link.remove();
|
|
117
|
+
if (objectURL) {
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
URL.revokeObjectURL(objectURL);
|
|
120
|
+
}, 0);
|
|
121
|
+
}
|
|
103
122
|
}
|
|
104
123
|
|
|
105
124
|
// Obtener todos los modelos (solo metadata)
|