Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Mar 21, 2024
1 parent 2c949d7 commit dd49f71
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/drawer/3d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Drawer3dConfigInterface,
DrawerInterface, MouseClickListenerCallback,
ViewConfigInterface,
DrawerInterface,
MouseClickListenerCallback,
} from '../types/drawer';
import { ColorVector, TypesConfig, WorldConfig } from '../types/config';
import { AtomInterface, LinkInterface } from '../types/atomic';
Expand All @@ -25,7 +25,6 @@ export class Drawer3d implements DrawerInterface {
private readonly WORLD_CONFIG: WorldConfig;
private readonly TYPES_CONFIG: TypesConfig;
private readonly domElement: HTMLCanvasElement;
private readonly viewConfig: ViewConfigInterface;
private readonly engine: Engine;
private readonly scene: Scene;
private readonly camera: UniversalCamera;
Expand Down
11 changes: 10 additions & 1 deletion src/simulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class Simulation implements SimulationInterface {
private readonly linkManager: LinkManagerInterface;
private readonly interactionManager: InteractionManagerInterface;
private readonly clusterManager: ClusterManagerInterface;
private isRunning: boolean = false;

constructor({
worldConfig,
Expand Down Expand Up @@ -50,9 +51,14 @@ export class Simulation implements SimulationInterface {
}

start() {
this.isRunning = true;
this.tick();
}

stop() {
this.isRunning = false;
}

private tick() {
// const ts = Date.now();
for (let i=0; i<this.worldConfig.PLAYBACK_SPEED; ++i) {
Expand Down Expand Up @@ -80,6 +86,9 @@ export class Simulation implements SimulationInterface {
// console.log('tick spent', Date.now()-ts);

this.drawer.draw(this.atoms, this.linkManager);
setTimeout(() => this.tick(), 10);

if (this.isRunning) {
setTimeout(() => this.tick(), 10);
}
}
}
1 change: 1 addition & 0 deletions src/types/simulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export type SimulationConfig = {

export interface SimulationInterface {
start(): void;
stop(): void;
}

0 comments on commit dd49f71

Please sign in to comment.