fix(dashboard): clean up Fresnel toggle sync and fix semi-minor axis formula
Simplify Fresnel debug overlay toggle to use single toggleFresnelDebugOverlay call instead of duplicating Viz3D sync logic. Fix semi-minor axis calculation in viz3d.js (was missing factor of 2 in distance term). Add Math.max(0,...) guard against negative sqrt. Add missing dispose mocks in fresnel tests. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
ccf12da102
commit
3150dadf32
4 changed files with 15 additions and 28 deletions
|
|
@ -2286,13 +2286,7 @@
|
|||
// Fallback without Layers module
|
||||
var btn = document.getElementById('fresnel-toggle-btn');
|
||||
var isActive = btn && btn.classList.contains('active');
|
||||
if (isActive) {
|
||||
Viz3D.toggleFresnelZones(false);
|
||||
if (btn) btn.classList.remove('active');
|
||||
} else {
|
||||
Viz3D.toggleFresnelZones(true);
|
||||
if (btn) btn.classList.add('active');
|
||||
}
|
||||
toggleFresnelDebugOverlay(!isActive);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -2307,11 +2301,6 @@
|
|||
window.toggleFresnelDebugOverlay = function(visible) {
|
||||
state.fresnelDebugVisible = visible;
|
||||
|
||||
// Sync Viz3D Fresnel zones with debug overlay state
|
||||
if (window.Viz3D && Viz3D.toggleFresnelZones) {
|
||||
Viz3D.toggleFresnelZones(visible);
|
||||
}
|
||||
|
||||
// Sync toolbar button
|
||||
var btn = document.getElementById('fresnel-toggle-btn');
|
||||
if (btn) {
|
||||
|
|
|
|||
|
|
@ -233,22 +233,16 @@
|
|||
function removeFresnelEllipsoid(ellipsoid) {
|
||||
if (!ellipsoid) return;
|
||||
|
||||
if (ellipsoid.wireframe && _scene) {
|
||||
_scene.remove(ellipsoid.wireframe);
|
||||
ellipsoid.wireframe.geometry.dispose();
|
||||
if (ellipsoid.wireframe.material) {
|
||||
ellipsoid.wireframe.material.dispose();
|
||||
}
|
||||
if (ellipsoid.wireframe) {
|
||||
if (_scene) _scene.remove(ellipsoid.wireframe);
|
||||
if (ellipsoid.wireframe.geometry) ellipsoid.wireframe.geometry.dispose();
|
||||
if (ellipsoid.wireframe.material) ellipsoid.wireframe.material.dispose();
|
||||
}
|
||||
|
||||
if (ellipsoid.fill && _scene) {
|
||||
_scene.remove(ellipsoid.fill);
|
||||
if (ellipsoid.fill.geometry) {
|
||||
ellipsoid.fill.geometry.dispose();
|
||||
}
|
||||
if (ellipsoid.fill.material) {
|
||||
ellipsoid.fill.material.dispose();
|
||||
}
|
||||
if (ellipsoid.fill) {
|
||||
if (_scene) _scene.remove(ellipsoid.fill);
|
||||
if (ellipsoid.fill.geometry) ellipsoid.fill.geometry.dispose();
|
||||
if (ellipsoid.fill.material) ellipsoid.fill.material.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ describe('Fresnel Module', function() {
|
|||
this.position = { copy: function() {} };
|
||||
this.quaternion = { copy: function() {} };
|
||||
this.userData = {};
|
||||
this.geometry = { dispose: function() {} };
|
||||
this.material = { dispose: function() {} };
|
||||
},
|
||||
MeshBasicMaterial: function() {},
|
||||
Mesh: function() {
|
||||
|
|
@ -37,6 +39,8 @@ describe('Fresnel Module', function() {
|
|||
this.position = { copy: function() {} };
|
||||
this.quaternion = { copy: function() {} };
|
||||
this.userData = {};
|
||||
this.geometry = { dispose: function() {} };
|
||||
this.material = { dispose: function() {} };
|
||||
},
|
||||
DoubleSide: 2
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2914,9 +2914,9 @@ const Viz3D = (function () {
|
|||
// Ellipsoid semi-axes calculation
|
||||
// For a prolate spheroid with foci at tx and rx:
|
||||
// Semi-major axis (a) = (d + deltaL) / 2
|
||||
// Semi-minor axis (b) = sqrt(deltaL * (d + deltaL)) / 2
|
||||
// Semi-minor axis (b) = sqrt(deltaL * (2*d + deltaL)) / 2
|
||||
const a = (d + deltaL) / 2;
|
||||
const b = Math.sqrt(deltaL * (d + deltaL)) / 2;
|
||||
const b = Math.sqrt(Math.max(0, deltaL * (2 * d + deltaL))) / 2;
|
||||
|
||||
// Center of ellipsoid (midpoint between TX and RX)
|
||||
const center = new THREE.Vector3().addVectors(tx, rx).multiplyScalar(0.5);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue