Exploring the Depths of a Room in ThreeJS

I am currently working on creating a room in ThreeJS, and here is the progress I have made so far:

http://jsfiddle.net/7oyq4yqz/

var camera, scene, renderer, geometry, material, mesh, focus;

init();
animate();

function init() {

    scene = new THREE.Scene();

    focus = new THREE.Vector3( 0, 0, 0 );

    camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
    scene.add(camera);
    camera.position.set(0,0,1);
    camera.lookAt(focus);
    camera.updateProjectionMatrix();

    controls = new THREE.TrackballControls( camera );
    controls.rotateSpeed = 3.0;
    controls.noZoom = true;
    controls.noPan = true;
    controls.staticMoving = true;
    controls.dynamicDampingFactor = 0.3;
    controls.keys = [ 65, 83, 68 ];

    controls.addEventListener( 'change', render );

    geometry = new THREE.BoxGeometry( 1000, 1000, 1000 );
    for ( var i = 0; i < geometry.faces.length; i ++ ) {
        geometry.faces[ i ].color.setHex(Math.random() * 0xffffff);
    }
   
    material = new THREE.MeshNormalMaterial();
 
    mesh = new THREE.Mesh(geometry, material);
    mesh.flipSided = true;
    scene.add(mesh);

    renderer = new THREE.WebGLRenderer({ antialias: false });
    renderer.setSize(window.innerWidth, window.innerHeight);

    document.body.appendChild(renderer.domElement);
    render();
}

function animate() {
    requestAnimationFrame(animate);
    controls.update();
}

function render() {
    renderer.render(scene, camera);

}

The current implementation works fine but lacks depth perception. The walls should feel farther away than they currently do. Can anyone suggest how I can achieve this effect? I've tried studying examples without success.

Answer №1

Adjusting the camera's field of view can enhance your photography.

THREE.PerspectiveCamera( 45

Experiment with values ranging from 10 to 180 for optimal results.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Increase the lag time for the execution of the on('data') function in Node.js

In my current function, it searches data from a database and performs an action with it. For the purpose of this demonstration, it simply increments a counter. exports.fullThreads = function(){ return new Promise((resolve, reject) => { MongoClien ...

React Router's default component for nested routes

In React Router, I am facing a challenge with nested Routes <Route path='about' component={{main: About, header: Header}}> <Route path='team' component={Team} /> </Route> Currently, the Team component is displayed ...

Encountered a problem with Google API during the execution of Vue mounted hook

Looking for some help with this issue. I've loaded the Google map API on the created hook of the parent component, but I keep running into the following error message: Error in the created hook: ReferenceError: google is not defined Here is the code ...

Obtaining the value of a JavaScript confirm popup in C#.NET

I am trying to implement a javascript confirm popup that returns a value from the code behind. When the user selects the ok button on the confirm popup, certain code will execute, and if they select cancel, different code will run. Is there a way to retri ...

The JSONP file can be successfully retrieved through an AJAX request in the console, however, the data does not display when attempting

Currently attempting to send an ajax request utilizing the following code snippet: $.ajax({ url: "http://mywebsite.com/blog/json", dataType: "jsonp", jsonpCallback: "jsonpCallback" }); function jsonpCallback(data) { console.log(data); } E ...

Unexpected behavior from Bootstrap within React

I recently started working on a React project that I initiated with the create-react-app command. To incorporate Bootstrap into my project, I added the necessary CDNs to the public/index.html file after generating the project. <link rel="stylesheet" hr ...

The structure of NodeJS Express API calls revolves around handling asynchronous events

Currently, I am working on a hobby project using NodeJS and Express, but I am finding it challenging to manage asynchronous calls. There is a bug that I would like the community's help in resolving. I have set up an Express layout where I send post r ...

What is the best way to determine the total number of rows in a JSON file?

Here is the JSON data I have: [0:{name:"jason",height:"150cm"}, 1:{name:"henry",height:"178cm"}] In my function, I am attempting to create a for loop like this: function DrawTable(output) { var ...

Exploring file writing using Node Webkit and JavaScript

When developing my app, I encountered an issue with the 'fs' module not functioning as expected. Despite the code being written to write a file, nothing happens when the app is launched. However, if I start the app using the following command: $ ...

Ways to restart script following Ajax call when additional search results are loaded

Implementing Klevu's search results page has been a manageable task so far. However, I encountered an issue where the search results page is displaying an Add to Cart button that should not be there, as confirmed by Klevu themselves. Their suggestion ...

How can I retrieve the class of the parent element by referencing the child id in jQuery?

I want to trigger an alert on click from the child id <th id="first"> to the table(parent) class. alert($(this).parent('tr').attr('class')); This code helped me to get the class of the <tr>. However, when I try to get the ...

Comparing partial strings using Mongodb aggregation techniques

After populating my MongoDB database with around 5000 questions, I am now looking to group questions together that are partially similar, ranging from 70% to 80% similarity, and then send them to the frontend. I attempted to achieve this using the pipelin ...

What is the best way to include dynamic query parameters in the src attribute of a <script> tag?

As I develop a basic asp.net application, I encountered a situation where I needed to include a script with a dynamic query parameter in my aspx page. For instance: <script src="../javascript/script.js?v=#var#" type="text/javascript"></script> ...

The Helper Text fails to display the error, and the error message does not appear when the login data is incorrect

Currently, I am facing an issue with displaying error messages within my helper text component while using Material UI. Despite successfully testing my backend code using Postman to identify errors, I am unable to see the error message under the button whe ...

Increase in textbox size depending on selected dropdown value

Our concept involves offering three choices: Email #1 pulled from the database Email #2 retrieved from the database Input a new email Should the user select option #3, a textbox will expand at the bottom of the dropdown menu for easy entry of a new emai ...

Having trouble establishing an HTTPS connection with a Node.js server

After connecting to my server through the console without any errors, I encountered an issue in Chrome where it displayed a message stating This site can’t provide a secure connection local host uses an unsupported protocol. Here is the code snippet: im ...

Typescript - Creating a Class with Constructor that Extends an Interface without Constructor

I am faced with an interface structured as follows: interface Person { id: number name: string } In my implementation class for this interface, I have the following code: class PersonClass implements Person { id: number = 123 name: string = &apo ...

State management at its core with integrated functionalities

I'm exploring different ways to manage application state within Angular 18 using its built-in features. Would it be effective to start with a simple service that utilizes dependency injection (DI)? As someone new to Angular 18, I'm a bit confuse ...

React native: Implementing a method to trigger an action upon entering a screen

Is there a way to trigger an action when a user visits a specific view in my application? I've tried using componentDidMount and componentWillMount but they don't seem to work for this purpose. If I include the action in the render method, it ca ...

I'm interested in knowing if it's feasible to develop unique jQuery selectors that can navigate ancestors, such as a :closest or :parents selector

As a developer who frequently creates jQuery plugins, I often find myself using custom jQuery selectors like :focusable and :closeto to simplify common filters in my code. For example, the :focusable selector is defined as follows: jQuery.extend(jQuery.e ...