Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Objects fall through a simple collada plane/floor #9

Closed
7ammer opened this issue Dec 11, 2016 · 4 comments
Closed

Objects fall through a simple collada plane/floor #9

7ammer opened this issue Dec 11, 2016 · 4 comments

Comments

@7ammer
Copy link

7ammer commented Dec 11, 2016

I've noticed an issue where objects are falling through a simple Collada based floor/plane.

Here is the jsfiddle example:
https://jsfiddle.net/9z9e1jtk/

@donmccurdy
Copy link
Collaborator

Hi @7ammer — there's some more detail about this in c-frame/aframe-extras#41.

tl;dr — By default, your Collada model is turned into a CANNON.Trimesh shape. These are only partially supported by Cannon.js, have poor performance, and can only collide with Sphere and Plane shapes, as described in Cannon.js collision matrix.

In general cases, these are the options:

  1. Use a single static-body="shape:box" or static-body="shape:hull" shape, if your terrain can be treated as convex. Shape docs.
  2. Use some combination of invisible boxes and planes to model the terrain.
  3. Construct a shape programmatically using Cannon.js JavaScript APIs and add it to the A-Frame physics system.
  4. Use a CANNON.Heightfield shape. Doing this automatically is not yet implemented, and I'm tracking the feature in Support CANNON.Heightfield donmccurdy/three-to-cannon#1.

In your particular case, since this is just a very basic plane, I would normally use option (1).

<a-entity static-body="shape: box" collada-model="#ground"></a-entity>

Unfortunately there is a bug with fitting a box to an infinitely thin object, so that won't work right now. I'll try to fix that. In the meantime, you'll need to use option (2) instead:

<a-entity collada-model="#ground"></a-entity>
<a-plane static-body visible="false" height="100" width="100" rotation="-90 0 0"></a-plane>

@7ammer
Copy link
Author

7ammer commented Dec 12, 2016

Ah, I see! Thanks for letting me know.

Is .obj support in the same boat as .dae or is the support slightly better?

I tried static-body="shape:hull" on a different collada 3d model to the one in the jsfiddle above and it froze my browser. I also tried the same object written as an .obj file. This didn't freeze but I fell straight through the terrain.

Cheers

@donmccurdy
Copy link
Collaborator

I'd have expected OBJ or DAE to behave the same way, it should just depend on the geometry. I'm not sure why the hull option would have frozen, though.

@donmccurdy
Copy link
Collaborator

Bug related to infinitely-thin objects is now filed separately here: #45

I'm going to try to put together some info on how to use model(s) as your base scene for physics, soon, but that will require some preparation of the model in Blender... will never be as simple as dropping in an arbitrary model and putting static-body on it unfortunately.

Closing this issue in the meantime.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants