Commit cceb77c7 authored by legoc's avatar legoc
Browse files

Corrected trajectories in energy

parent 8824772b
...@@ -151,13 +151,18 @@ class EnergyLine extends TrajectoryLine { ...@@ -151,13 +151,18 @@ class EnergyLine extends TrajectoryLine {
// Calculate length of the segment. Applies the scale. // Calculate length of the segment. Applies the scale.
let length = this._end.clone().sub(this._start).length() * this.getEnergyScale(); let length = this._end.clone().sub(this._start).length() * this.getEnergyScale();
// Create a line segment for the line. // Create a line segment for the line.
let segment = new LineSegment(new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, length), 0.5 / scale, this._lineMaterial); if (length > 0) {
this._line = segment; // It is necessary not to draw line with length 0 because the underlying cylinder has a default length 1.
this._line = new LineSegment(new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, length), 0.5 / scale, this._lineMaterial);
// Add the line to the data group. // Add the line to the data group.
this._dataGroup.add(this._line.object3D); this._dataGroup.add(this._line.object3D);
}
else {
this._line = null;
}
} }
// Update the data. // Update the data.
...@@ -189,6 +194,7 @@ class EnergyLine extends TrajectoryLine { ...@@ -189,6 +194,7 @@ class EnergyLine extends TrajectoryLine {
this._line.object3D.visible = visibility; this._line.object3D.visible = visibility;
} }
this._dataGroup.visible = visibility; this._dataGroup.visible = visibility;
this._pointSphereGroup.visible = visibility;
} }
/** /**
......
...@@ -104,12 +104,8 @@ class TrajectoryView3D extends View3D { ...@@ -104,12 +104,8 @@ class TrajectoryView3D extends View3D {
this._energyLine.start = energyStart; this._energyLine.start = energyStart;
this._energyLine.end = energyStart; this._energyLine.end = energyStart;
this._energyLine.setVisibility(true);
// Show energy line for ki and kf trajectories.
if (this._type === 'ki' || this._type === 'kf') {
this._energyLine.setVisibility(true);
}
this._drawLines = true; this._drawLines = true;
} }
else { else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment