Skip to content

Commit b0a006e

Browse files
committed
Fixed
1 parent efb5ff7 commit b0a006e

3 files changed

Lines changed: 8 additions & 43 deletions

File tree

‎src/components/Algorithms/Maze/Generation/BinaryTreeCreation.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export function BinaryTreeCreation(board) {
3737
}
3838
for (var x = 0; x < numPoints; x++) {
3939
let node = board[x];
40+
// const col = (i % numCols) - numCols / 2;
41+
// const row = Math.floor(i / numCols) - numCols / 2;
4042

43+
// node.x = col * 1.05;
44+
// node.y = row * 1.05;
4145
node.x = board[x].x = Math.floor(node.x);
4246
node.y = board[x].y = Math.floor(node.y);
4347
node.z = 0;

‎src/components/BoardCanvas/Cells.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function updateInstancedMeshMatrices({mesh, board}) {
6363
tempOBJ.rotation.set(0.5 * Math.PI, 0, 0); // Look at the origin
6464
tempCOLOR.set(getColor(board[i].type));
6565
tempOBJ.updateMatrix();
66-
mesh.setMatrixAt(i, tempOBJ.matrix);
66+
mesh.setMatrixAt(i, tempOBJ.matrix, tempCOLOR);
6767
}
6868
mesh.instanceMatrix.needsUpdate = true;
6969
}
@@ -175,7 +175,7 @@ const Cells = ({board, layoutType, mazeType, selectedPoint, onSelectPoint /*, u
175175
useEffect(() => {
176176
console.log('Board updated');
177177
updateInstancedMeshMatrices({mesh: meshRef.current, board});
178-
});
178+
}, [layoutType, mazeType]);
179179

180180

181181

‎src/components/BoardCanvas/Layouts.js‎

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,6 @@ export const useLayoutHook = ({board, layoutType}) => {
3737
};
3838

3939

40-
// export const useMazeTypeHook = ({board}) => {
41-
// useEffect(() => {
42-
// switch {
43-
// case 'binaryTree':
44-
// BinaryTreeCreation(board);
45-
// break;
46-
// case '_RecursiveBacktracker_':
47-
//
48-
// break;
49-
// case '_RecursiveDivision_':
50-
//
51-
// break;
52-
// case 'none':
53-
// default: {
54-
// return;
55-
// }
56-
// }
57-
5840
export function useAnimationHook({board, layoutType}) {
5941
console.log('useAnimationHook used.');
6042
useLayoutHook({board, layoutType}); // do the actual animation when layoutType changes
@@ -82,9 +64,10 @@ export function useGenerateMazeHook({board, mazeType}) {
8264
return;
8365
}
8466
}
85-
console.log('generatedMaze ended.');
8667

8768
}, [board, mazeType]);
69+
console.log('generatedMaze ended.');
70+
8871
}
8972

9073

@@ -123,28 +106,6 @@ export function useGenerateMazeHook({board, mazeType}) {
123106
};
124107

125108

126-
/* function BinaryTreeMaze(board) {
127-
const numPoints = board.length;
128-
const numCols = Math.ceil(Math.sqrt(numPoints));
129-
130-
for (let i = 0; i < numPoints; ++i) {
131-
const node = board[i];
132-
let direction = Math.random() * 4;
133-
134-
let xcord = board[i].x + directions[direction].x;
135-
let ycord = board[i].y + directions[direction].y;
136-
const col = (i % numCols) - numCols / 2;
137-
const row = Math.floor(i / numCols) - numCols / 2;
138-
139-
node.x = col;
140-
node.y = row;
141-
node.z = 0;
142-
node.type = board[i].type;
143-
}
144-
} */
145-
146-
147-
148109

149110

150111
function circularLayout(board) {

0 commit comments

Comments
 (0)