https://didisoftwares.ddns.net/12/index.html
Testing with the ammo.js physics library, I decided to apply physics to an entire city, including buildings, streets and houses.
And it works very well.
There is another way to apply physics to large or complex objects, which is BVH (Bounding Volume Hierarchy) :
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/physics.html
however, ammo.js is much more complete.
The biggest problem when working with ammo.js is that you must always destroy all variables that are no longer used. Either reuse them, or the memory will burst.
This is the final physics class: https://didisoftwares.ddns.net/12/js/physics.js
With the function I created, you can generate physics for any object with geometry with one line:
import IPHYSICS from "./physics.js"
const physics = new IPHYSICS();
const clock = new THREE.Clock();
await physics.create().then(() => {//wait physics world create
const geometry = new THREE.BoxGeometry(1, 1, 1);
const mesh = new THREE.Mesh(geometry, new THREE.MeshStandardMaterial());
await physics.createObj(mesh, 'geometry', 'wall', null, 0, null, { margin: 1.0 });
//options: 'wall' - static | 'tile' - ground | 'obj' - dinamic
});
and in update:
const delta = clock.getDelta();
physics.update(delta);
I just simplified the meshes and fixed some broken faces of the model