Spaces:
Running
Running
Update interface.js
Browse files- interface.js +30 -27
interface.js
CHANGED
|
@@ -80,7 +80,7 @@ const currentScriptTag = document.currentScript;
|
|
| 80 |
widgetContainer.style.paddingBottom = aspectPercent;
|
| 81 |
widgetContainer.setAttribute('data-original-aspect', aspectPercent);
|
| 82 |
|
| 83 |
-
// Add the 3D-viewer HTML +
|
| 84 |
widgetContainer.innerHTML = `
|
| 85 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
| 86 |
<div id="progress-dialog-${instanceId}" class="progress-dialog">
|
|
@@ -92,7 +92,22 @@ const currentScriptTag = document.currentScript;
|
|
| 92 |
<span class="reset-icon">β²</span>
|
| 93 |
</button>
|
| 94 |
<button id="points-toggle-${instanceId}" class="widget-button points-toggle">β¦Ώ</button>
|
| 95 |
-
<div id="menu-content-${instanceId}" class="menu-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
</div>
|
| 97 |
<div id="point-tooltip" class="point-tooltip" style="display: none;">
|
| 98 |
<div class="point-tooltip-content">
|
|
@@ -110,6 +125,7 @@ const currentScriptTag = document.currentScript;
|
|
| 110 |
const viewerContainerElem = document.getElementById('viewer-container-' + instanceId);
|
| 111 |
const fullscreenToggle = document.getElementById('fullscreen-toggle-' + instanceId);
|
| 112 |
const helpToggle = document.getElementById('help-toggle-' + instanceId);
|
|
|
|
| 113 |
const resetCameraBtn = document.getElementById('reset-camera-btn-' + instanceId);
|
| 114 |
const pointsToggleBtn = document.getElementById('points-toggle-' + instanceId);
|
| 115 |
const menuContent = document.getElementById('menu-content-' + instanceId);
|
|
@@ -120,24 +136,8 @@ const currentScriptTag = document.currentScript;
|
|
| 120 |
const tooltipImage = document.getElementById('point-tooltip-image');
|
| 121 |
const tooltipCloseBtn = document.getElementById('point-tooltip-close');
|
| 122 |
|
| 123 |
-
//
|
| 124 |
-
|
| 125 |
-
const isMobile = isIOS || /Android/i.test(navigator.userAgent);
|
| 126 |
-
if (isMobile) {
|
| 127 |
-
menuContent.innerHTML = `
|
| 128 |
-
- Pour vous dΓ©placer, glissez deux doigts sur l'Γ©cran.<br>
|
| 129 |
-
- Pour orbiter, utilisez un doigt.<br>
|
| 130 |
-
- Pour zoomer, pincez avec deux doigts.<br>
|
| 131 |
-
- Cliquez sur β¦Ώ pour afficher/masquer les points dβinformation.
|
| 132 |
-
`;
|
| 133 |
-
} else {
|
| 134 |
-
menuContent.innerHTML = `
|
| 135 |
-
- orbitez avec le clic droit<br>
|
| 136 |
-
- zoomez avec la molette<br>
|
| 137 |
-
- dΓ©placez vous avec le clic gauche<br>
|
| 138 |
-
- Cliquez sur β¦Ώ pour afficher/masquer les points dβinformation.
|
| 139 |
-
`;
|
| 140 |
-
}
|
| 141 |
|
| 142 |
viewerContainerElem.style.display = 'block';
|
| 143 |
|
|
@@ -146,15 +146,18 @@ const currentScriptTag = document.currentScript;
|
|
| 146 |
|
| 147 |
// Utility: hide tooltip and remove drag-hide listener
|
| 148 |
function hideTooltip() {
|
| 149 |
-
// Remove drag-hide listener if present
|
| 150 |
if (dragHide) {
|
| 151 |
viewerContainerElem.removeEventListener('pointermove', dragHide);
|
| 152 |
dragHide = null;
|
| 153 |
}
|
| 154 |
-
// Hide tooltip DOM
|
| 155 |
tooltipDiv.style.display = 'none';
|
| 156 |
}
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
// βββ 7. Dynamically load viewer.js βββββββββββββββββββββββββββββββββββββββββ
|
| 159 |
let viewerModule;
|
| 160 |
try {
|
|
@@ -171,10 +174,8 @@ const currentScriptTag = document.currentScript;
|
|
| 171 |
|
| 172 |
// βββ 8. Conditional display of points-toggle button βββββββββββββββββββββββββ
|
| 173 |
if (!config.points_url) {
|
| 174 |
-
// No points_url provided β hide button
|
| 175 |
pointsToggleBtn.style.display = 'none';
|
| 176 |
} else {
|
| 177 |
-
// Verify that points.json is reachable
|
| 178 |
fetch(config.points_url)
|
| 179 |
.then(resp => {
|
| 180 |
if (!resp.ok) {
|
|
@@ -407,6 +408,10 @@ const currentScriptTag = document.currentScript;
|
|
| 407 |
menuContent.style.display = (menuContent.style.display === 'block') ? 'none' : 'block';
|
| 408 |
});
|
| 409 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
resetCameraBtn.addEventListener('click', () => {
|
| 411 |
hideTooltip();
|
| 412 |
if (viewerModule.resetViewerCamera) {
|
|
@@ -414,7 +419,7 @@ const currentScriptTag = document.currentScript;
|
|
| 414 |
}
|
| 415 |
});
|
| 416 |
|
| 417 |
-
//
|
| 418 |
let pointsVisible = !!config.showPointsDefault;
|
| 419 |
if (pointsToggleBtn.style.display !== 'none') {
|
| 420 |
if (!pointsVisible) {
|
|
@@ -447,8 +452,6 @@ const currentScriptTag = document.currentScript;
|
|
| 447 |
|
| 448 |
// Attach drag-based hide listener
|
| 449 |
dragHide = (e) => {
|
| 450 |
-
// For mouse: e.buttons !== 0 indicates primary button held
|
| 451 |
-
// For touch: pointerType === 'touch'
|
| 452 |
if ((e.pointerType === 'mouse' && e.buttons !== 0) ||
|
| 453 |
(e.pointerType === 'touch')) {
|
| 454 |
hideTooltip();
|
|
|
|
| 80 |
widgetContainer.style.paddingBottom = aspectPercent;
|
| 81 |
widgetContainer.setAttribute('data-original-aspect', aspectPercent);
|
| 82 |
|
| 83 |
+
// Add the 3D-viewer HTML + β¦Ώ toggle + tooltip + help HTML
|
| 84 |
widgetContainer.innerHTML = `
|
| 85 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
| 86 |
<div id="progress-dialog-${instanceId}" class="progress-dialog">
|
|
|
|
| 92 |
<span class="reset-icon">β²</span>
|
| 93 |
</button>
|
| 94 |
<button id="points-toggle-${instanceId}" class="widget-button points-toggle">β¦Ώ</button>
|
| 95 |
+
<div id="menu-content-${instanceId}" class="menu-content">
|
| 96 |
+
<span id="help-close-${instanceId}" class="help-close">Γ</span>
|
| 97 |
+
<div class="help-text">
|
| 98 |
+
${isMobile ? `
|
| 99 |
+
- Pour vous dΓ©placer, glissez deux doigts sur l'Γ©cran.<br>
|
| 100 |
+
- Pour orbiter, utilisez un doigt.<br>
|
| 101 |
+
- Pour zoomer, pincez avec deux doigts.<br>
|
| 102 |
+
- Cliquez sur β¦Ώ pour afficher/masquer les points dβinformation.
|
| 103 |
+
` : `
|
| 104 |
+
- orbitez avec le clic droit<br>
|
| 105 |
+
- zoomez avec la molette<br>
|
| 106 |
+
- dΓ©placez vous avec le clic gauche<br>
|
| 107 |
+
- Cliquez sur β¦Ώ pour afficher/masquer les points dβinformation.
|
| 108 |
+
`}
|
| 109 |
+
</div>
|
| 110 |
+
</div>
|
| 111 |
</div>
|
| 112 |
<div id="point-tooltip" class="point-tooltip" style="display: none;">
|
| 113 |
<div class="point-tooltip-content">
|
|
|
|
| 125 |
const viewerContainerElem = document.getElementById('viewer-container-' + instanceId);
|
| 126 |
const fullscreenToggle = document.getElementById('fullscreen-toggle-' + instanceId);
|
| 127 |
const helpToggle = document.getElementById('help-toggle-' + instanceId);
|
| 128 |
+
const helpCloseBtn = document.getElementById('help-close-' + instanceId);
|
| 129 |
const resetCameraBtn = document.getElementById('reset-camera-btn-' + instanceId);
|
| 130 |
const pointsToggleBtn = document.getElementById('points-toggle-' + instanceId);
|
| 131 |
const menuContent = document.getElementById('menu-content-' + instanceId);
|
|
|
|
| 136 |
const tooltipImage = document.getElementById('point-tooltip-image');
|
| 137 |
const tooltipCloseBtn = document.getElementById('point-tooltip-close');
|
| 138 |
|
| 139 |
+
// Ensure instructions panel is visible by default
|
| 140 |
+
menuContent.style.display = 'block';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
viewerContainerElem.style.display = 'block';
|
| 143 |
|
|
|
|
| 146 |
|
| 147 |
// Utility: hide tooltip and remove drag-hide listener
|
| 148 |
function hideTooltip() {
|
|
|
|
| 149 |
if (dragHide) {
|
| 150 |
viewerContainerElem.removeEventListener('pointermove', dragHide);
|
| 151 |
dragHide = null;
|
| 152 |
}
|
|
|
|
| 153 |
tooltipDiv.style.display = 'none';
|
| 154 |
}
|
| 155 |
|
| 156 |
+
// Utility: hide instructions panel
|
| 157 |
+
function hideHelpPanel() {
|
| 158 |
+
menuContent.style.display = 'none';
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
// βββ 7. Dynamically load viewer.js βββββββββββββββββββββββββββββββββββββββββ
|
| 162 |
let viewerModule;
|
| 163 |
try {
|
|
|
|
| 174 |
|
| 175 |
// βββ 8. Conditional display of points-toggle button βββββββββββββββββββββββββ
|
| 176 |
if (!config.points_url) {
|
|
|
|
| 177 |
pointsToggleBtn.style.display = 'none';
|
| 178 |
} else {
|
|
|
|
| 179 |
fetch(config.points_url)
|
| 180 |
.then(resp => {
|
| 181 |
if (!resp.ok) {
|
|
|
|
| 408 |
menuContent.style.display = (menuContent.style.display === 'block') ? 'none' : 'block';
|
| 409 |
});
|
| 410 |
|
| 411 |
+
helpCloseBtn.addEventListener('click', () => {
|
| 412 |
+
hideHelpPanel();
|
| 413 |
+
});
|
| 414 |
+
|
| 415 |
resetCameraBtn.addEventListener('click', () => {
|
| 416 |
hideTooltip();
|
| 417 |
if (viewerModule.resetViewerCamera) {
|
|
|
|
| 419 |
}
|
| 420 |
});
|
| 421 |
|
| 422 |
+
// β¦Ώ toggle button
|
| 423 |
let pointsVisible = !!config.showPointsDefault;
|
| 424 |
if (pointsToggleBtn.style.display !== 'none') {
|
| 425 |
if (!pointsVisible) {
|
|
|
|
| 452 |
|
| 453 |
// Attach drag-based hide listener
|
| 454 |
dragHide = (e) => {
|
|
|
|
|
|
|
| 455 |
if ((e.pointerType === 'mouse' && e.buttons !== 0) ||
|
| 456 |
(e.pointerType === 'touch')) {
|
| 457 |
hideTooltip();
|