@@ -17,11 +17,11 @@ import {BinaryTreeCreation} from '../Algorithms/Maze/Generatio
1717 * Board type selector hook.
1818 *
1919 */
20- export const useLayoutHook = ( { board, layoutType = 'standard' } ) => {
20+ export const useLayoutHook = ( { board, layoutType} ) => {
2121 console . log ( 'useLayoutHook used.' ) ;
2222
2323 useEffect ( ( ) => {
24- console . log ( 'useLayoutHook MEMO E1 used.' ) ;
24+ console . log ( 'useLayoutHook used.' ) ;
2525
2626 // if === "none") {
2727 switch ( layoutType ) {
@@ -54,90 +54,19 @@ export const useLayoutHook = ({board, layoutType = 'standard'}) => {
5454// return;
5555// }
5656// }
57- // }, [board]);
58- // };
59-
60-
61- /*
62- This function component is used to animate the grid layout by
63- altering the points(Cells)' position on the board.
64-
65- "Deep Linking" is used to animate the grid layout.
66- */
67- // function useTargetLayoutHook({board, layoutType}) {
68- //
69- // useEffect(() => {
70- // for (let i = 0; i < board.length; ++i) {
71- // board[i].sourceX = board[i].x || 0;
72- // board[i].sourceY = board[i].y || 0;
73- // board[i].sourceZ = board[i].z || 0;
74- // board[i].sourceType = board[i].type;
75- // }
76- // }, [board, layoutType]);
77- //
78- // useLayoutHook({board, layoutType});
79-
80- // useEffect(() => {
81- // for (let i = 0; i < board.length; ++i) {
82- // board[i].targetX = board[i].x;
83- // board[i].targetY = board[i].y;
84- // board[i].targetZ = board[i].z;
85- // board[i].targetType = board[i].type;
86- // }
87- // }, [board, layoutType]);
88- //
89-
90- // interpolateSourceTarget({board});
91- // }
92-
93-
94- /*
95- function useMazeTargetHook({board}) {
96- useEffect(() => {
97- for (let i = 0; i < board.length; ++i) {
98- board[i].sourceX = board[i].x || 0;
99- board[i].sourceY = board[i].y || 0;
100- board[i].sourceZ = board[i].z || 0;
101- board[i].sourceType = board[i].type || '_floor_';
102- }
103- }, [board]);
104-
105- useMazeTypeHook({board});
106-
107- useEffect(() => {
108- for (let i = 0; i < board.length; ++i) {
109- board[i].targetX = board[i].x;
110- board[i].targetY = board[i].y;
111- board[i].targetZ = board[i].z;
112- board[i].targetType = board[i].type;
113- }
114- }, [board]);
115- }
116- */
117-
118-
119- // function interpolateSourceTarget(board) {
120- // for (let i = 0; i < board.length; ++i) {
121- // board[i].x = board[i].targetX;
122- // board[i].y = board[i].targetY;
123- // board[i].z = board[i].targetZ;
124- // board[i].type = board[i].targetType;
125- // }
126- // }
127-
128-
129-
130-
13157
13258export function useAnimationHook ( { board, layoutType} ) {
133-
59+ console . log ( 'useAnimationHook used.' ) ;
13460 useLayoutHook ( { board, layoutType} ) ; // do the actual animation when layoutType changes
61+ console . log ( 'useAnimationHook ended.' ) ;
62+
13563}
13664
13765
13866export function useGenerateMazeHook ( { board, mazeType} ) {
67+ console . log ( 'generatedMaze used.' ) ;
68+
13969 useEffect ( ( ) => {
140- console . log ( 'generatedMaze used.' ) ;
14170 switch ( mazeType ) {
14271 case 'binaryTree' :
14372 BinaryTreeCreation ( board ) ;
@@ -153,6 +82,8 @@ export function useGenerateMazeHook({board, mazeType}) {
15382 return ;
15483 }
15584 }
85+ console . log ( 'generatedMaze ended.' ) ;
86+
15687 } , [ board , mazeType ] ) ;
15788}
15889
@@ -171,7 +102,7 @@ export function useGenerateMazeHook({board, mazeType}) {
171102 node . x = col * 1.05 ;
172103 node . y = row * 1.05 ;
173104 node . z = 0 ;
174- node . type = board [ i ] . type || '_wall_' ;
105+ // node.type = board[i].type || '_wall_';
175106
176107 }
177108 }
0 commit comments