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:
@@ -289,6 +289,7 @@ class StereoSim {
|
||||
this._customPoints = []; // [{pos: Vector3, edgeIdx: number, t: number, label: string}]
|
||||
this._connections = []; // [{from: idx, to: idx}]
|
||||
this._connectPicks = []; // temp picks for connecting
|
||||
this.showConnectionLengths = true; // show length labels on connected segments
|
||||
this._pointGroup = new THREE.Group();
|
||||
this.scene.add(this._pointGroup);
|
||||
this._nextPointId = 1;
|
||||
@@ -557,6 +558,12 @@ class StereoSim {
|
||||
this.renderer.domElement.style.cursor = on ? 'pointer' : 'grab';
|
||||
}
|
||||
|
||||
toggleConnectionLengths(on) {
|
||||
this.showConnectionLengths = on;
|
||||
this._rebuildPointVisuals();
|
||||
this._invalidate();
|
||||
}
|
||||
|
||||
clearCustomPoints() {
|
||||
this._customPoints = [];
|
||||
this._connections = [];
|
||||
@@ -2794,13 +2801,15 @@ class StereoSim {
|
||||
line.computeLineDistances();
|
||||
this._pointGroup.add(line);
|
||||
|
||||
// Distance label
|
||||
const dist = posA.distanceTo(posB);
|
||||
const mid = new THREE.Vector3().addVectors(posA, posB).multiplyScalar(0.5);
|
||||
const lbl = this._makeTextSprite(dist.toFixed(2), '#F59E0B', 36);
|
||||
lbl.position.copy(mid).add(new THREE.Vector3(0, 0.25, 0));
|
||||
lbl.scale.set(0.8, 0.4, 1);
|
||||
this._pointGroup.add(lbl);
|
||||
// Distance label (optional — toggle "Длины отрезков")
|
||||
if (this.showConnectionLengths) {
|
||||
const dist = posA.distanceTo(posB);
|
||||
const mid = new THREE.Vector3().addVectors(posA, posB).multiplyScalar(0.5);
|
||||
const lbl = this._makeTextSprite(dist.toFixed(2), '#F59E0B', 36);
|
||||
lbl.position.copy(mid).add(new THREE.Vector3(0, 0.25, 0));
|
||||
lbl.scale.set(0.8, 0.4, 1);
|
||||
this._pointGroup.add(lbl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5059,6 +5068,12 @@ class StereoSim {
|
||||
_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) ── */
|
||||
function stereoLineMode(btn) {
|
||||
const on = !btn.classList.contains('active');
|
||||
|
||||
@@ -3670,6 +3670,10 @@
|
||||
<button class="st-action-btn" onclick="stereoMeasureUndo()">Удалить изм.</button>
|
||||
<button class="st-action-btn" onclick="stereoMeasureClear()">Очист. изм.</button>
|
||||
</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>
|
||||
|
||||
<!-- ── Построения (прямые / плоскости) ── -->
|
||||
|
||||
Reference in New Issue
Block a user