Spaces:
Running
Running
Update interface.js
Browse files- interface.js +14 -10
interface.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
// ==============================
|
| 2 |
// interface.js
|
| 3 |
// ==============================
|
|
@@ -182,7 +183,7 @@ const currentScriptTag = document.currentScript;
|
|
| 182 |
// βββ 7. Dynamically load viewer.js βββββββββββββββββββββββββββββββββββββββββ
|
| 183 |
let viewerModule;
|
| 184 |
try {
|
| 185 |
-
viewerModule = await import('
|
| 186 |
await viewerModule.initializeViewer(config, instanceId);
|
| 187 |
} catch (err) {
|
| 188 |
console.error("Failed to load viewer.js or initialize the 3D viewer:", err);
|
|
@@ -212,9 +213,6 @@ const currentScriptTag = document.currentScript;
|
|
| 212 |
const computedWidget = window.getComputedStyle(widgetContainer);
|
| 213 |
const computedViewer = window.getComputedStyle(viewerContainerElem);
|
| 214 |
const originalAspect = widgetContainer.getAttribute('data-original-aspect') || aspectPercent;
|
| 215 |
-
const containerWidth = widgetContainer.offsetWidth;
|
| 216 |
-
const containerHeight = widgetContainer.clientHeight || viewerContainerElem.offsetHeight;
|
| 217 |
-
const calculatedRatio = (containerHeight / containerWidth * 100) + '%';
|
| 218 |
savedState = {
|
| 219 |
widget: {
|
| 220 |
position: widgetContainer.style.position,
|
|
@@ -236,7 +234,7 @@ const currentScriptTag = document.currentScript;
|
|
| 236 |
|
| 237 |
function restoreOriginalStyles() {
|
| 238 |
if (!savedState) return;
|
| 239 |
-
|
| 240 |
widgetContainer.style.position = savedState.widget.position || "";
|
| 241 |
widgetContainer.style.top = savedState.widget.top || "";
|
| 242 |
widgetContainer.style.left = savedState.widget.left || "";
|
|
@@ -259,10 +257,12 @@ const currentScriptTag = document.currentScript;
|
|
| 259 |
viewerContainerElem.style.border = savedState.viewer.border || "";
|
| 260 |
|
| 261 |
if (viewerModule.app) {
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
|
|
|
| 265 |
}
|
|
|
|
| 266 |
savedState = null;
|
| 267 |
}
|
| 268 |
|
|
@@ -287,6 +287,7 @@ const currentScriptTag = document.currentScript;
|
|
| 287 |
if (viewerModule.app) {
|
| 288 |
viewerModule.app.resizeCanvas(window.innerWidth, window.innerHeight);
|
| 289 |
}
|
|
|
|
| 290 |
fullscreenToggle.textContent = 'β²';
|
| 291 |
isFullscreen = true;
|
| 292 |
}
|
|
@@ -346,7 +347,7 @@ const currentScriptTag = document.currentScript;
|
|
| 346 |
|
| 347 |
if (tooltipsToggleBtn) {
|
| 348 |
let tooltipsVisible = !!config.showTooltipsDefault;
|
| 349 |
-
|
| 350 |
tooltipsToggleBtn.addEventListener('click', () => {
|
| 351 |
hideTooltipPanel();
|
| 352 |
tooltipsVisible = !tooltipsVisible;
|
|
@@ -386,7 +387,10 @@ const currentScriptTag = document.currentScript;
|
|
| 386 |
if (isFullscreen) {
|
| 387 |
viewerModule.app.resizeCanvas(window.innerWidth, window.innerHeight);
|
| 388 |
} else {
|
| 389 |
-
viewerModule.app.resizeCanvas(
|
|
|
|
|
|
|
|
|
|
| 390 |
}
|
| 391 |
}
|
| 392 |
});
|
|
|
|
| 1 |
+
// interface.js
|
| 2 |
// ==============================
|
| 3 |
// interface.js
|
| 4 |
// ==============================
|
|
|
|
| 183 |
// βββ 7. Dynamically load viewer.js βββββββββββββββββββββββββββββββββββββββββ
|
| 184 |
let viewerModule;
|
| 185 |
try {
|
| 186 |
+
viewerModule = await import('https://mikafil-viewer-gs.static.hf.space/viewer.js');
|
| 187 |
await viewerModule.initializeViewer(config, instanceId);
|
| 188 |
} catch (err) {
|
| 189 |
console.error("Failed to load viewer.js or initialize the 3D viewer:", err);
|
|
|
|
| 213 |
const computedWidget = window.getComputedStyle(widgetContainer);
|
| 214 |
const computedViewer = window.getComputedStyle(viewerContainerElem);
|
| 215 |
const originalAspect = widgetContainer.getAttribute('data-original-aspect') || aspectPercent;
|
|
|
|
|
|
|
|
|
|
| 216 |
savedState = {
|
| 217 |
widget: {
|
| 218 |
position: widgetContainer.style.position,
|
|
|
|
| 234 |
|
| 235 |
function restoreOriginalStyles() {
|
| 236 |
if (!savedState) return;
|
| 237 |
+
const aspectToUse = savedState.widget.paddingBottom;
|
| 238 |
widgetContainer.style.position = savedState.widget.position || "";
|
| 239 |
widgetContainer.style.top = savedState.widget.top || "";
|
| 240 |
widgetContainer.style.left = savedState.widget.left || "";
|
|
|
|
| 257 |
viewerContainerElem.style.border = savedState.viewer.border || "";
|
| 258 |
|
| 259 |
if (viewerModule.app) {
|
| 260 |
+
viewerModule.app.resizeCanvas(
|
| 261 |
+
viewerContainerElem.clientWidth,
|
| 262 |
+
viewerContainerElem.clientHeight
|
| 263 |
+
);
|
| 264 |
}
|
| 265 |
+
|
| 266 |
savedState = null;
|
| 267 |
}
|
| 268 |
|
|
|
|
| 287 |
if (viewerModule.app) {
|
| 288 |
viewerModule.app.resizeCanvas(window.innerWidth, window.innerHeight);
|
| 289 |
}
|
| 290 |
+
|
| 291 |
fullscreenToggle.textContent = 'β²';
|
| 292 |
isFullscreen = true;
|
| 293 |
}
|
|
|
|
| 347 |
|
| 348 |
if (tooltipsToggleBtn) {
|
| 349 |
let tooltipsVisible = !!config.showTooltipsDefault;
|
| 350 |
+
tooltipsToggleBtn.style.opacity = tooltipsVisible ? '1' : '0.5';
|
| 351 |
tooltipsToggleBtn.addEventListener('click', () => {
|
| 352 |
hideTooltipPanel();
|
| 353 |
tooltipsVisible = !tooltipsVisible;
|
|
|
|
| 387 |
if (isFullscreen) {
|
| 388 |
viewerModule.app.resizeCanvas(window.innerWidth, window.innerHeight);
|
| 389 |
} else {
|
| 390 |
+
viewerModule.app.resizeCanvas(
|
| 391 |
+
viewerContainerElem.clientWidth,
|
| 392 |
+
viewerContainerElem.clientHeight
|
| 393 |
+
);
|
| 394 |
}
|
| 395 |
}
|
| 396 |
});
|