Skip to content
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

Enable static-body on ground with a Heightfield shape (wip) #24

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vincentfretin
Copy link
Contributor

@vincentfretin vincentfretin commented Oct 9, 2017

I create the PR so you folks know I'm working on that. I'll probably continue this work in two weeks.

I want my cubes and spheres to rest on the ground, not go through it!
I first tested this.ground.setAttribute('static-body', 'shape', 'hull'); that create a CANNON.ConvexPolyhedron shape, but I had really poor performance on GearVR, lots of frame drop.

While reading some old https://github.com/donmccurdy/aframe-physics-system issues, I stopped at c-frame/aframe-extras#41 and donmccurdy/three-to-cannon#1 where it gave me the idea to try that.
I successfully created a CANNON.Heightfield shape for the generated ground, and it is working great!
I don't have any slowdown with this on GearVR.

I'm sure there are issues with updating the properties of the schema, so please don't merge.
If you want to play with it, please do! ;-)

Here is screenshot with <a-scene physics="debug:true">
capture d ecran de 2017-10-09 20-37-10

@vincentfretin
Copy link
Contributor Author

As I said on donmccurdy/three-to-cannon#1 I'll probably move the heightfield creation to three-to-cannon and add an option to the environment component to enable the heightfield creation, disabled by default. And be sure that I don't broke something when a property of the environment component schema changes.

@arpu
Copy link

arpu commented Dec 23, 2017

@vincentfretin any news on this? works fantastic

@vincentfretin
Copy link
Contributor Author

@arpu I didn't do anything on this front yet. I still have to do the work I described.

@illifly
Copy link

illifly commented Aug 17, 2018

@vincentfretin Great idea, but i dont get this to work!
I have aframe-environment-component.js and aframe-physics-system.min.js installed on aframe 0.7.0 as well as 0.8.0/0.8.2.
I made your changes on aframe-environment-component.js, check it with console but it takes no effect, i can go through the ground or e.g. pyramids. I also dont see the grid as in your screenshot.
Please, can you help me or show a working example or maybe is there a better solution?
My Code:

<html>
  <head>
    <script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
    <script src="https://www.beverung.de/vr/ground/aframe-environment-component.js"></script>
    <script src="//cdn.rawgit.com/donmccurdy/aframe-physics-system/v3.2.0/dist/aframe-physics-system.min.js"></script>
  </head>
  <body>
<a-scene physics="debug: true">
	<a-entity environment="preset:egypt"></a-entity>
	<a-entity  dynamic-body camera look-controls wasd-controls position="0 1.6 0"></a-entity>
</a-scene>
  </body>
</html>

Thank you very much!

When i use physics 3.0.0 i can see the grid, but go still through all...

@vincentfretin
Copy link
Contributor Author

For the red wireframe, if I remember well, it only appears for me on firefox on desktop, not on chrome on desktop, not sure why.

@vincentfretin
Copy link
Contributor Author

You can look at my example https://github.com/vincentfretin/aframe-sandbox and compare with yours.

@netgfx
Copy link

netgfx commented Oct 29, 2020

Is this going to be merged at some point? It is really useful!

@vincentfretin
Copy link
Contributor Author

I don't plan to work on it myself for the time being. It was really a proof of concept for me back in October 2017, time flies :)
I know that the physics system switched from cannon to ammo, so if somebody works on this, they should use ammo now I think.
I know @arpu did similar thing in vrland.io, what tech did you use @arpu for your https://vrland.io/worldg/in map?

@arpu
Copy link

arpu commented Oct 29, 2020

i still use the typedscrypt port from cannon https://github.com/pmndrs/cannon-es with the CANNON.Heightfield generated from a heighmap image and https://github.com/mapbox/martini

@vincentfretin vincentfretin marked this pull request as draft June 15, 2023 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants