Having a THREE.js application running in Chrome causes my browser to slow down significantly

As I work on developing a small 2D game using THREE.js, I've encountered an issue where having a tab open with my THREE.js app loaded causes all my other tabs to slow down significantly. However, when I switch tabs and hide the THREE.js tab, everything returns to normal speed. Is there a solution to this problem? I suspect it may be related to the requestAnimationFrame(render) function running continuously. Any advice on optimizing the use of requestAnimationFrame in THREE.js?

Answer №1

Three.js configurations often require rendering the scene 60 times per second, a demanding task for many devices. Operating a WebGL website always demands more resources compared to a standard HTML page. Optimizing each frame is specific to the individual setup, so there isn't a one-size-fits-all solution. It usually involves finding a balance between performance and visual quality. Below are some common factors that could be impacting performance, although this list is not exhaustive:

  • High Mesh count (consider merging geometries or using instancing when meshes repeat)
  • Too many lights (try using light-maps to minimize dynamic lights)
  • Rendering at high DPI (reduce pixel ratio if possible)
  • Anti-aliasing (avoiding AA can save resources)
  • Complex shadows (opt for baked shadows over dynamic shadows)
  • Complex shaders (some realistic shaders may require more computation)
  • Expensive post-processing
  • Full-screen rendering (higher resolutions are more resource-intensive)
  • Discrete GPU (dedicated graphics cards typically offer better performance than integrated graphics in CPUs, which some laptops lack)

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

Unable to fetch data using getJSON method

objecten.js var objectData = [ { image: 'gallery/objecten/bear.jpg', thumb: 'gallery/objecten/bear.jpg', title: 'my first image', description: 'Lorem ipsum caption&apos ...

Sending a javascript variable to an angularjs scope

Currently, I am utilizing Flask to render an HTML template and wish to transfer the variable add_html_data, which is passed via Flask's render_template, to the scope of an AngularJS controller. I have attempted the following: <body> <di ...

Locate items across three different arrays

Is there a more efficient way to search for an element across 3 arrays and create a string using their values? I have attempted a solution and generated the output, but I am curious if there is a better approach available. var numbers = ['1',&ap ...

What is the best way to utilize Enquire.js for dynamically adding and removing CSS classes?

I'm looking to dynamically add and remove a css class based on a media query using Enquire.js but I could use some guidance on utilizing the functions properly. Here's what I envision in pseudo code: if (screens max-width > 480px){ #thumb.r ...

``Is there a way to effectively assess the Angular UI-Grid cellTemplate function in the attribute value only when it is displayed

Utilizing angularjs and ui-grid with a custom cellTemplate, each cell contains an object referred to as COL_FIELD. This object is passed to a function that generates an image data URI used in the src attribute of the cellTemplate to display images within e ...

Is it possible for the data submitted in a POST request to be converted into URL parameters?

Our technology stack: Frontend built with Vue.js and utilizing the vuetify component library Custom Python middleware REST API using Flask + Tornado External Matomo setup connected to the frontend via the vue-matomo plugin system (https://github.com/Amaz ...

"I'm having trouble with the Icosahedron geometry not appearing correctly

I'm currently experimenting with three.js and I've managed to successfully draw and animate a cube. However, when I try to change the geometry to an Icosahedron, nothing shows up on the screen. Within my js source folder, I only have the three.m ...

Leveraging external objects in Vue.js computed functions

Can Vue's computed property be used with an external object? Let's consider the following code example to illustrate the idea: <!-- Vue file --> <template> <div>{{data.auth}}</div> </template> <script> i ...

Angular2 - Utilizing Promises within a conditional block

I'm currently facing an issue where I need to await a response from my server in order to determine if an email is already taken or not. However, I am struggling to achieve this synchronously. TypeScript is indicating that the function isCorrectEmail( ...

Attempting to use express and nodemailer to send an email, but there is absolutely no output appearing in either the console or the terminal

When I click the send email button, it should send the data to a mailhog inbox. However, nothing happens - no errors in the console or terminal. My goal is to use nodemailer to send the name, email, chosen plan, and message from the form to the mailhog add ...

Setting up a simple configuration for WebGl and Javascript

I am currently using OSX 10.9.5 (Mavericks) and following a WebGL tutorial script provided on . I copied and pasted the code from the tutorial into TextEdit and saved it as HTML with the following file structure: webgl | +--index.html | ...

React is nowhere to be seen

index.js: import react from 'react'; import {render} from 'react-dom'; render( <h1>Hello World!</h1>, document.getElementById('root') ); package.json: { "name": "", "version": "1.0.0", "descriptio ...

Unable to call Ionic component function using ref in Vue3

I'm attempting to utilize the closeSlidingItems method of the IonList element in order to automatically close the sliding item after clicking a button that appears from behind once the item is slid to the right. My approach involved referencing IonLi ...

Limit access to the server in Node.js by allowing loading only if the request is coming from another page and form POST variables are present

After searching for documentation without success, I have a question: Is there a way to prevent users from directly accessing my node.js server at website.com:3000? Currently, when a user visits my node.js website, it crashes the whole server and takes i ...

Utilizing Google Language API for bulk translation tasks

My current project involves using Google's AJAX Language API to translate each element in an array. for(var i=0; i < mytext.length; i++) { google.language.translate(mytext[i], originalLanguage, newLanguage, function(result){ if(!result.error){ ...

Tips for aligning an image in the middle of a column within an ExtJS GridPanel

My goal is to center the icon horizontally within the "Data" column: Currently, I have applied textAlign: center to the column: Additionally, I am using CSS in the icon renderer function to horizontally center it: Despite these efforts, the icon remains ...

Utilizing R3F OrbitControls to maintain a constant camera perspective

Currently I am working on a project involving a 360 image, and it is crucial for the camera to remain fixed at the coordinates (0,0,0). However, whenever I try to update the camera position, the controls stop functioning properly. While researching this ...

Adjust the camera position in Three.js by moving it forwards and backwards

Is there a way to move a camera back and forth from a fixed position along its current trajectory? I've tried using existing control scripts, but I need something customized and haven't been able to isolate the desired behavior from their code. ...

Issue with the transmission of FormData and string data to PHP

Struggling to properly handle sending file data and string data together through ajax to PHP. Having trouble retrieving the correct string data from $_POST[] in PHP, resulting in only receiving the initial alphabet of a string instead of the specific produ ...

Toggle the visibility of a div based on whether or not certain fields have been filled

Having a form with a repeater field... <table class="dokan-table"> <tfoot> <tr> <th colspan="3"> <?php $file = [ 'file' => ...