set camera FOV as parameter
This commit is contained in:
@@ -27,15 +27,17 @@ THREE.Cache.enabled = true
|
||||
const assetPath = '/asset/default/';
|
||||
const defaultLightIntensity = 11;
|
||||
const defaultInteractionDistance = 10;
|
||||
const defaultCameraFov = 50;
|
||||
const sceneScale = 1.33;
|
||||
|
||||
class GameEngine extends EventManager{
|
||||
|
||||
async initScene(){
|
||||
this.perspectiveCamera = new THREE.PerspectiveCamera(45, this.aspect, 0.001, 99);
|
||||
this.perspectiveCamera = new THREE.PerspectiveCamera(defaultCameraFov, this.aspect, 0.001, 399);
|
||||
//this.perspectiveCamera.position.set(0, 0, 10);
|
||||
|
||||
this.camera = this.perspectiveCamera;
|
||||
this.defaultCameraFov = defaultCameraFov;
|
||||
|
||||
this.frustumSize = 50;
|
||||
this.orthographicCamera = new THREE.OrthographicCamera(
|
||||
@@ -371,6 +373,9 @@ class GameEngine extends EventManager{
|
||||
}
|
||||
|
||||
disposeXr(){
|
||||
if (this.renderer.xr.isPresenting){
|
||||
this.renderer.xr.getSession().end();
|
||||
}
|
||||
[this.xrController1, this.xrController2].forEach(c=>{
|
||||
c.removeEventListener('select', this.xrHandlers.onSelect);
|
||||
c.removeEventListener('selectstart', this.xrHandlers.onControllerEvent);
|
||||
|
||||
+6
-6
@@ -81,9 +81,9 @@ class Hero{
|
||||
this.size = engine.meshUtils.getBoundingBoxSize(bb);
|
||||
//console.log('Hero size is', this.size);
|
||||
this.cameraYBase = this.size.y / this.engine.scale;
|
||||
this.cameraZMin = 1 / this.engine.scale;
|
||||
this.cameraZMin = 0.25 / this.engine.scale;
|
||||
this.cameraZMax = 12 / this.engine.scale;
|
||||
this.#cameraZ = this.cameraZDefault = 4 / this.engine.scale;
|
||||
this.#cameraZ = this.cameraZDefault = 2 / this.engine.scale;
|
||||
|
||||
// let center = getBoundingBoxCenterPoint(bb, io.object.position)
|
||||
|
||||
@@ -107,7 +107,7 @@ class Hero{
|
||||
//this.characterController.setMaxSlopeClimbAngle(90 * Math.PI / 180);
|
||||
// Automatically slide down on slopes smaller than 30 degrees.
|
||||
// this.characterController.setMinSlopeSlideAngle(30 * Math.PI / 180);
|
||||
// this.characterController.enableAutostep(0.5, 0.2, true);
|
||||
//this.characterController.enableAutostep(0.5, 0.002, true);
|
||||
//this.characterController.setApplyImpulsesToDynamicBodies(true);
|
||||
// this.characterController.setCharacterMass(50);
|
||||
|
||||
@@ -134,7 +134,7 @@ class Hero{
|
||||
if (this.engine.renderer.xr.isPresenting && !this.fpv){
|
||||
this.cameraMode = 'fixed'
|
||||
this.engine.cameraRig.position.y = -this.engine.camera.position.y;
|
||||
this.engine.dashboard.object.position.y = this.engine.camera.position.y;
|
||||
//this.engine.dashboard.object.position.y = this.engine.camera.position.y;
|
||||
//this.cameraY = this.size.y * 1;
|
||||
//this.camera = this.engine.cameraWorld;
|
||||
// this.engine.activeObjects.position.x = -this.camera.position.x;
|
||||
@@ -143,7 +143,7 @@ class Hero{
|
||||
this.cameraMode = 'rotate'
|
||||
this.cameraDelta = 0;
|
||||
this.engine.cameraRig.position.y = - this.engine.camera.position.y;
|
||||
this.engine.dashboard.object.position.y = this.engine.camera.position.y;
|
||||
//this.engine.dashboard.object.position.y = this.engine.camera.position.y;
|
||||
}else{
|
||||
this.cameraMode = 'rotate'
|
||||
this.engine.cameraRig.position.y = 0;
|
||||
@@ -168,7 +168,7 @@ class Hero{
|
||||
if (!this.fpv && !this.model.visible){
|
||||
this.model.visible = true;
|
||||
this.#cameraZ = this.cameraZDefault;
|
||||
this.engine.camera.fov = 45;
|
||||
this.engine.camera.fov = this.engine.defaultCameraFov;
|
||||
this.engine.camera.updateProjectionMatrix();
|
||||
}
|
||||
let input = pc.input;
|
||||
|
||||
@@ -204,9 +204,9 @@ function onMouseMove( event ) {
|
||||
function onMouseWheel( event ){
|
||||
if (this.isLocked){
|
||||
this.engine.camera.fov += event.deltaY / 100;
|
||||
this.engine.camera.fov = Math.min(Math.max(this.engine.camera.fov, 0.01), 45);
|
||||
this.engine.camera.fov = Math.min(Math.max(this.engine.camera.fov, 0.01), this.engine.defaultCameraFov);
|
||||
this.engine.camera.updateProjectionMatrix();
|
||||
if (this.engine.camera.fov >= 45){
|
||||
if (this.engine.camera.fov >= this.engine.defaultCameraFov){
|
||||
this.unlock();
|
||||
}
|
||||
this.engine.dashboard?.orient();
|
||||
@@ -221,7 +221,7 @@ function onPointerlockChange() {
|
||||
this.isLocked = false;
|
||||
this.dispatchEvent( { type: 'unlock' } );
|
||||
}
|
||||
this.engine.camera.fov = 45;
|
||||
this.engine.camera.fov = this.engine.defaultCameraFov;
|
||||
this.engine.camera.updateProjectionMatrix();
|
||||
this.engine.dashboard?.orient();
|
||||
//this.engine.cameraRig.rotation.y = this.isLocked ? 0 : Math.PI;
|
||||
|
||||
Reference in New Issue
Block a user