Spaces:
Running
Running
fix: destroy and recreate model-viewer to prevent stale mesh display
Browse files- index.html +40 -8
index.html
CHANGED
|
@@ -904,9 +904,7 @@
|
|
| 904 |
document.getElementById('angle-display').textContent = '00';
|
| 905 |
|
| 906 |
// Reset 3D viewer
|
| 907 |
-
|
| 908 |
-
v.removeAttribute('src');
|
| 909 |
-
v.style.visibility = 'visible';
|
| 910 |
|
| 911 |
// Reset thumbnails
|
| 912 |
document.getElementById('ref-thumb-2').style.display = 'none';
|
|
@@ -1007,6 +1005,18 @@
|
|
| 1007 |
async function startGeneration() {
|
| 1008 |
if (!currentFile) return;
|
| 1009 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1010 |
showLoading();
|
| 1011 |
startProgressListener();
|
| 1012 |
try {
|
|
@@ -1141,14 +1151,36 @@
|
|
| 1141 |
if (active) active.classList.add('active');
|
| 1142 |
}
|
| 1143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1144 |
async function startExtraction() {
|
| 1145 |
if (!generationResult) return;
|
| 1146 |
|
| 1147 |
-
//
|
| 1148 |
-
|
| 1149 |
-
|
| 1150 |
-
//
|
| 1151 |
-
viewer
|
| 1152 |
|
| 1153 |
showLoading();
|
| 1154 |
startProgressListener();
|
|
|
|
| 904 |
document.getElementById('angle-display').textContent = '00';
|
| 905 |
|
| 906 |
// Reset 3D viewer
|
| 907 |
+
resetModelViewer();
|
|
|
|
|
|
|
| 908 |
|
| 909 |
// Reset thumbnails
|
| 910 |
document.getElementById('ref-thumb-2').style.display = 'none';
|
|
|
|
| 1005 |
async function startGeneration() {
|
| 1006 |
if (!currentFile) return;
|
| 1007 |
|
| 1008 |
+
// Clear old preview frames and 3D result
|
| 1009 |
+
generationResult = null;
|
| 1010 |
+
document.getElementById('frame-container').innerHTML = '';
|
| 1011 |
+
document.getElementById('angle-slider').value = 0;
|
| 1012 |
+
document.getElementById('angle-display').textContent = '00';
|
| 1013 |
+
resetModelViewer();
|
| 1014 |
+
document.getElementById('extract-btn').style.display = 'none';
|
| 1015 |
+
document.getElementById('download-btn').style.display = 'none';
|
| 1016 |
+
|
| 1017 |
+
// Stay on step 1 during generation
|
| 1018 |
+
setStep(1);
|
| 1019 |
+
|
| 1020 |
showLoading();
|
| 1021 |
startProgressListener();
|
| 1022 |
try {
|
|
|
|
| 1151 |
if (active) active.classList.add('active');
|
| 1152 |
}
|
| 1153 |
|
| 1154 |
+
// Destroy and recreate model-viewer to fully purge old mesh from WebGL
|
| 1155 |
+
function resetModelViewer() {
|
| 1156 |
+
const container = document.querySelector('#panel-3 .viewer-wrapper');
|
| 1157 |
+
const old = document.getElementById('main-3d-viewer');
|
| 1158 |
+
if (old) old.remove();
|
| 1159 |
+
const mv = document.createElement('model-viewer');
|
| 1160 |
+
mv.id = 'main-3d-viewer';
|
| 1161 |
+
mv.setAttribute('camera-controls', '');
|
| 1162 |
+
mv.setAttribute('auto-rotate', '');
|
| 1163 |
+
mv.setAttribute('camera-orbit', '-180deg 90deg auto');
|
| 1164 |
+
mv.setAttribute('shadow-intensity', '1.5');
|
| 1165 |
+
mv.setAttribute('environment-image', 'neutral');
|
| 1166 |
+
mv.setAttribute('exposure', '1.2');
|
| 1167 |
+
mv.style.width = '100%';
|
| 1168 |
+
mv.style.height = '100%';
|
| 1169 |
+
mv.style.background = 'radial-gradient(circle at 50% 50%, #1a2235 0%, #0b0f1a 100%)';
|
| 1170 |
+
mv.style.visibility = 'hidden';
|
| 1171 |
+
mv.innerHTML = '<div slot="progress-bar" style="background: var(--primary); height: 4px;"></div>';
|
| 1172 |
+
container.appendChild(mv);
|
| 1173 |
+
return mv;
|
| 1174 |
+
}
|
| 1175 |
+
|
| 1176 |
async function startExtraction() {
|
| 1177 |
if (!generationResult) return;
|
| 1178 |
|
| 1179 |
+
// Switch away from panel-3 immediately so user won't see stale mesh
|
| 1180 |
+
if (currentStep === 3) setStep(2);
|
| 1181 |
+
|
| 1182 |
+
// Destroy old model-viewer and create a fresh one (purges WebGL scene completely)
|
| 1183 |
+
const viewer = resetModelViewer();
|
| 1184 |
|
| 1185 |
showLoading();
|
| 1186 |
startProgressListener();
|