chandlerprall / Physijs

Physics plugin for Three.js
MIT License
2.77k stars 455 forks source link

No updates for years, any recommendations for an alternative lib? #319

Open foxnoodles opened 4 years ago

foxnoodles commented 4 years ago

The title is pretty much self-explanatory. As much as I'd love to use this in a commercial product it's way too old and unmaintained to be trusted. Not trying to trash on anyone, I know how hard it is to maintain an open-source project.

I was wondering if there are any similar alternatives to Physijs which are well maintained?

ghost commented 4 years ago

Off the top of my head, the only thing which has a Physijs-like integration is Whitestorm.js, but it's more of a complete framework rather than just being a small plugin. It is based on three.js though, so it might be what you're looking for. Although I haven't seen much activity, it should still work.

That aside, the only alternative at this point is to roll out your own Physijs interface for your project which calls some JavaScript physics engine, such as ammo.js (lots of features included, even has softbodies), cannon.js (small size) or Oimo.js (fairly fast). You could even take this repo's code as a starting point, as I'm pretty sure the worker code will work without many modifications, if any.

foxnoodles commented 4 years ago

I'm aiming to use React Native Desktop (Windows an MacOS forks) as a base an use a webview to interact with 3D objects(I don't know if there's any other way to it besides cramping in the Unity view which is too hacky afaik and has licensing problems) Something like a native openGL view would be nice but I have no idea how's that done.

So basically I'll have to write my own wrapper around the physics engine of choice? That sounds terrifying :D

ghost commented 4 years ago

Actually, seeing this use case makes me think that writing your own wrapper will most likely save you time in the long run since Physijs was not really intended to be run inside a React application in the first place (it probably would work if you embedded it inside the webview with your three.js code for your 3D objects - I really don’t know, never used React nor React Native before).

Also, I’m pretty sure that you’ll need your own wrapper anyways if you go with an OpenGL view / Unity view since Physijs is JavaScript and in that case your rendering framework is native code, right?

The wrapper doesn’t have to be as complicated as the one for Physijs though - all you need to do is create a “physics model” replica for each 3D object, then sync position / rotation / etc with your 3D objects in your render loop.