Generate Custom Mesh Collider dynamically + options for Rigid body

It’s a simple OBJLoader that I use, like it :

loader = new OBJLoader();


    loadObj (url) {
        return new Promise((resolve) => {
          function onLoad(geo) {
            // geo.computeVertexNormals();
            
            // return the obj when it's loaded
            resolve(geo.children[0]);
          }
          this.loader.load(url, onLoad, onProgressCallback, onError);
        });
        
        function onProgressCallback() {}
        function onError() {
          console.log("cannot load obj files");
        }
      };```

*by user 224464722878005248*

by user 224464722878005248

Same problem with a random .obj url

by user 224464722878005248

Here the code if you wanna try :

by user 224464722878005248

addCollider.ts

by user 224464722878005248

Thank you, i can reproduce it on my end.

In the mean time, can you simplify it on your end and use the Box colliders for example?

or capsules

Not really, the teeth can generate collision from anywhere by any movement and box or capsule could not repoduce that :confused:

by user 224464722878005248

gotcha, ok

Hazaaa :tada:

So, the issue is that the OBJ file and the OBJ Loader always load the mesh in an unindexed state. Rapier requires that the mesh has verticies and indices.

Our implementation doesn’t check if the mesh has that apparently :+1: will create an issue for that. Probably it is not common when working with GTLF and FBX and so on.

A quick fix, is to generate the indices manually.


Test.ts

Oooh

by user 224464722878005248

Okay it seems to work but it destroy my performances ^^’

by user 224464722878005248

Like, on start? Or overall low fps?

low fps

by user 224464722878005248

Hm :confused:

You can simplify the shape by enabling the convex bool.
collider.convex = true;

Better

by user 224464722878005248

That creates a simpler shape to compute, you will loose a bit of the shape, but in the case of the teeth, it could work.

What is your target platform? PC, Mobile, VR?

Pc

by user 224464722878005248