diff --git a/src/app/coordinate-system/coordinate-system.component.sass b/src/app/coordinate-system/coordinate-system.component.sass index c2ed8f3..0b13fdd 100644 --- a/src/app/coordinate-system/coordinate-system.component.sass +++ b/src/app/coordinate-system/coordinate-system.component.sass @@ -82,6 +82,7 @@ p text-align: center margin-left: -10px + cursor: default .measure-band-y opacity: 0.6 !important @@ -98,3 +99,4 @@ p text-align: center margin-left: 10px + cursor: default diff --git a/src/app/service/move.service.ts b/src/app/service/move.service.ts index 0b0c7dc..57376ed 100644 --- a/src/app/service/move.service.ts +++ b/src/app/service/move.service.ts @@ -5,8 +5,6 @@ import { ObjectService } from './object.service'; providedIn: 'root', }) export class MoveService { - static G = 6.6743e-11; - private interval: any | null = null; isPlaying: boolean = false; diff --git a/src/app/service/settings.service.ts b/src/app/service/settings.service.ts index 4d71da9..ff731f9 100644 --- a/src/app/service/settings.service.ts +++ b/src/app/service/settings.service.ts @@ -1,6 +1,11 @@ import { Injectable } from '@angular/core'; import { LocalStorageService } from './local-storage.service'; import { CoordinateSystemComponent } from '../coordinate-system/coordinate-system.component'; +import { + CollisionMode, + collisionModeToString, + rotateCollisionMode, +} from '../../types/CollisionMode'; @Injectable({ providedIn: 'root', @@ -14,6 +19,8 @@ export class SettingsService { private static showLogo = true; private static showSettings = true; + private static collisionMode: CollisionMode = CollisionMode.IGNORE; + static init() { if (this.isInit) { return; @@ -25,6 +32,7 @@ export class SettingsService { this.showVelocityArrow = settings.showVelocityArrow; this.showLogo = settings.showLogo; this.showSettings = settings.showSettings; + this.collisionMode = settings.collisionMode; } this.isInit = true; } @@ -37,6 +45,7 @@ export class SettingsService { showVelocityArrow: this.showVelocityArrow, showLogo: this.showLogo, showSettings: this.showSettings, + collisionMode: this.collisionMode, }); } @@ -89,6 +98,17 @@ export class SettingsService { this.saveSettings(); } + static getCollisionMode(): string { + this.init(); + return collisionModeToString(this.collisionMode); + } + + static toggleCollisionMode(): void { + this.init(); + this.collisionMode = rotateCollisionMode(this.collisionMode); + this.saveSettings(); + } + static toggleGridSize(): void { this.init(); diff --git a/src/app/settings/settings/settings.component.html b/src/app/settings/settings/settings.component.html index c253840..7c7e78c 100644 --- a/src/app/settings/settings/settings.component.html +++ b/src/app/settings/settings/settings.component.html @@ -61,11 +61,8 @@

View

Behavior

Collision Mode

-

Examples

diff --git a/src/app/settings/settings/settings.component.ts b/src/app/settings/settings/settings.component.ts index e13b84b..6f9e916 100644 --- a/src/app/settings/settings/settings.component.ts +++ b/src/app/settings/settings/settings.component.ts @@ -8,7 +8,6 @@ import { getPlutoCharonExample, getThreeBody, } from '../../../data/examples'; -import { CoordinateSystemComponent } from 'src/app/coordinate-system/coordinate-system.component'; import { ObjectService } from 'src/app/service/object.service'; @Component({ diff --git a/src/types/CollisionMode.ts b/src/types/CollisionMode.ts new file mode 100644 index 0000000..6282e80 --- /dev/null +++ b/src/types/CollisionMode.ts @@ -0,0 +1,27 @@ +export enum CollisionMode { + IGNORE = 'Ignore', + END = 'End', + JOIN = 'Join', +} + +export function rotateCollisionMode(mode: CollisionMode): CollisionMode { + switch (mode) { + case CollisionMode.IGNORE: + return CollisionMode.END; + case CollisionMode.END: + return CollisionMode.JOIN; + case CollisionMode.JOIN: + return CollisionMode.IGNORE; + } +} + +export function collisionModeToString(mode: CollisionMode): string { + switch (mode) { + case CollisionMode.IGNORE: + return 'Ignore'; + case CollisionMode.END: + return 'End'; + case CollisionMode.JOIN: + return 'Join'; + } +}