Spaces:
Running
Running
Update interface.js
Browse files- interface.js +12 -20
interface.js
CHANGED
|
@@ -95,7 +95,7 @@ const currentScriptTag = document.currentScript;
|
|
| 95 |
<button id="reset-camera-btn-${instanceId}" class="widget-button reset-camera-btn">
|
| 96 |
<span class="reset-icon">⟲</span>
|
| 97 |
</button>
|
| 98 |
-
<button id="points-toggle-${instanceId}" class="widget-button points-toggle"
|
| 99 |
<div id="menu-content-${instanceId}" class="menu-content"></div>
|
| 100 |
</div>
|
| 101 |
<div id="point-tooltip" class="point-tooltip" style="display: none;">
|
|
@@ -131,24 +131,24 @@ const currentScriptTag = document.currentScript;
|
|
| 131 |
menuContent.innerHTML = `
|
| 132 |
- Pour vous déplacer, glissez deux doigts sur l'écran.<br>
|
| 133 |
- Pour orbiter, utilisez un doigt.<br>
|
| 134 |
-
- Pour zoomer, pincez avec deux doigts
|
|
|
|
| 135 |
`;
|
| 136 |
} else {
|
| 137 |
menuContent.innerHTML = `
|
| 138 |
- orbitez avec le clic droit<br>
|
| 139 |
- zoomez avec la molette<br>
|
| 140 |
-
- déplacez vous avec le clic gauche
|
|
|
|
| 141 |
`;
|
| 142 |
}
|
|
|
|
|
|
|
| 143 |
|
| 144 |
viewerContainerElem.style.display = 'block';
|
| 145 |
|
| 146 |
-
// Attach a ResizeObserver to track viewerContainer size changes
|
| 147 |
-
const containerObserver = new ResizeObserver(
|
| 148 |
-
for (const entry of entries) {
|
| 149 |
-
// No debug logs here anymore
|
| 150 |
-
}
|
| 151 |
-
});
|
| 152 |
containerObserver.observe(viewerContainerElem);
|
| 153 |
|
| 154 |
// Variable to hold the drag-hide listener reference
|
|
@@ -156,12 +156,10 @@ const currentScriptTag = document.currentScript;
|
|
| 156 |
|
| 157 |
// Utility: hide tooltip and remove drag-hide listener
|
| 158 |
function hideTooltip() {
|
| 159 |
-
// Remove drag-hide listener if present
|
| 160 |
if (dragHide) {
|
| 161 |
viewerContainerElem.removeEventListener('pointermove', dragHide);
|
| 162 |
dragHide = null;
|
| 163 |
}
|
| 164 |
-
// Hide tooltip DOM
|
| 165 |
tooltipDiv.style.display = 'none';
|
| 166 |
}
|
| 167 |
|
|
@@ -224,10 +222,8 @@ const currentScriptTag = document.currentScript;
|
|
| 224 |
let aspectToUse;
|
| 225 |
|
| 226 |
if (hasConfigAspect) {
|
| 227 |
-
// If aspect was in config, use that stored value
|
| 228 |
aspectToUse = savedState.widget.aspectPercent;
|
| 229 |
} else {
|
| 230 |
-
// Recompute from the parent container each time
|
| 231 |
const parentContainer = widgetContainer.parentNode;
|
| 232 |
const containerWidth = parentContainer.clientWidth;
|
| 233 |
const containerHeight = parentContainer.clientHeight;
|
|
@@ -238,12 +234,11 @@ const currentScriptTag = document.currentScript;
|
|
| 238 |
}
|
| 239 |
}
|
| 240 |
|
| 241 |
-
// Restore widgetContainer styles
|
| 242 |
widgetContainer.style.position = savedState.widget.position || "";
|
| 243 |
widgetContainer.style.top = savedState.widget.top || "";
|
| 244 |
widgetContainer.style.left = savedState.widget.left || "";
|
| 245 |
widgetContainer.style.width = "100%";
|
| 246 |
-
widgetContainer.style.height = "0";
|
| 247 |
widgetContainer.style.maxWidth = savedState.widget.maxWidth || "";
|
| 248 |
widgetContainer.style.maxHeight = savedState.widget.maxHeight || "";
|
| 249 |
widgetContainer.style.paddingBottom= aspectToUse;
|
|
@@ -254,7 +249,6 @@ const currentScriptTag = document.currentScript;
|
|
| 254 |
widgetContainer.style.overflow = savedState.widget.overflow || "";
|
| 255 |
widgetContainer.classList.remove('fake-fullscreen');
|
| 256 |
|
| 257 |
-
// Restore viewer container styles
|
| 258 |
viewerContainerElem.style.position = "absolute";
|
| 259 |
viewerContainerElem.style.top = "0";
|
| 260 |
viewerContainerElem.style.left = "0";
|
|
@@ -276,7 +270,7 @@ const currentScriptTag = document.currentScript;
|
|
| 276 |
const evt = new CustomEvent('viewerFullscreenExit', { detail: { instanceId } });
|
| 277 |
window.dispatchEvent(evt);
|
| 278 |
|
| 279 |
-
//
|
| 280 |
fullscreenToggle.textContent = '⇱';
|
| 281 |
|
| 282 |
savedState = null;
|
|
@@ -423,7 +417,7 @@ const currentScriptTag = document.currentScript;
|
|
| 423 |
}
|
| 424 |
});
|
| 425 |
|
| 426 |
-
// 📍 toggle button
|
| 427 |
let pointsVisible = !!config.showPointsDefault;
|
| 428 |
if (!pointsVisible) {
|
| 429 |
pointsToggleBtn.style.opacity = '0.5';
|
|
@@ -480,7 +474,6 @@ const currentScriptTag = document.currentScript;
|
|
| 480 |
|
| 481 |
// Window resize → adjust aspectRatios and resize PlayCanvas
|
| 482 |
window.addEventListener('resize', () => {
|
| 483 |
-
// If no config.aspect, recompute aspectPercent when not fullscreen
|
| 484 |
if (!hasConfigAspect && !isFullscreen) {
|
| 485 |
const parentContainer = widgetContainer.parentNode;
|
| 486 |
const cw = parentContainer.clientWidth;
|
|
@@ -491,7 +484,6 @@ const currentScriptTag = document.currentScript;
|
|
| 491 |
widgetContainer.setAttribute('data-original-aspect', newPercent);
|
| 492 |
}
|
| 493 |
}
|
| 494 |
-
// Resize PlayCanvas canvas
|
| 495 |
if (viewerModule.app) {
|
| 496 |
if (isFullscreen) {
|
| 497 |
viewerModule.app.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
|
|
| 95 |
<button id="reset-camera-btn-${instanceId}" class="widget-button reset-camera-btn">
|
| 96 |
<span class="reset-icon">⟲</span>
|
| 97 |
</button>
|
| 98 |
+
<button id="points-toggle-${instanceId}" class="widget-button points-toggle">⦿</button>
|
| 99 |
<div id="menu-content-${instanceId}" class="menu-content"></div>
|
| 100 |
</div>
|
| 101 |
<div id="point-tooltip" class="point-tooltip" style="display: none;">
|
|
|
|
| 131 |
menuContent.innerHTML = `
|
| 132 |
- Pour vous déplacer, glissez deux doigts sur l'écran.<br>
|
| 133 |
- Pour orbiter, utilisez un doigt.<br>
|
| 134 |
+
- Pour zoomer, pincez avec deux doigts.<br>
|
| 135 |
+
- Cliquez sur ⦿ pour afficher/masquer les points d’information.
|
| 136 |
`;
|
| 137 |
} else {
|
| 138 |
menuContent.innerHTML = `
|
| 139 |
- orbitez avec le clic droit<br>
|
| 140 |
- zoomez avec la molette<br>
|
| 141 |
+
- déplacez vous avec le clic gauche<br>
|
| 142 |
+
- Cliquez sur ⦿ pour afficher/masquer les points d’information.
|
| 143 |
`;
|
| 144 |
}
|
| 145 |
+
// Show instructions panel by default
|
| 146 |
+
menuContent.style.display = 'block';
|
| 147 |
|
| 148 |
viewerContainerElem.style.display = 'block';
|
| 149 |
|
| 150 |
+
// Attach a ResizeObserver to track viewerContainer size changes (no debug logs)
|
| 151 |
+
const containerObserver = new ResizeObserver(() => { /* no-op */ });
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
containerObserver.observe(viewerContainerElem);
|
| 153 |
|
| 154 |
// Variable to hold the drag-hide listener reference
|
|
|
|
| 156 |
|
| 157 |
// Utility: hide tooltip and remove drag-hide listener
|
| 158 |
function hideTooltip() {
|
|
|
|
| 159 |
if (dragHide) {
|
| 160 |
viewerContainerElem.removeEventListener('pointermove', dragHide);
|
| 161 |
dragHide = null;
|
| 162 |
}
|
|
|
|
| 163 |
tooltipDiv.style.display = 'none';
|
| 164 |
}
|
| 165 |
|
|
|
|
| 222 |
let aspectToUse;
|
| 223 |
|
| 224 |
if (hasConfigAspect) {
|
|
|
|
| 225 |
aspectToUse = savedState.widget.aspectPercent;
|
| 226 |
} else {
|
|
|
|
| 227 |
const parentContainer = widgetContainer.parentNode;
|
| 228 |
const containerWidth = parentContainer.clientWidth;
|
| 229 |
const containerHeight = parentContainer.clientHeight;
|
|
|
|
| 234 |
}
|
| 235 |
}
|
| 236 |
|
|
|
|
| 237 |
widgetContainer.style.position = savedState.widget.position || "";
|
| 238 |
widgetContainer.style.top = savedState.widget.top || "";
|
| 239 |
widgetContainer.style.left = savedState.widget.left || "";
|
| 240 |
widgetContainer.style.width = "100%";
|
| 241 |
+
widgetContainer.style.height = "0";
|
| 242 |
widgetContainer.style.maxWidth = savedState.widget.maxWidth || "";
|
| 243 |
widgetContainer.style.maxHeight = savedState.widget.maxHeight || "";
|
| 244 |
widgetContainer.style.paddingBottom= aspectToUse;
|
|
|
|
| 249 |
widgetContainer.style.overflow = savedState.widget.overflow || "";
|
| 250 |
widgetContainer.classList.remove('fake-fullscreen');
|
| 251 |
|
|
|
|
| 252 |
viewerContainerElem.style.position = "absolute";
|
| 253 |
viewerContainerElem.style.top = "0";
|
| 254 |
viewerContainerElem.style.left = "0";
|
|
|
|
| 270 |
const evt = new CustomEvent('viewerFullscreenExit', { detail: { instanceId } });
|
| 271 |
window.dispatchEvent(evt);
|
| 272 |
|
| 273 |
+
// Reset fullscreen button icon back to “⇱”
|
| 274 |
fullscreenToggle.textContent = '⇱';
|
| 275 |
|
| 276 |
savedState = null;
|
|
|
|
| 417 |
}
|
| 418 |
});
|
| 419 |
|
| 420 |
+
// 📍 toggle button (now “⦿”)
|
| 421 |
let pointsVisible = !!config.showPointsDefault;
|
| 422 |
if (!pointsVisible) {
|
| 423 |
pointsToggleBtn.style.opacity = '0.5';
|
|
|
|
| 474 |
|
| 475 |
// Window resize → adjust aspectRatios and resize PlayCanvas
|
| 476 |
window.addEventListener('resize', () => {
|
|
|
|
| 477 |
if (!hasConfigAspect && !isFullscreen) {
|
| 478 |
const parentContainer = widgetContainer.parentNode;
|
| 479 |
const cw = parentContainer.clientWidth;
|
|
|
|
| 484 |
widgetContainer.setAttribute('data-original-aspect', newPercent);
|
| 485 |
}
|
| 486 |
}
|
|
|
|
| 487 |
if (viewerModule.app) {
|
| 488 |
if (isFullscreen) {
|
| 489 |
viewerModule.app.resizeCanvas(window.innerWidth, window.innerHeight);
|