Skip to content

Commit

Permalink
Cleaning (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgatelabs authored Mar 11, 2022
1 parent 30e72d8 commit fce7bde
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/app/puzzle-view/puzzle-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ <h2>
<app-three-dview
(configurationChanged)="updateConfigurationChange($event)"
#threedview
puzzleId="{{ puzzleId }}"
[puzzleInfo]="puzzleInfo"
class="col-xs-12 col-lg-8"
></app-three-dview>
Expand Down
20 changes: 6 additions & 14 deletions src/app/puzzle-view/puzzle-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand All @@ -71,7 +70,6 @@ export class PuzzleViewComponent implements OnInit, AfterViewInit {
);

if (this.afterInit) {
//this.someElement.puzzleInfo = this.puzzleInfo!;
this.solvePuzzle();
}
}
Expand All @@ -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) {
Expand Down
27 changes: 13 additions & 14 deletions src/app/three-dview/three-dview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,33 @@ export class ThreeDViewComponent implements OnInit, AfterViewInit, OnChanges {

ngOnInit(): void {}

ngAfterViewInit(): void {}
ngAfterViewInit(): void {
this.loadTextures();
}

public startView() {
this.loadTextures();
}

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<PuzzleDirection> = [];

@Input('puzzleId')
public puzzleId: string;

@Input()
public puzzleInfo: PuzzleInfo | undefined;

Expand Down

0 comments on commit fce7bde

Please sign in to comment.