Optimizing ThreeJS performance on Android devices

After following a tutorial on ThreeJS from , I decided to test my creation on my Nexus 5 Android phone. Unfortunately, the performance was extremely slow and I can't figure out why.

I noticed that other ThreeJS games on the website run smoothly on mobile devices, such as the "Hello Run" example.

Why is my Pong game running so slowly on mobile? And what steps can I take to improve its performance?

Answer №1

It's not just Android that's slow, my iPhone 6+ also experiences performance issues.

Based on my own experiences, here are a few tips to improve performance with three.js:

  1. Large files like vertices, triangles, and textures can slow down loading times due to network resource consumption.

  2. Using BufferGeometry instead of Geometry can significantly boost performance.

  3. Utilize the Geometry.merge method whenever possible.

  4. Avoid using geometry utilities like ExtrudedGeometry as they consume CPU and memory resources. Buffered geometry instances are recommended.

  5. Tools like mesh lab can help simplify mesh vertices without altering the appearance much.

  6. Invest time in optimizing shading program coding to maximize GPU usage.

Answer №2

Are you experiencing poor performance on your device due to lack of WebGL support? Don't worry, I have a solution that will allow you to run ThreeJs and access the GPU with ease.

Unfortunately, this can't be achieved using the native browser of the device.

If you're interested in packaging everything into a mobile app, my recommended setup includes Cordova, Crosswalk, and ThreeJs.

It's worth mentioning that Crosswalk is an innovative technology supported by Google and Intel, similar to what they do for Cordova. Cordova provides native device interaction while Crosswalk unleashes the power of WebGL.

You can check out a demo of an HTML5 application running with Threejs on the Google Play Store (Note: The demo is from Ludei, but I prefer Crosswalk since it's open source).

Demo Three JS

Setting up a project is straightforward - just create a Cordova project, add the platforms you need, integrate the Crosswalk Cordova plugin, and you're all set!

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

Creating a peaceful web platform with React that supports several user roles

I am in the process of developing a single-page web application that must be completely restful, which is new territory for me. One challenge I'm facing is determining how to efficiently render the user interface for different roles using React. With ...

Error: Attempting to access the `isPaused` property of a null object is not possible

For my Vue front-end app, I'm attempting to integrate wavesurfer.js. However, upon receiving the audio file link from the backend, I encounter the following error: wavesurfer.js?8896:5179 Uncaught (in promise) TypeError: Cannot read property 'isP ...

Is your website's Google analytics event tracking not giving you the feedback you need

Here's what I'm trying to achieve in the code below: Set up Google Analytics on the page Add a jQuery click event based on specific query strings and domain characters Trigger a Google Analytics tracking event with the click event Implement cod ...

An issue encountered in the axios package of vue.js, specifically with the error message "id=[object%20Object]"

I am facing an issue where I have an id called "test" as a parameter and I pass it to the index.js store. The error I see in the console is users?id=[object%20Object]. I tried converting the id with this.id.toString(), but unfortunately, it did not resolve ...

Make sure to close any existing Featherlight windows before trying to open another one

I'm setting up multiple featherlight instances when the page loads jQuery('.feedback').featherlight(jQuery( "#feedback-box" ), { closeIcon: 'close'}); jQuery('#imprint').featherlight(jQuery( "#imprint-box" ), { closeIcon ...

The controller and node js request associated are invisible to my HTML page

Here is my HTML code. I have just created a unique controller for a specific part of the code. <div class="mdl-grid" ng-controller="ValueController"> <div class="mdl-card mdl-shadow--4dp mdl-cell--12-col"> <div class ...

Adding QML code into a Jade file

Currently working on developing a straightforward video streaming application using Node.js and integrating the WebChimera plugin. The player configuration is done in QML with Chimera, and I am facing numerous errors during the compilation process in Jade. ...

Creating Seamless, Unified Shape-to-Shape (Containers) Transition with CSS and JavaScript - A Step-by-Step Guide

I am experimenting with creating a unique effect where two rectangular shapes, each containing text and with rounded ends, move towards each other, merge to form a single rounded rectangle as the page is scrolled down, and then separate back when scrolling ...

Array of generic types in Typescript

Here's a method that I have: getFiveObjectsFromArray(array: T[]) { return array.slice(0, 5); } I've been using this method multiple times. Is there a way in TypeScript to pass a generic argument instead of using multiple types? Also, when ...

Utilizing Google Web Fonts in Gatsby with Custom Styled Components

While using createGlobalStyle from styled-components for global styling, everything seems to be working fine except for applying Google fonts. I have tried multiple ways but can't seem to get it to work. Here's the code snippet: import { createG ...

Error encountered in onclick handler due to unterminated string literal in PHP and jQuery

Trying to utilize PHP to send variables into the onclick of an element is resulting in an "Unterminated string literal" error due to long strings. Below is a snippet of my PHP code: $query = $conn->prepare("SELECT Name, Image, Description, Link, Price, ...

What are some effective replacements for SoundManager2 worth considering?

While Soundmanager2 is a useful app, many find the code to be overly complex and difficult to navigate. It almost seems as if it was purposely written in a way to confuse rather than clarify. Are there any recommended alternatives to Soundmanager2 that are ...

What is the best way to determine the precise name and version of a web browser

I've been experimenting with some solutions, but I'm having trouble extracting the exact browser name and version: Here's the code I'm using: $browserAgent = $_SERVER['HTTP_USER_AGENT']; echo $browserAgent; The output of th ...

Utilize Bootstrap in an Angular template to effortlessly expand one element while collapsing all others

I'm facing an issue with a table in my component. Each row has a button that, when clicked, should expand to show some calculated data specific to that row. However, the problem is that when one button is expanded, it keeps other buttons expanded as w ...

Does moment/moment-timezone have a feature that allows for the conversion of a timezone name into a more easily comprehendible format?

Consider this example project where a timezone name needs to be converted to a more readable format. For instance: input: America/Los_Angeles output: America Los Angeles While "America/Los_Angeles" may seem human-readable, the requirement is to convert ...

I need to update a JSON file on the server by adding a new object to the existing array using the fs.appendFile function

I have a JSON stored on the server like this: [{"a":1}, {"a":2}] and I'm wondering if there is a way to add an object at the end without having to rewrite the entire file on the server. As a workaround, I have been omitting the brackets and adding the ...

Unable to execute the 'getElementsByTagName' function as null value is passed as the parameter

I'm encountering a problem with my first AJAX attempt and my first time using a .php file. I'm working through an exercise in the text, but things aren't going as expected. To troubleshoot, I've been using the alert function extensively ...

Getting the inner element of a particular child from the parent div using selenium with javascript

<div class="A"> <svg> ... </svg> <button> <svg> ... </svg> </button> <svg> ... </svg> </div> <div class="A"> <svg> ... </svg> <button> ...

Developed a verification process using Discord.JS, however, I'm not receiving any feedback when trying to configure the command

As I embark on creating my debut Discord bot to enhance my coding skills, I have encountered numerous hurdles along the way. While most of these challenges were overcome by me independently, this particular issue has left me stumped. The objective of the ...

Error encountered when calling the function .jstree() on a tree structure

While working on MVC4, I attempted to implement a jstree but encountered an issue where the tree view was not displayed when running my application. Upon investigating with Firebug, I came across the following error message: "TypeError: $(...).jstree is ...