-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obj/Collada models fall through with dynamic/static-body #41
Comments
Alright, two issues – The first is general trimesh support, mentioned in schteppe/cannon.js#231 and schteppe/cannon.js#191. In summary, collisions on a trimesh are not as fully supported as other shapes. I've got a demo working that uses a trimesh as the ground, and the player (a sphere) can sort of walk across it, buggily, but cubes can't collide with a trimesh yet. Similarly, the (trimesh) manatee will fall through the (cube-ish) floor. My ideas are:
I can add 1 pretty soon. 2-4 are more difficult, so no promises on timeline there. PRs welcome! /cc @bnolan and @h0r0man, since we've discussed issues with trimesh collision a bit. EDIT –CANNON.js gives much more detail into support for various shapes in the collision matrix. |
Second issue, that mountain mesh is pretty complex to just throw at a JS physics engine. Here's the wireframe coming out of it all: Clearly that's not, eh, working quite as expected. Maybe best not to have the whole scene in one big model – much easier for the physics engine if each tree can just be modeled as a box, and terrain as a heightmap, than one massive mesh. So 1-4 above will give you some options to work with, but it won't be able to magically physics-ify any arbitrary model, I don't think. |
maybe I'm way off here but maybe you could ortho render the terrain from above at low resolution and take it's depth as the heightmap |
@wizgrav yeah, sounds feasible but a bit painful. raycasting at some sampling ratio would work too, but slower. 😐 |
Well here's a start on (1), in v1.13.0. Not documented yet because various bugs, but – <a-entity obj-model="obj: url(...)" dynamic-body="shape: box"></a-entity> Which will ignore the actual shape of the mesh and just put a box around it. You can see the bounding box by adding Also, CANNON.js gives quite a bit more detail into what's supported in its collision matrix. |
@donmccurdy yeah raycasting is much more practical and the overhead is not necessarily prohibitive, maybe an octree could be generated to speed up the process and could also be useful for generic intersection testing later. |
@donmccurdy Hi, the I’m trying to use simple ground Here’s a html: <!-- aframe v0.2.0 & aframe-extras v1.14.0 -->
<a-scene physics="debug:true">
<a-entity
id="player"
camera
universal-controls
kinematic-body="enableSlopes: false"
position="0 4 2"></a-entity>
<a-entity
id="scene"
static-body
obj-model="obj: url(object/ground.obj); mtl: url(object/ground.mtl);"></a-entity>
</a-scene> |
Oh nice documentation on that! Thanks. |
@donmccurdy After v1.13.0 if use collada-model it’s basically freezes the browser! <a-entity collada-model="url(/path/to/tree.dae)"></a-entity> |
|
@donmccurdy Here’s a simple pen, just try to remove an HTML comment to use your library. |
Great thanks. Hoping I can get to this tomorrow, the most likely issue is mesh -> physics body conversion. There's a case where it can enter an infinite loop. |
Some progress in 9df3943 (not released yet). I think the main issue with that Collada model is solved, but there's an issue that causes the physics body to not scale to match the model. Still working on that. |
@h0r0man ah yeah, no I just fixed the collada freezing issue so far. using an arbitrary mesh as ground is likely to have issues for a while, not least because lots of shapes can't collide with a trimesh in cannonjs (or oimojs for that matter). i'd like to focus on roomscale tbh. i think next on my list though is (3) above, to let you define compound shapes around a model using multiple cubes/cylinders. that way even if your model isn't supported you can at least put a custom frame around it (e.g. to pick it up or toss it around) |
Added |
Moving this discussion over to n5ro/aframe-physics-system#9, and I've added a brief summary there. |
Test at http://anj.fyi/mountains
The manatee falls through the floor, and the mountain mesh isn't walkable.
Link to models:
http://anj.fyi/images/manatee.obj
http://anj.fyi/images/mountains.dae
The text was updated successfully, but these errors were encountered: