feat(stereo): тумблер показа длин соединённых отрезков

В инструменте «Соединить» подпись длины у каждого отрезка рисовалась всегда.
Добавил переключатель «Длины отрезков» (секция «Инструменты»): прячет только
подписи длин, сами отрезки и точки остаются.

- StereoSim: флаг showConnectionLengths (деф. true), гард в
  _rebuildPointVisuals, метод toggleConnectionLengths(on). Предпочтение
  переживает смену фигуры (не сбрасывается в setFigure).
- Панель: st-toggle-row #stg-connlen + glue stereoToggleConnLen.

Верификация: node --check OK; headless-смоук 8/8 (деф. вкл, подпись
гейтится флагом, линия/маркеры сохраняются, предпочтение переживает
setFigure); эмодзи/eval/new Function — 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-06-17 17:52:26 +03:00
parent 601f584181
commit 5e6effa8cd
2 changed files with 26 additions and 7 deletions
+16 -1
View File
@@ -289,6 +289,7 @@ class StereoSim {
this._customPoints = []; // [{pos: Vector3, edgeIdx: number, t: number, label: string}] this._customPoints = []; // [{pos: Vector3, edgeIdx: number, t: number, label: string}]
this._connections = []; // [{from: idx, to: idx}] this._connections = []; // [{from: idx, to: idx}]
this._connectPicks = []; // temp picks for connecting this._connectPicks = []; // temp picks for connecting
this.showConnectionLengths = true; // show length labels on connected segments
this._pointGroup = new THREE.Group(); this._pointGroup = new THREE.Group();
this.scene.add(this._pointGroup); this.scene.add(this._pointGroup);
this._nextPointId = 1; this._nextPointId = 1;
@@ -557,6 +558,12 @@ class StereoSim {
this.renderer.domElement.style.cursor = on ? 'pointer' : 'grab'; this.renderer.domElement.style.cursor = on ? 'pointer' : 'grab';
} }
toggleConnectionLengths(on) {
this.showConnectionLengths = on;
this._rebuildPointVisuals();
this._invalidate();
}
clearCustomPoints() { clearCustomPoints() {
this._customPoints = []; this._customPoints = [];
this._connections = []; this._connections = [];
@@ -2794,7 +2801,8 @@ class StereoSim {
line.computeLineDistances(); line.computeLineDistances();
this._pointGroup.add(line); this._pointGroup.add(line);
// Distance label // Distance label (optional — toggle "Длины отрезков")
if (this.showConnectionLengths) {
const dist = posA.distanceTo(posB); const dist = posA.distanceTo(posB);
const mid = new THREE.Vector3().addVectors(posA, posB).multiplyScalar(0.5); const mid = new THREE.Vector3().addVectors(posA, posB).multiplyScalar(0.5);
const lbl = this._makeTextSprite(dist.toFixed(2), '#F59E0B', 36); const lbl = this._makeTextSprite(dist.toFixed(2), '#F59E0B', 36);
@@ -2803,6 +2811,7 @@ class StereoSim {
this._pointGroup.add(lbl); this._pointGroup.add(lbl);
} }
} }
}
/* ════════════════ HEIGHT LINE ════════════════ */ /* ════════════════ HEIGHT LINE ════════════════ */
@@ -5059,6 +5068,12 @@ class StereoSim {
_stereoUpdatePointsInfo(); _stereoUpdatePointsInfo();
} }
function stereoToggleConnLen(toggle) {
const on = !toggle.classList.contains('on');
toggle.classList.toggle('on', on);
if (stereoSim) stereoSim.toggleConnectionLengths(on);
}
/* ── Constructions: lines & planes (Phase A) ── */ /* ── Constructions: lines & planes (Phase A) ── */
function stereoLineMode(btn) { function stereoLineMode(btn) {
const on = !btn.classList.contains('active'); const on = !btn.classList.contains('active');
+4
View File
@@ -3670,6 +3670,10 @@
<button class="st-action-btn" onclick="stereoMeasureUndo()">Удалить изм.</button> <button class="st-action-btn" onclick="stereoMeasureUndo()">Удалить изм.</button>
<button class="st-action-btn" onclick="stereoMeasureClear()">Очист. изм.</button> <button class="st-action-btn" onclick="stereoMeasureClear()">Очист. изм.</button>
</div> </div>
<div onclick="stereoToggleConnLen(this.querySelector('.st-toggle'))" class="st-toggle-row" title="Показывать длины соединённых отрезков">
<span class="st-toggle-label"><svg viewBox="0 0 24 24"><line x1="4" y1="12" x2="20" y2="12" stroke-dasharray="4,2"/><line x1="4" y1="9" x2="4" y2="15"/><line x1="20" y1="9" x2="20" y2="15"/></svg>Длины отрезков</span>
<div class="st-toggle on" id="stg-connlen"></div>
</div>
<div id="points-info" style="font-size:0.65rem;color:rgba(255,255,255,0.4);margin-top:2px"></div> <div id="points-info" style="font-size:0.65rem;color:rgba(255,255,255,0.4);margin-top:2px"></div>
<!-- ── Построения (прямые / плоскости) ── --> <!-- ── Построения (прямые / плоскости) ── -->