Refactored the WHOLE project
From a simple test file, we're now on road to create a real project Took 3 hours, but code looks nice
This commit is contained in:
14
src/cameras/PerspectiveCamera.js
Normal file
14
src/cameras/PerspectiveCamera.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as THREE from 'three';
|
||||
import * as MathUtils from 'three/src/math/MathUtils.js';
|
||||
|
||||
export function getCamera(){
|
||||
/* Function to create and place the Camera object. is freecam is true, it will enable freecam controls for easier debug*/
|
||||
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
|
||||
|
||||
camera.position.x = 0;// <----->
|
||||
camera.position.y = -4;// ^^ / vv
|
||||
camera.position.z = 4;// ^-----v
|
||||
camera.rotateOnWorldAxis(new THREE.Vector3(1, 0, 0), MathUtils.degToRad(60));
|
||||
|
||||
return camera;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
//https://medium.com/geekculture/how-to-control-three-js-camera-like-a-pro-a8575a717a2
|
||||
|
||||
import * as THREE from 'three';
|
||||
import { FlyControls } from 'three/examples/jsm/controls/FlyControls';
|
||||
|
||||
let controls;
|
||||
export function enableFreeCam(camera, renderer){
|
||||
controls = new FlyControls( camera, renderer.domElement );
|
||||
controls.movementSpeed = 5;
|
||||
controls.rollSpeed = Math.PI / 48;
|
||||
controls.autoForward = false;
|
||||
controls.dragToLook = true;
|
||||
}
|
||||
|
||||
export function updateFreeCamKeys(){
|
||||
controls.update(0.01)
|
||||
}
|
||||
Reference in New Issue
Block a user