Spaces:
Running
Running
Update viewer.js
Browse files
viewer.js
CHANGED
|
@@ -80,7 +80,7 @@ export async function initializeViewer(config, instanceId) {
|
|
| 80 |
window.pc = pc;
|
| 81 |
}
|
| 82 |
|
| 83 |
-
// ---
|
| 84 |
const assets = {
|
| 85 |
model: new pc.Asset('gsplat', 'gsplat', { url: plyUrl }),
|
| 86 |
orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-gs.static.hf.space/orbit-camera.js" }),
|
|
@@ -91,12 +91,19 @@ export async function initializeViewer(config, instanceId) {
|
|
| 91 |
),
|
| 92 |
};
|
| 93 |
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
loader.load(() => {
|
| 96 |
app.start();
|
| 97 |
progressDialog.style.display = 'none';
|
| 98 |
|
| 99 |
-
// ---
|
| 100 |
if (assets.hdr && assets.hdr.resource) {
|
| 101 |
app.scene.envAtlas = assets.hdr.resource;
|
| 102 |
}
|
|
|
|
| 80 |
window.pc = pc;
|
| 81 |
}
|
| 82 |
|
| 83 |
+
// --- HDR asset is now included AND registered ---
|
| 84 |
const assets = {
|
| 85 |
model: new pc.Asset('gsplat', 'gsplat', { url: plyUrl }),
|
| 86 |
orbit: new pc.Asset('script', 'script', { url: "https://mikafil-viewer-gs.static.hf.space/orbit-camera.js" }),
|
|
|
|
| 91 |
),
|
| 92 |
};
|
| 93 |
|
| 94 |
+
// Register all assets to app.assets so they are tracked and loaded
|
| 95 |
+
for (const key in assets) {
|
| 96 |
+
if (!app?.assets.get(assets[key].name)) {
|
| 97 |
+
app.assets.add(assets[key]);
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
const loader = new pc.AssetListLoader(Object.values(assets), app.assets);
|
| 102 |
loader.load(() => {
|
| 103 |
app.start();
|
| 104 |
progressDialog.style.display = 'none';
|
| 105 |
|
| 106 |
+
// --- Apply HDR environment if available ---
|
| 107 |
if (assets.hdr && assets.hdr.resource) {
|
| 108 |
app.scene.envAtlas = assets.hdr.resource;
|
| 109 |
}
|