diff --git a/frontend/js/labs/stereo.js b/frontend/js/labs/stereo.js index d3fd2f1..01a3e2e 100644 --- a/frontend/js/labs/stereo.js +++ b/frontend/js/labs/stereo.js @@ -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'); diff --git a/frontend/labs-bodies.html b/frontend/labs-bodies.html index 530044e..2597d52 100644 --- a/frontend/labs-bodies.html +++ b/frontend/labs-bodies.html @@ -3670,6 +3670,10 @@ +
+ Длины отрезков +
+