Add asset file download indicator to the loading screen.
This provides visual feedback to the user while loading large models. PiperOrigin-RevId: 918708877 Change-Id: I77ea475cce6d9718e6cf8b33cb72b3f524a6ee63
This commit is contained in:
committed by
Copybara-Service
parent
7174d33f08
commit
7c47a89cd0
@@ -71,8 +71,17 @@ class AssetRegistry {
|
|||||||
// The caller is responsible for freeing the buffer. Returns 0 on failure.
|
// The caller is responsible for freeing the buffer. Returns 0 on failure.
|
||||||
EM_ASYNC_JS(int, FetchUrl,
|
EM_ASYNC_JS(int, FetchUrl,
|
||||||
(const char* url, char** out_data, std::int32_t* out_size), {
|
(const char* url, char** out_data, std::int32_t* out_size), {
|
||||||
|
const urlStr = UTF8ToString(url);
|
||||||
|
const filename = urlStr.split('/').pop() || urlStr;
|
||||||
|
const dlEl = document.getElementById('loadingDownload');
|
||||||
|
const dlFileEl = document.getElementById('loadingDownloadFile');
|
||||||
|
if (dlEl) {
|
||||||
|
dlEl.style.display = 'block';
|
||||||
|
}
|
||||||
|
if (dlFileEl) {
|
||||||
|
dlFileEl.textContent = filename + '\u2026';
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const urlStr = UTF8ToString(url);
|
|
||||||
const response = await fetch(urlStr);
|
const response = await fetch(urlStr);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.error('Fetch failed: ' + response.status + ' ' +
|
console.error('Fetch failed: ' + response.status + ' ' +
|
||||||
@@ -89,6 +98,13 @@ EM_ASYNC_JS(int, FetchUrl,
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Fetch error:', e);
|
console.error('Fetch error:', e);
|
||||||
return 0;
|
return 0;
|
||||||
|
} finally {
|
||||||
|
if (dlEl) {
|
||||||
|
dlEl.style.display = 'none';
|
||||||
|
}
|
||||||
|
if (dlFileEl) {
|
||||||
|
dlFileEl.textContent = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,17 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
.loading-download {
|
||||||
|
display: none;
|
||||||
|
margin-top: 24px;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
.loading-download-label {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
.loading-download-file {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
#dropOverlay {
|
#dropOverlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
<div class="loading-container">
|
<div class="loading-container">
|
||||||
<div class="loading-title">Loading model…</div>
|
<div class="loading-title">Loading model…</div>
|
||||||
<div class="loading-subtitle">This may take a moment for large models.</div>
|
<div class="loading-subtitle">This may take a moment for large models.</div>
|
||||||
|
<div id="loadingDownload" class="loading-download">
|
||||||
|
<div class="loading-download-label">Downloading asset file</div>
|
||||||
|
<div id="loadingDownloadFile" class="loading-download-file"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="dropOverlay">
|
<div id="dropOverlay">
|
||||||
|
|||||||
Reference in New Issue
Block a user