Spaces:
Running
Running
Update viewer.js
Browse files
viewer.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
let pc; // PlayCanvas
|
| 2 |
export let app = null;
|
| 3 |
let cameraEntity = null;
|
|
@@ -154,7 +156,7 @@ export async function initializeViewer(config, instanceId) {
|
|
| 154 |
orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-gs.static.hf.space/orbit-camera.js" }),
|
| 155 |
galerie: new pc.Asset('galerie', 'container', { url: glbUrl }),
|
| 156 |
hdr: new pc.Asset('hdr', 'texture', {
|
| 157 |
-
url: https://huggingface.co/datasets/bilca/ply_files/resolve/main/galeries/blanc.png
|
| 158 |
}, { type: pc.TEXTURETYPE_RGBP, mipmaps: false })
|
| 159 |
};
|
| 160 |
|
|
@@ -166,7 +168,7 @@ export async function initializeViewer(config, instanceId) {
|
|
| 166 |
// 90MB is a big PLY!
|
| 167 |
loadTimeout = setTimeout(() => {
|
| 168 |
alert("⚠️ 3D model loading is taking unusually long on your device. Large PLY files (>40MB) may exceed memory limits on iOS Safari and cannot be shown. Try a smaller model, or use a desktop browser for best results.");
|
| 169 |
-
progressDialog.innerHTML =
|
| 170 |
}, 20000); // 20 seconds
|
| 171 |
}
|
| 172 |
|
|
@@ -175,16 +177,16 @@ export async function initializeViewer(config, instanceId) {
|
|
| 175 |
progressDialog.style.display = 'none';
|
| 176 |
if (assets.model.resource && assets.model.resource._buffer) {
|
| 177 |
let buf = assets.model.resource._buffer;
|
| 178 |
-
logAndAlert([viewer.js] PLY/GSplat asset loaded! Buffer byteLength: ${buf.byteLength || buf.length || 'n/a'});
|
| 179 |
} else {
|
| 180 |
-
logAndAlert([viewer.js] PLY/GSplat asset loaded! [NO BUFFER?]);
|
| 181 |
}
|
| 182 |
});
|
| 183 |
|
| 184 |
assets.model.on('error', err => {
|
| 185 |
if (loadTimeout) { clearTimeout(loadTimeout); loadTimeout = null; }
|
| 186 |
logAndAlert('[viewer.js] Error loading model: ' + err);
|
| 187 |
-
progressDialog.innerHTML =
|
| 188 |
});
|
| 189 |
|
| 190 |
const progCheck = setInterval(() => {
|
|
@@ -336,7 +338,7 @@ export async function initializeViewer(config, instanceId) {
|
|
| 336 |
} catch (error) {
|
| 337 |
if (loadTimeout) { clearTimeout(loadTimeout); loadTimeout = null; }
|
| 338 |
logAndAlert("[viewer.js] Error initializing PlayCanvas viewer: " + error.message);
|
| 339 |
-
progressDialog.innerHTML =
|
| 340 |
}
|
| 341 |
}
|
| 342 |
|
|
@@ -401,4 +403,4 @@ export function cleanupViewer() {
|
|
| 401 |
resizeObserver.disconnect();
|
| 402 |
resizeObserver = null;
|
| 403 |
}
|
| 404 |
-
}
|
|
|
|
| 1 |
+
// viewer.js
|
| 2 |
+
|
| 3 |
let pc; // PlayCanvas
|
| 4 |
export let app = null;
|
| 5 |
let cameraEntity = null;
|
|
|
|
| 156 |
orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-gs.static.hf.space/orbit-camera.js" }),
|
| 157 |
galerie: new pc.Asset('galerie', 'container', { url: glbUrl }),
|
| 158 |
hdr: new pc.Asset('hdr', 'texture', {
|
| 159 |
+
url: `https://huggingface.co/datasets/bilca/ply_files/resolve/main/galeries/blanc.png`
|
| 160 |
}, { type: pc.TEXTURETYPE_RGBP, mipmaps: false })
|
| 161 |
};
|
| 162 |
|
|
|
|
| 168 |
// 90MB is a big PLY!
|
| 169 |
loadTimeout = setTimeout(() => {
|
| 170 |
alert("⚠️ 3D model loading is taking unusually long on your device. Large PLY files (>40MB) may exceed memory limits on iOS Safari and cannot be shown. Try a smaller model, or use a desktop browser for best results.");
|
| 171 |
+
progressDialog.innerHTML = `<p style="color:red">Loading failed or too slow. Try a smaller model, or use a desktop browser.</p>`;
|
| 172 |
}, 20000); // 20 seconds
|
| 173 |
}
|
| 174 |
|
|
|
|
| 177 |
progressDialog.style.display = 'none';
|
| 178 |
if (assets.model.resource && assets.model.resource._buffer) {
|
| 179 |
let buf = assets.model.resource._buffer;
|
| 180 |
+
logAndAlert(`[viewer.js] PLY/GSplat asset loaded! Buffer byteLength: ${buf.byteLength || buf.length || 'n/a'}`);
|
| 181 |
} else {
|
| 182 |
+
logAndAlert(`[viewer.js] PLY/GSplat asset loaded! [NO BUFFER?]`);
|
| 183 |
}
|
| 184 |
});
|
| 185 |
|
| 186 |
assets.model.on('error', err => {
|
| 187 |
if (loadTimeout) { clearTimeout(loadTimeout); loadTimeout = null; }
|
| 188 |
logAndAlert('[viewer.js] Error loading model: ' + err);
|
| 189 |
+
progressDialog.innerHTML = `<p style="color: red">Error loading model: ${err}</p>`;
|
| 190 |
});
|
| 191 |
|
| 192 |
const progCheck = setInterval(() => {
|
|
|
|
| 338 |
} catch (error) {
|
| 339 |
if (loadTimeout) { clearTimeout(loadTimeout); loadTimeout = null; }
|
| 340 |
logAndAlert("[viewer.js] Error initializing PlayCanvas viewer: " + error.message);
|
| 341 |
+
progressDialog.innerHTML = `<p style="color: red">Error loading viewer: ${error.message}</p>`;
|
| 342 |
}
|
| 343 |
}
|
| 344 |
|
|
|
|
| 403 |
resizeObserver.disconnect();
|
| 404 |
resizeObserver = null;
|
| 405 |
}
|
| 406 |
+
}
|