cannon-es is just a physics library, it’s not related to react. the demo i linked is plain vanilla threejs. in principle it’s the same thing, you register a threejs mesh as a physics object and cannon takes care of controlling it afterwards. vanilla is more complex and takes a lot more code, so making sense of these demos will be a bit harder but they contain everything you need.
I presume you want to move each monkey head independently using the mouse.
Here is another example that uses the drag controls with cannonjs.
Also, note that you are using quite an old version of my boilerplate so I’ve recreated a similar example to what you forked that uses a newer version of threejs, webpack, and cannon-es.
Also note that ConvexPolyhedrons are CPU intensive and never work vey well if you want performant collisions. Instead you will get better performance if you manually create a collision shape from simple primitives such as CANNON.sphere’s. My version linked above uses a compound shape of spheres.
This means that many more monkeys can be loaded into the scene.
I estimated using blender. Note how each sphere shape I added to the main monkeyBody has a size, and a position.
For your model, its much simpler. I got something quite close by using trial and error
@seanwasere Hey Mr , sorry if i asking a lot but there is some thing i stuck on it. as i mentioned before i try to make a gltf model move with mouse with physics animation and i get your example as a reference but there is a strange behave happen here
why the performance was very bad ?
is there some thing wrong , i think i work in right way
sorry if i asking a lot but there is some thing i stuck on it. as i mentioned before i try to make a gltf model move with mouse with physics animation and i get your example as a reference but there is a strange behave happen here
why the performance was very bad ?
is there some thing wrong , i think i work in right way
you’ve added intersects to the example I edited for you. My example allowed you to move the objects with your mouse. This worked and performance was ok.
working example : blue-waterfall-fsmhs - CodeSandbox
Now you’ve added some intersect logic in the animation loop, but you are applying it indiscriminately to all the objects in the scene and hoping that it will do what you want. Its as if you don’t really know what intersects actually does but hoping it reads your mind.
Try to recreate a new demo from scratch, containing one object only that does what you want. Delete everything in the code that you don’t need. Then try to achieve it using two objects, and then add more objects gradually until you have what you need. It seems you are editing my example without yet understanding what it was doing.