Comments (8)
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.
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.
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.
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.
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.
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.
Great, thanks, I'll give something like that a shot!
from physijs.
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)
- Collision Event not firing HOT 2
- Refused to execute script (from xyz) because its MIME type ('text/js') is not executable. HOT 1
- How to deform an Physijs.SphereMesh like a WaterDrop?
- PhysijsWorker is not a constructor HOT 2
- How to move blocks out of blocks faster HOT 1
- how to load GLTF model ? HOT 2
- No updates for years, any recommendations for an alternative lib? HOT 3
- THREE.InstancedMesh is not supported
- How do I get the number of layers and roots with a mouse click HOT 1
- Objects after coming to rest are stuck in that state.
- Scenegraph Skipping collision checks - possible issue or me being silly
- How to check for an overlap event
- applyImpulse to object: vector: NaN ? HOT 1
- Use physijs to give three.js Questions about adding physical effects?
- When I used concavemesh to transform the externally introduced obj model, the browser reported an error
- Uncaught TypeError: class constructors must be invoked with 'new' when trying to create Physijs Scene HOT 3
- Vehicle physics HOT 1
- How to use it in vue-cli3?
- Döner alike fractal terrain rolled up
- Physi
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from physijs.