I make the lottery drum with Babylon js. The lottery drum itself is a cylinder located in another cylinder. so I make a cavity in it. Balls spin inside it. Lottery drum has MeshImpostor. but it greatly reduces FPS. how can i fix this?
Hey @11116…great to have you as a part of the Babylon family.
Can you please provide a playground so that we can help you troubleshoot?
Sorry for the mess in my code, I’m new to Babylon.js
http://test3.avior.by/site/3d/index.html. link to my site.
https://www.babylonjs-playground.com/#4BEMYY . Link to playground
Thanks for the playground.
Looping in the physics master @RaananW.
One thing you might want to try is different physics engine to see if the mesh imposter has better performance in a different one. Perhaps try ammo?
I has tried, but unfortunately I get an error. I’m building my game using webpack.
Uncaught TypeError: this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration is not a constructor
scene.enablePhysics(null, new BABYLON.AmmoJSPlugin(true, 100, ammo));
Ammo package downloaded using npm and connect it through import
The demo using Ammo:
Cannon doesn’t handle too many mesh impostors at the same time. If you want to use cannon, you will need to create containers instead (using other impostors)
maybe you know how I can fix the error, which is on the screen above?
A better version with less friction:
Whenever you need to use so much (max) force on a motor, know that there is either too much mass involved, or too much friction. In your case, it was too much friction (which also made cannon crazy)
For that I will need to know your setup -
npm? which babylon packages are you loading? how do you import ammo?
can you try (just for the sake of trying) to define
window.Ammo = ammoImport;
this might be helpful as well - ES6 - Babylon.js Documentation
I registered the following commands:
npm i -s babylonjs
npm i -s ammo.js
import * as ammo from 'ammo.js';
UDM should be able to find ammo automatically, but it seems like it doesn’t in your case.
What you could is define Ammo as external in webpack, and set it to be a global variable on window. if you set the external to load the
Ammo namespace, it should load the global namespace whenever you load it.
Having said that - if you are already using ES6 imports i would recommend using the @babylonjs/core package instead of babylonjs. The import will (probably) work better.
Thank you very much for your quick help. The FPS has really risen, but still holds in the region of 20. Can it be even higher? I just wonder how they make big games presented on the official website with normal FPS. I have an easy game, and already such a FPS …
not sure on what computer you are testing, but i am getting a constant 60 FPS.
Constant mesh to mesh is a heavy computation… try maybe simplifying your physics object while still showing complex objects. This will help with FPS for sure.
what do you mean by simplification?
It should be noted that on the playground FPS higher by 15 - 20 points, then the localhost
This means it could be related to your window size so GPU. Maybe your GPU is blacklisted ??? You should first profile it in the dev tools and then check in the chrome://gpu tabs for issues ???
just wanted to say (as it might sounds like this) - it is not that we don’t believe you, it is simply very hard to tell why locally it renders differently then on a different computer. it is usually a CPU/GPU issue, but could be other factors.
About simplifications - use less mesh impostors and more primitives. For example, I would personally build the cage out of a lot of box impostors that circulate around the mesh. This way some of them will sleep, while the other collide. It won’t be a perfect circle, but will offer much better performance. Of course they should be invisible and only used for collision.
Same goes to the upper pipes - build 4 “walls” around them, but set to to be invisible. The user won’t notice that, if configured correctly.
And using those two “hacks” you managed to avoid 3 mesh impostors.
You are right, I reduced the window size and the FPS has become 60. Thanks
I thought about it, but did not know how to implement it. Good tip, you’re so helpful