Skip to content

Commit 157e943

Browse files
author
Jame
committed
fixed the camera to be facing downward, removed the ability to rotate, and increased panning speed
1 parent c919355 commit 157e943

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Maze/Maze.tsx

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect } from "react";
2-
import { Canvas, useThree } from "react-three-fiber";
2+
import { Canvas, useThree, useFrame } from "react-three-fiber";
33
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
44

55
// Components
@@ -10,6 +10,7 @@ import { Maze as IMaze, MazeInfo } from "../../models/maze/index";
1010
import { Coord } from "../../models/maze";
1111

1212
import "./Maze.scss";
13+
import { Vector3, MOUSE } from "three";
1314

1415
// Helper functions
1516
const getMazeSize = (mazeInfo: MazeInfo) => {
@@ -21,19 +22,18 @@ const getMazeSize = (mazeInfo: MazeInfo) => {
2122

2223
const CameraController = () => {
2324
const { camera, gl } = useThree();
25+
2426
useEffect(() => {
2527
const controls = new OrbitControls(camera, gl.domElement);
2628

27-
controls.minDistance = 5;
29+
controls.minDistance = 2;
2830
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;
3632

33+
controls.maxAzimuthAngle = 0;
34+
controls.minAzimuthAngle = 0;
35+
controls.maxPolarAngle = 0;
36+
3737
return () => {
3838
controls.dispose();
3939
};
@@ -102,7 +102,11 @@ const Maze: React.FC<Props> = props => {
102102
// bottom: 100,
103103
// top: 10
104104
// }}
105+
camera={{
106+
position: new Vector3(0,10,0)
107+
}}
105108
>
109+
106110
<CameraController />
107111
<ambientLight />
108112

0 commit comments

Comments
 (0)