mirror of
https://github.com/Krafpy/KSP-MGA-Planner.git
synced 2025-12-12 15:49:59 -08:00
Fixed sprites display on slider change.
This commit is contained in:
6
dist/main/solvers/trajectory.js
vendored
6
dist/main/solvers/trajectory.js
vendored
@@ -11,6 +11,7 @@ export class Trajectory {
|
||||
this.orbits = [];
|
||||
this._maneuvres = [];
|
||||
this._flybys = [];
|
||||
this._displayedSteps = [];
|
||||
this._spritesUpdateFunId = -1;
|
||||
for (const { orbitElts, attractorId } of this.steps) {
|
||||
const attractor = this.system.bodyFromId(attractorId);
|
||||
@@ -33,6 +34,8 @@ export class Trajectory {
|
||||
textureLoader.load("sprites/maneuver.png", loaded("maneuver"));
|
||||
}
|
||||
draw(resolution) {
|
||||
const numSteps = this.steps.length;
|
||||
this._displayedSteps = Array(numSteps).fill(true);
|
||||
this._createTrajectoryArcs(resolution);
|
||||
this._createManeuvreSprites();
|
||||
this._calculateManeuvresDetails();
|
||||
@@ -121,7 +124,7 @@ export class Trajectory {
|
||||
const dstToCam = bodyPos.distanceTo(camPos);
|
||||
const visible = dstToCam < scale * body.soi * spriteDispSOIMul;
|
||||
for (const sprite of this._spriteObjects[i]) {
|
||||
sprite.visible = visible;
|
||||
sprite.visible = visible && this._displayedSteps[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -273,6 +276,7 @@ export class Trajectory {
|
||||
for (const sprite of sprites) {
|
||||
sprite.visible = visible;
|
||||
}
|
||||
this._displayedSteps[i] = visible;
|
||||
}
|
||||
}
|
||||
get _totalDeltaV() {
|
||||
|
||||
@@ -18,6 +18,7 @@ export class Trajectory {
|
||||
private readonly _maneuvres: ManeuvreDetails[] = [];
|
||||
private readonly _flybys: FlybyDetails[] = [];
|
||||
|
||||
private _displayedSteps: boolean[] = [];
|
||||
private _spritesUpdateFunId: number = -1;
|
||||
|
||||
constructor(public readonly steps: TrajectoryStep[], public readonly system: SolarSystem, public readonly config: Config) {
|
||||
@@ -45,6 +46,9 @@ export class Trajectory {
|
||||
}
|
||||
|
||||
public draw(resolution: {width: number, height: number}){
|
||||
const numSteps = this.steps.length;
|
||||
this._displayedSteps = Array(numSteps).fill(true);
|
||||
|
||||
this._createTrajectoryArcs(resolution);
|
||||
this._createManeuvreSprites();
|
||||
this._calculateManeuvresDetails();
|
||||
@@ -147,7 +151,7 @@ export class Trajectory {
|
||||
const visible = dstToCam < scale * body.soi * spriteDispSOIMul;
|
||||
|
||||
for(const sprite of this._spriteObjects[i]){
|
||||
sprite.visible = visible;
|
||||
sprite.visible = visible && this._displayedSteps[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -339,6 +343,7 @@ export class Trajectory {
|
||||
for(const sprite of sprites){
|
||||
sprite.visible = visible;
|
||||
}
|
||||
this._displayedSteps[i] = visible;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user