1
1
import React , { useEffect } from "react" ;
2
- import { Canvas , useThree } from "react-three-fiber" ;
2
+ import { Canvas , useThree , useFrame } from "react-three-fiber" ;
3
3
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js" ;
4
4
5
5
// Components
@@ -10,6 +10,7 @@ import { Maze as IMaze, MazeInfo } from "../../models/maze/index";
10
10
import { Coord } from "../../models/maze" ;
11
11
12
12
import "./Maze.scss" ;
13
+ import { Vector3 , MOUSE } from "three" ;
13
14
14
15
// Helper functions
15
16
const getMazeSize = ( mazeInfo : MazeInfo ) => {
@@ -21,19 +22,18 @@ const getMazeSize = (mazeInfo: MazeInfo) => {
21
22
22
23
const CameraController = ( ) => {
23
24
const { camera, gl } = useThree ( ) ;
25
+
24
26
useEffect ( ( ) => {
25
27
const controls = new OrbitControls ( camera , gl . domElement ) ;
26
28
27
- controls . minDistance = 5 ;
29
+ controls . minDistance = 2 ;
28
30
controls . maxDistance = 30 ;
29
- controls . keyPanSpeed = 10 ;
30
-
31
- //uncomment to limit orbit rotation
32
- // controls.maxAzimuthAngle = (Math.PI / 360) * angle;
33
- // controls.minAzimuthAngle = (Math.PI / 360) * -angle;
34
-
35
- controls . maxPolarAngle = ( Math . PI / 360 ) * 180 ;
31
+ controls . keyPanSpeed = 20 ;
36
32
33
+ controls . maxAzimuthAngle = 0 ;
34
+ controls . minAzimuthAngle = 0 ;
35
+ controls . maxPolarAngle = 0 ;
36
+
37
37
return ( ) => {
38
38
controls . dispose ( ) ;
39
39
} ;
@@ -102,7 +102,11 @@ const Maze: React.FC<Props> = props => {
102
102
// bottom: 100,
103
103
// top: 10
104
104
// }}
105
+ camera = { {
106
+ position : new Vector3 ( 0 , 10 , 0 )
107
+ } }
105
108
>
109
+
106
110
< CameraController />
107
111
< ambientLight />
108
112
0 commit comments