1

I'm trying to find a way to improve performance of my card game on mobile devices (wrapped with Cordova).

The script detect if WebGL is available and fallback to Canvas 2d if it's not supported. But I get a low 5-10fps on my Samsung Galaxy S4.

Is it possible to turn off Physijs? If not, how can I rewrite Physijs functions to only return ThreeJS objects instead of Physijs objects? Exmeple:

if(disablePhysics) {
        Physijs.createMaterial(elem,v1,v2) {
            return elem;
        }
    }

your help, as always, is valuable, thank you :)

Jeremy Dicaire
  • 4,615
  • 8
  • 38
  • 62

1 Answers1

0

If you want to disable the Physijs physics simulation on your webpage, then all you need to do is not call the scene.simulate() method in your rendering loop:

function render(){
    if(!disablePhysics){
        scene.simulate();
    }

    renderer.render();
}

It is safe to create Physijs objects and not run any simulations on them. They inherit from THREE's Object3D and its children, so it should be more or less the same without Physijs alternatives. It's just that every scene has an associated worker, and it would be kind of useless having a thread simply sitting there. The solution is actually easy: create a new THREE.Scene and transfer all your Physijs.Mesh objects to it.

Conclusion

So, when disabling physics:

  • Don't call scene.simulate()
  • Just fill your Physijs scene normally
  • You can transfer all your Physijs.Mesh objects to a THREE.Scene instead of keeping them in a Physijs.Scene
Community
  • 1
  • 1