Repository navigation
Expand file tree
/
Copy pathBoard.js
More file actions
63 lines (58 loc) · 1.46 KB
/
Copy pathBoard.js
File metadata and controls
63 lines (58 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import * as React from "react";
// import {useFrame /*useFrame*/} from '@react-three/fiber';
import { forwardRef, useImperativeHandle, useRef } from "react";
import { Canvas } from "react-three-fiber";
import {
default as Controls,
default as OrbitControls,
} from "../OrbitControls";
import Cells from "./Cells";
export const Board = (
{
board,
solving,
algorithm,
layoutType,
selectedPoint,
onSelectPoint,
mazeType,
},
ref
) => {
// Based on Peter Beshai's grid example:
const controlsRef = useRef(OrbitControls);
useImperativeHandle(ref, () => ({
resetCamera: () => {
return controlsRef.current.resetCamera();
},
}));
return (
<Canvas>
<Controls ref={controlsRef} selectedPoint={selectedPoint} />
<mesh>
{" "}
{/* BorderBox */}
<boxBufferGeometry attach="geometry" args={[80, 80, -10]} />
<meshBasicMaterial attach="material" color="black" />
</mesh>
<ambientLight color="white" intensity={0.1} />
<hemisphereLight
color="#ffffff"
skyColor="#ffffbb"
groundColor="#080820"
intensity={1.0}
/>
<Cells
board={board}
layoutType={layoutType}
mazeType={mazeType}
solving={solving}
algorithm={algorithm}
selectedPoint={selectedPoint}
onSelectPoint={onSelectPoint}
/>
{/*<Effects />*/}
</Canvas>
);
};
export default forwardRef(Board);