From fce7bde41293233583bd9250718b03a309127946 Mon Sep 17 00:00:00 2001 From: Michael Fuller Date: Thu, 10 Mar 2022 18:56:20 -0600 Subject: [PATCH] Cleaning (#144) --- .../puzzle-view/puzzle-view.component.html | 1 - src/app/puzzle-view/puzzle-view.component.ts | 20 +++++--------- src/app/three-dview/three-dview.component.ts | 27 +++++++++---------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/app/puzzle-view/puzzle-view.component.html b/src/app/puzzle-view/puzzle-view.component.html index a1681d1..ec8f956 100644 --- a/src/app/puzzle-view/puzzle-view.component.html +++ b/src/app/puzzle-view/puzzle-view.component.html @@ -7,7 +7,6 @@

diff --git a/src/app/puzzle-view/puzzle-view.component.ts b/src/app/puzzle-view/puzzle-view.component.ts index dfe21f5..ed724de 100644 --- a/src/app/puzzle-view/puzzle-view.component.ts +++ b/src/app/puzzle-view/puzzle-view.component.ts @@ -28,7 +28,6 @@ import * as SOLVER from '../solver/puzzle'; styleUrls: ['./puzzle-view.component.scss'], }) export class PuzzleViewComponent implements OnInit, AfterViewInit { - public puzzleId: string; public puzzleInfo?: PuzzleInfo; public puzzleConfiguration: PuzzleConfiguration = new PuzzleConfiguration( @@ -48,14 +47,14 @@ export class PuzzleViewComponent implements OnInit, AfterViewInit { private router: Router ) { this.route.params.subscribe((params) => { - this.puzzleId = params['puzzleId']; + let puzzleId: string = params['puzzleId']; - if (this.dataSource.puzzles.has(this.puzzleId)) { - this.puzzleInfo = this.dataSource.puzzles.get(this.puzzleId)!; + if (this.dataSource.puzzles.has(puzzleId)) { + this.puzzleInfo = this.dataSource.puzzles.get(puzzleId)!; if (this.puzzleInfo!.type == PuzzleType.BROKEN) { this.puzzleConfiguration = new PuzzleConfiguration( - this.puzzleInfo.type, + PuzzleType.BROKEN, [] ); } else { @@ -71,7 +70,6 @@ export class PuzzleViewComponent implements OnInit, AfterViewInit { ); if (this.afterInit) { - //this.someElement.puzzleInfo = this.puzzleInfo!; this.solvePuzzle(); } } @@ -85,19 +83,13 @@ export class PuzzleViewComponent implements OnInit, AfterViewInit { }); } - ngOnInit(): void { - var self = this; - - console.log('Init'); - } + ngOnInit(): void {} ngAfterViewInit(): void { this.afterInit = true; - if (this.puzzleInfo != null) { - this.someElement.puzzleInfo = this.puzzleInfo!; + if (this.puzzleInfo) { this.solvePuzzle(); } - this.someElement.startView(); } configurationChange(index: number) { diff --git a/src/app/three-dview/three-dview.component.ts b/src/app/three-dview/three-dview.component.ts index 832e79b..7073b62 100644 --- a/src/app/three-dview/three-dview.component.ts +++ b/src/app/three-dview/three-dview.component.ts @@ -34,7 +34,9 @@ export class ThreeDViewComponent implements OnInit, AfterViewInit, OnChanges { ngOnInit(): void {} - ngAfterViewInit(): void {} + ngAfterViewInit(): void { + this.loadTextures(); + } public startView() { this.loadTextures(); @@ -42,26 +44,23 @@ export class ThreeDViewComponent implements OnInit, AfterViewInit, OnChanges { ngOnChanges(changes: SimpleChanges) { if (changes && changes['puzzleInfo']) { - if (this.puzzleInfo && this.camera && this.scene) { - this.loadBackground(); - this.buildDirectionArray(); - this.removeInteraction(); - this.reCreateScene(); - this.createCamera(); - this.createInteractionManager(); - this.addInteraction(); - this.renderer.render(this.scene, this.camera); - } else { + if (this.puzzleInfo) { this.loadBackground(); + if (this.camera && this.scene) { + this.buildDirectionArray(); + this.removeInteraction(); + this.reCreateScene(); + this.createCamera(); + this.createInteractionManager(); + this.addInteraction(); + this.renderer.render(this.scene, this.camera); + } } } } private cubeDirections: Array = []; - @Input('puzzleId') - public puzzleId: string; - @Input() public puzzleInfo: PuzzleInfo | undefined;