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:
2023-11-15 17:23:11 +01:00
parent c73aa99ca2
commit d15d257ddb
8 changed files with 191 additions and 133 deletions

View 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;
}

View File

@@ -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)
}