@@ -65,7 +65,7 @@ const populateMaze = (props: Props, openSet: Coord[], closedSet: Coord[]) => {
65
65
type = { mazeInfo [ y ] [ x ] . type }
66
66
visited = { mazeInfo [ y ] [ x ] . visited }
67
67
path = { mazeInfo [ y ] [ x ] . path }
68
- position = { { x, z : 0 , y } }
68
+ position = { { x : x - mazeSize . x / 2 , z : 0 , y : y - mazeSize . y / 2 } }
69
69
inOpenSet = { includesCoord ( openSet , { x, y } as Coord ) }
70
70
inClosedSet = { includesCoord ( closedSet , { x, y } as Coord ) }
71
71
key = { key }
@@ -335,7 +335,7 @@ const Maze: React.FC<Props> = (props) => {
335
335
336
336
// If we end up removing the last space we end BFS
337
337
if ( queue . length === 0 ) {
338
- handlePauseVisualization ( ) ;
338
+ if ( isPlaying ) handlePauseVisualization ( ) ;
339
339
return ;
340
340
}
341
341
}
@@ -353,7 +353,7 @@ const Maze: React.FC<Props> = (props) => {
353
353
// Update bfsQueue and set curr to visited
354
354
progressBFS ( queue , curr , currNeighbors ) ;
355
355
} else {
356
- handlePauseVisualization ( ) ;
356
+ if ( isPlaying ) handlePauseVisualization ( ) ;
357
357
progressBFS ( [ ] , curr , currNeighbors ) ;
358
358
}
359
359
}
@@ -475,7 +475,7 @@ const Maze: React.FC<Props> = (props) => {
475
475
}
476
476
} else {
477
477
console . log ( "NO SOLUTION" ) ;
478
- handlePauseVisualization ( ) ;
478
+ if ( isPlaying ) handlePauseVisualization ( ) ;
479
479
return ;
480
480
}
481
481
} , 100 / currentSpeed ) ;
@@ -556,7 +556,7 @@ const Maze: React.FC<Props> = (props) => {
556
556
}
557
557
} else {
558
558
console . log ( "NO SOLUTION" ) ;
559
- handlePauseVisualization ( ) ;
559
+ if ( isPlaying ) handlePauseVisualization ( ) ;
560
560
return ;
561
561
}
562
562
} , 100 / currentSpeed ) ;
@@ -575,7 +575,7 @@ const Maze: React.FC<Props> = (props) => {
575
575
// top: 10
576
576
// }}
577
577
camera = { {
578
- position : new Vector3 ( 0 , 10 , 0 ) ,
578
+ position : new Vector3 ( 0 , getMazeSize ( mazeInfo ) . x , 0 ) ,
579
579
} }
580
580
>
581
581
< CameraController />
0 commit comments