Just completed a project in WebGL using Javascript and the 3D library known as three.js
Unfortunately, the performance of the project is less than impressive - slow from the start with occasional moments of adequacy.
In this game, there are: 1 car, 6 oranges, 161 cheerios, 1 table, 1 fork, and 6 candles.
- The player controls the car in a race-like game, navigating through a circuit enclosed by cheerios. The car consists of various three.js geometries like box, torus, cylinder, and sphere. When an orange collides with the car, the player restarts and loses a life.
- All oranges move uniformly in straight lines, posing a threat to the car upon collision. Their structure consists of sphere and cylinder geometries in three.js.
- A cube-shaped table scaled to be 300x1x300 in xyz coordinates.
- Each candle acts as a pointlight source, flickering for added effect.
- In addition to the 6 pointlights, there is ambient light and 1 directional light, all created with three.js.
- The fork behaves like a billboard, constantly pointing towards the active camera represented by a plane.
- An explosion of particles occurs when an orange reaches its destination or when the car completes a lap. Each explosion includes at least 100 small plane particles following a billboard-like movement pattern.
- Upon creation, each particle within an explosion is individually added to the scene before eventually expiring after a set period of time (usually around 1000 milliseconds).
- All objects within the game feature their own textures, some not optimized with dimensions as powers of 2. Textures are loaded using the deprecated method THREE.ImageUtils.loadTexture(URL).
- Everything within the game, including scenes, cameras, lights, meshes, geometries, and materials, was built using three.js.
It has come to my attention that adding numerous cheerios significantly impacted the performance. Is there a way to use a single model for all cheerios similar to OpenGL's VS libs?
How can I enhance the overall performance of the project?
Please feel free to request more specific information if needed regarding this issue.