Spaces:
Running
Running
Update interface.js
Browse files- interface.js +56 -2
interface.js
CHANGED
|
@@ -76,6 +76,41 @@ const currentScriptTag = document.currentScript;
|
|
| 76 |
? `<button id="tooltips-toggle-${instanceId}" class="widget-button tooltips-toggle">⦿</button>`
|
| 77 |
: '';
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
widgetContainer.innerHTML = `
|
| 80 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
| 81 |
<div id="progress-dialog-${instanceId}" class="progress-dialog">
|
|
@@ -87,6 +122,7 @@ const currentScriptTag = document.currentScript;
|
|
| 87 |
<span class="reset-icon">⟲</span>
|
| 88 |
</button>
|
| 89 |
${tooltipsButtonHTML}
|
|
|
|
| 90 |
<div id="menu-content-${instanceId}" class="menu-content">
|
| 91 |
<span id="help-close-${instanceId}" class="help-close">×</span>
|
| 92 |
<div class="help-text"></div>
|
|
@@ -116,6 +152,10 @@ const currentScriptTag = document.currentScript;
|
|
| 116 |
const tooltipImage = document.getElementById('tooltip-image');
|
| 117 |
const tooltipCloseBtn = document.getElementById('tooltip-close');
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
| 120 |
const isMobile = isIOS || /Android/i.test(navigator.userAgent);
|
| 121 |
|
|
@@ -124,7 +164,7 @@ const currentScriptTag = document.currentScript;
|
|
| 124 |
: '';
|
| 125 |
|
| 126 |
if (isMobile) {
|
| 127 |
-
helpTextDiv.innerHTML =
|
| 128 |
'- Déplacez vous en glissant deux doigts sur l\'écran.<br>' +
|
| 129 |
'- Orbitez en glissant un doigt.<br>' +
|
| 130 |
'- Zoomez en pinçant avec deux doigts.<br>' +
|
|
@@ -132,7 +172,7 @@ const currentScriptTag = document.currentScript;
|
|
| 132 |
'- Cliquez sur ⟲ pour réinitialiser la caméra.<br>' +
|
| 133 |
'- Cliquez sur ⇱ pour passer en plein écran.<br>';
|
| 134 |
} else {
|
| 135 |
-
helpTextDiv.innerHTML =
|
| 136 |
'- Orbitez avec le clic droit<br>' +
|
| 137 |
'- Zoomez avec la molette<br>' +
|
| 138 |
'- Déplacez vous avec le clic gauche<br>' +
|
|
@@ -383,6 +423,20 @@ const currentScriptTag = document.currentScript;
|
|
| 383 |
|
| 384 |
tooltipCloseBtn.addEventListener('click', hideTooltipPanel);
|
| 385 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
document.addEventListener('tooltip-selected', (evt) => {
|
| 387 |
// Always show panel, cancel hide first
|
| 388 |
if (dragHide) {
|
|
|
|
| 76 |
? `<button id="tooltips-toggle-${instanceId}" class="widget-button tooltips-toggle">⦿</button>`
|
| 77 |
: '';
|
| 78 |
|
| 79 |
+
// ----------------- COLOR BUTTONS (will be inserted after the main viewer controls) ----------------------
|
| 80 |
+
const colorBtnContainerId = `color-btn-container-${instanceId}`;
|
| 81 |
+
// Only red and white for now. Extend array to add more colors later.
|
| 82 |
+
const colorButtonsConfig = [
|
| 83 |
+
{
|
| 84 |
+
id: `color-btn-white-${instanceId}`,
|
| 85 |
+
label: '',
|
| 86 |
+
title: 'Blanc',
|
| 87 |
+
color: [1, 1, 1],
|
| 88 |
+
style: 'background: #fff; border: 1.5px solid #bbb;'
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
id: `color-btn-red-${instanceId}`,
|
| 92 |
+
label: '',
|
| 93 |
+
title: 'Rouge',
|
| 94 |
+
color: [0.7, 0.05, 0.05],
|
| 95 |
+
style: 'background: #d00; border: 1.5px solid #b33;'
|
| 96 |
+
}
|
| 97 |
+
];
|
| 98 |
+
// The colorBtnContainer is inserted into the widget HTML
|
| 99 |
+
const colorButtonsHTML = `
|
| 100 |
+
<div id="${colorBtnContainerId}" class="color-btn-container">
|
| 101 |
+
${colorButtonsConfig.map(btn => `
|
| 102 |
+
<button
|
| 103 |
+
id="${btn.id}"
|
| 104 |
+
class="widget-button color-btn"
|
| 105 |
+
title="${btn.title}"
|
| 106 |
+
style="${btn.style}; right: 172px; width: 32px; height: 32px; margin-bottom: 8px; display: flex; align-items: center; justify-content: center;"
|
| 107 |
+
tabindex="0"
|
| 108 |
+
></button>
|
| 109 |
+
`).join('\n')}
|
| 110 |
+
</div>
|
| 111 |
+
`;
|
| 112 |
+
// ---------------------------------
|
| 113 |
+
|
| 114 |
widgetContainer.innerHTML = `
|
| 115 |
<div id="viewer-container-${instanceId}" class="viewer-container">
|
| 116 |
<div id="progress-dialog-${instanceId}" class="progress-dialog">
|
|
|
|
| 122 |
<span class="reset-icon">⟲</span>
|
| 123 |
</button>
|
| 124 |
${tooltipsButtonHTML}
|
| 125 |
+
${colorButtonsHTML}
|
| 126 |
<div id="menu-content-${instanceId}" class="menu-content">
|
| 127 |
<span id="help-close-${instanceId}" class="help-close">×</span>
|
| 128 |
<div class="help-text"></div>
|
|
|
|
| 152 |
const tooltipImage = document.getElementById('tooltip-image');
|
| 153 |
const tooltipCloseBtn = document.getElementById('tooltip-close');
|
| 154 |
|
| 155 |
+
// Get color button DOM elements (by ID)
|
| 156 |
+
const colorBtnContainer = document.getElementById(colorBtnContainerId);
|
| 157 |
+
const colorBtnElements = colorButtonsConfig.map(btn => document.getElementById(btn.id));
|
| 158 |
+
|
| 159 |
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
| 160 |
const isMobile = isIOS || /Android/i.test(navigator.userAgent);
|
| 161 |
|
|
|
|
| 164 |
: '';
|
| 165 |
|
| 166 |
if (isMobile) {
|
| 167 |
+
helpTextDiv.innerHTML =
|
| 168 |
'- Déplacez vous en glissant deux doigts sur l\'écran.<br>' +
|
| 169 |
'- Orbitez en glissant un doigt.<br>' +
|
| 170 |
'- Zoomez en pinçant avec deux doigts.<br>' +
|
|
|
|
| 172 |
'- Cliquez sur ⟲ pour réinitialiser la caméra.<br>' +
|
| 173 |
'- Cliquez sur ⇱ pour passer en plein écran.<br>';
|
| 174 |
} else {
|
| 175 |
+
helpTextDiv.innerHTML =
|
| 176 |
'- Orbitez avec le clic droit<br>' +
|
| 177 |
'- Zoomez avec la molette<br>' +
|
| 178 |
'- Déplacez vous avec le clic gauche<br>' +
|
|
|
|
| 423 |
|
| 424 |
tooltipCloseBtn.addEventListener('click', hideTooltipPanel);
|
| 425 |
|
| 426 |
+
// ----------------- COLOR BUTTON LOGIC (click handler) -----------------
|
| 427 |
+
colorBtnElements.forEach((btnEl, idx) => {
|
| 428 |
+
if (!btnEl) return;
|
| 429 |
+
btnEl.addEventListener('click', (e) => {
|
| 430 |
+
e.preventDefault();
|
| 431 |
+
// Defensive: Wait until changeColor function is available and model loaded
|
| 432 |
+
if (viewerModule && typeof viewerModule.changeColor === 'function') {
|
| 433 |
+
const [r, g, b] = colorButtonsConfig[idx].color;
|
| 434 |
+
viewerModule.changeColor(r, g, b);
|
| 435 |
+
}
|
| 436 |
+
});
|
| 437 |
+
});
|
| 438 |
+
// ----------------------------------------------------------------------
|
| 439 |
+
|
| 440 |
document.addEventListener('tooltip-selected', (evt) => {
|
| 441 |
// Always show panel, cancel hide first
|
| 442 |
if (dragHide) {
|