Skip to content

Commit 1f105c4

Browse files
committed
finishing board rendering algo
1 parent e7cd580 commit 1f105c4

File tree

11 files changed

+109
-46
lines changed

11 files changed

+109
-46
lines changed

package-lock.json

Lines changed: 2 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@react-three/fiber": "^8.0.27",
67
"@testing-library/jest-dom": "^5.16.4",
78
"@testing-library/react": "^13.3.0",
89
"@testing-library/user-event": "^13.5.0",
10+
"csstype": "^3.1.0",
911
"react": "^18.2.0",
1012
"react-dom": "^18.2.0",
1113
"react-router": "^6.3.0",
1214
"react-router-dom": "^6.3.0",
13-
"react-three-fiber": "^6.0.13",
1415
"rsuite": "^5.16.0",
1516
"web-vitals": "^2.1.4"
1617
},

src/App.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import './App.css';
22
import React, {Component} from 'react';
3-
import {Canvas} from 'react-three-fiber';
3+
import {Canvas, useFrame} from '@react-three/fiber';
44

55
import {Strategy /*changeRed*/} from './components/Strategy/Strategy';
66
import {InputField} from './components/Canvas/InputField.js';
@@ -13,6 +13,7 @@ import Footer from './components/Page/partial/Footer';
1313
import SplashScreen from './components/Page/Splash/SplashScreen';
1414
import Box from './modals/cube/Box';
1515
import AppRouter from './AppRouter';
16+
import Cell from './components/Board/Cell';
1617

1718

1819

@@ -30,15 +31,21 @@ class App extends Component {
3031
render() {
3132

3233
return (
33-
<>
34-
<div className = "App">
35-
<AppRouter/>
34+
/*<div className = "App">
3635
37-
</div>
36+
<AppRouter/>
3837
39-
</>
40-
);
38+
</div>*/
4139

40+
// TESTING PURPOSES: CELL COMPONENT
41+
<Canvas>
42+
<Cell id = {1}
43+
value = {1}
44+
size = {1}
45+
position = {[0, 0, 0]}
46+
/>
47+
</Canvas>
48+
);
4249
}
4350
}
4451

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import {Component} from 'react';
2+
import {Canvas, useFrame} from '@react-three/fiber';
3+
4+
5+
6+
export class Display extends Component {
7+
constructor(fArgs) {
8+
super(fArgs);
9+
this.state = {
10+
displayType: fArgs.displayType,
11+
algorithm : fArgs.algorithm,
12+
dataString : fArgs.dataString,
13+
width : fArgs.innerWidth,
14+
height : fArgs.innerHeight,
15+
aspect : fArgs.aspect,
16+
perspective: fArgs.perspective,
17+
};
18+
}
19+
20+
21+
componentDidMount() {
22+
window.addEventListener('resize', this.handleWindowSizeChange);
23+
}
24+
25+
26+
componentWillUnmount() {
27+
window.removeEventListener('resize', this.handleWindowSizeChange);
28+
}
29+
30+
31+
handleWindowSizeChange = () => {
32+
this.setState({width: window.innerWidth, height: window.innerHeight});
33+
};
34+
35+
36+
render() {
37+
const {width, height} = this.state;
38+
const aspect = width / height;
39+
return (
40+
<Canvas children = {}>
41+
42+
</Canvas>
43+
);
44+
};
45+
}

src/components/Algorithms/Greedy/Greedy.js

Whitespace-only changes.

src/components/Algorithms/MinMax/MiniMax.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class MiniMax {
5050
return 0;
5151
}
5252

53-
var board = new Board(grid);
54-
var leaves = new Move[10];
53+
var board = new Board(grid);
54+
let leaves: Move[] = new Move[10];
5555

5656
//
5757
for (var iter = 0; iter < leaves.length; iter++) {
@@ -60,7 +60,7 @@ class MiniMax {
6060
}
6161
}
6262

63-
var bestMove = null;
63+
let bestMove: Move = null;
6464
for (var i = 0; i < leaves.length; i++) {
6565
if (bestMove == null) {
6666
// bestMove = moves[i];

src/components/Algorithms/Search/BreadthFirst.js

Whitespace-only changes.

src/components/Algorithms/Search/DepthFirst.js

Whitespace-only changes.

src/components/Board/Cell.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {Component} from 'react';
2+
import Box from '../../modals/cube/Box';
3+
4+
5+
6+
const Cell = (fArgs) => {
7+
const id = fArgs.id;
8+
const value = fArgs.value;
9+
const onClick = fArgs.onClick;
10+
return (
11+
<Box size = {fArgs.size}/>
12+
);
13+
14+
};
15+
16+
export default Cell;

src/components/Page/Splash/SplashScreen.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import './splash.css';
33
import Navigation from '../partial/Navbar/Navigation';
4+
import Cell from '../../Board/Cell';
45

56

67

0 commit comments

Comments
 (0)