Giter Site home page Giter Site logo

Comments (8)

chandlerprall avatar chandlerprall commented on July 18, 2024

There is currently no caching for custom shapes such as ConvexMesh. However, in your case you should be able to use a BoxMesh which will envelope each die. This will result in much faster loading and processing times, and will be cached / reused.

from physijs.

rileydutton avatar rileydutton commented on July 18, 2024

The die are actually polyhedral, not cubes, so the BoxMesh won't work, right?

Is this something that I could figure out if I poke around the code enough, or am I just stuck?

from physijs.

chandlerprall avatar chandlerprall commented on July 18, 2024

The box mesh just uses the geometry's bounding box properties. None of the meshes are directly tied to any of Three's geometries.

EDIT: Sorry, just realized that by polyhedral you mean they are not 6-sided dice, now I'm rethinking :)

from physijs.

chandlerprall avatar chandlerprall commented on July 18, 2024

2,000 vertices is a huge amount - is it possible to get the basic shape of the dice with a lower vertex count? You could then use that shape as the physics body and attach your high-poly model as a child.

I am also thinking about how to cache any of the custom shapes which would help the generation time, though simulation performance will still be impacted by the high vertex count.

from physijs.

rileydutton avatar rileydutton commented on July 18, 2024

Is there an example of using a high-poly model attached to a low-poly physics object? Sorry, I'm really new to all this 3D stuff :-)

I did figure out how to cache the object in physijs_worker using the same method that the BoxMesh was using. As you've said, simulation time isn't going to be great (which is why the low-poly one is a good idea), but at least this way it load quickly.

from physijs.

chandlerprall avatar chandlerprall commented on July 18, 2024

Something like this should work for the low-poly physics version

var material_hidden = new THREE.MeshBasicMaterial(),
     real_material = ...your dice material...;
material_hidden.visible = false;

var dice = new THREE.Mesh( high_poly_mesh, real_material );
var lowPoly = new Physijs.ConvexMesh( low_poly_mesh, material_hidden );
lowPoly.add( dice );
scene.add( lowPoly );

from physijs.

rileydutton avatar rileydutton commented on July 18, 2024

Great, thanks, I'll give something like that a shot!

from physijs.

ThatsAMorais avatar ThatsAMorais commented on July 18, 2024

Hi. I enabled the caching for hulls and did what you suggested with adding the high poly mesh to the low poly version, but it seems that caching lowPoly is retaining the children as well. The solution itself works extremely well, otherwise.

So, as you create more objects if you aren't careful and readding dice to low_poly on repeated loads you will have lots of copies of dice in each subsequent load of lowPoly. I don't want to spend anyone's time asking for a solution, but I wanted to point out a hazard in doing this.

from physijs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.