chandlerprall / Physijs

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

Level of Detail #254

Open ashconnell opened 8 years ago

ashconnell commented 8 years ago

Is it possible to create a physijs object that also switches LOD as in http://threejs.org/docs/#Reference/Objects/LOD ?

Rialgar commented 8 years ago

I don't think it would be possible out of the box, you would need to add a _physijs object to the LOD manually, so physijs moves the whole LOD and not the individual meshes. However, that might clash with the implementation of compound objects being created from child objects in physijs. I don't know if the 2.0 rewrite will support physics on arbitrary objects out of the box.

ghost commented 8 years ago

This is just out of my head, but it might be possible to do it by checking the LOD level objects to see which one is visible based on the camera distance with .getObjectForDistance(). If the mesh changed, you are going to have to reconstruct it (same position, rotation, velocity, etc.) with a less greater level of detail. Remember, the only mesh that could help with detail would be the Physijs.ConvexMesh object (for dynamic objects). You are going to have to store a few instances of the object, just like LOD.