diff --git a/frontend/js/labs/stereo.js b/frontend/js/labs/stereo.js
index 4bb6afe..97abfe0 100644
--- a/frontend/js/labs/stereo.js
+++ b/frontend/js/labs/stereo.js
@@ -583,7 +583,9 @@ class StereoSim {
clearSection3P() {
this._section3PPicks = [];
this._section3PData = null;
- this._section3PStep = 0;
+ // keep step ≥1 while in step mode, else a re-pick would hide the section
+ this._section3PStep = this._section3PStepBy ? 1 : 0;
+ this._stepCaption = '';
this._clearGroup(this._section3PGroup);
this._notify();
}
@@ -2265,6 +2267,9 @@ class StereoSim {
if (!data || picks.length < 3) return;
+ // In step mode the step counter must be ≥1 (any reset path may have zeroed it),
+ // otherwise the section would be hidden and no step drawn.
+ if (this._section3PStepBy && this._section3PStep < 1) this._section3PStep = 1;
// In step-by-step mode the finished section is hidden until step ≥ 5 so the
// trace construction builds up; otherwise (or at the end) show it in full.
const showFull = !this._section3PStepBy || this._section3PStep >= 5;
@@ -2353,11 +2358,11 @@ class StereoSim {
// when the cutting plane is (nearly) parallel to the base (trace at infinity).
_traceLine(data) {
const a = data.normal.x, b = data.normal.z, D = data.D;
- if (Math.abs(a) < 1e-6 && Math.abs(b) < 1e-6) return null; // parallel to base
+ const denom = a * a + b * b;
+ if (denom < 1e-12) return null; // plane parallel to base
const dir = new THREE.Vector3(-b, 0, a).normalize();
- let p0;
- if (Math.abs(a) >= Math.abs(b)) p0 = new THREE.Vector3(-D / a, 0, 0);
- else p0 = new THREE.Vector3(0, 0, -D / b);
+ // foot of perpendicular from origin → keeps the drawn trace near the figure
+ const p0 = new THREE.Vector3(-D * a / denom, 0, -D * b / denom);
return { p0, dir };
}
@@ -4299,6 +4304,10 @@ class StereoSim {
// Live readout overlay (section type/area/perimeter, last measurement)
_stereoUpdateReadout(info);
+
+ // Keep the trace-method caption in sync (e.g. right after the 3rd pick),
+ // but only in step mode so the "Кликните 3 точки" instruction is preserved.
+ if (stereoSim && stereoSim._section3PStepBy) _stereoStepHint();
}
function _stereoUpdateReadout(info) {
diff --git a/frontend/lab.html b/frontend/lab.html
index 81f454f..94c3782 100644
--- a/frontend/lab.html
+++ b/frontend/lab.html
@@ -4819,7 +4819,7 @@
-
+