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

Align Cannon cylinder orientation with Three's cylinder #13

Closed
codynova opened this issue Apr 2, 2020 · 7 comments · Fixed by #30
Closed

Align Cannon cylinder orientation with Three's cylinder #13

codynova opened this issue Apr 2, 2020 · 7 comments · Fixed by #30
Assignees
Labels
enhancement New feature or request

Comments

@codynova
Copy link
Member

codynova commented Apr 2, 2020

This issue is readily apparent when using a wireframe debugger for the physics bodies.

We may want to allow specifying the axis orientation in the cylinder constructor - since the most popular way to construct capsule physics bodies is with cylinder+sphere compound bodies, and the most popular capsule geometry primitives are aligned with the Cannon cylinder's current orientation (i.e. not aligned with Three's cylinder)

pmndrs/use-cannon#58

schteppe#58

(cool (or uncool?) coincidence that it's issue 58 in both repos...)

@codynova codynova added the enhancement New feature or request label Apr 3, 2020
@codynova codynova self-assigned this Apr 21, 2020
@sunwin123
Copy link

sunwin123 commented Apr 23, 2020

Hey @codynova , you may have a look at this issue Cylinder cannon.js vs cylinder three.js #58 #issuecomment-618207128.
It is a way to solve the problem, I've tested, it works very well.

@codynova
Copy link
Member Author

@sunwin123 Thank you for taking a look. For performance reasons, rather than create the shape and then rotate, we should construct the geometry in the correct axes to start with.

@sunwin123
Copy link

@codynova Agree, if there’s a way to create the geometry with correct rotations, it would be nice. But do they have such APIs ?

@codynova
Copy link
Member Author

The geometry vertices and faces are mathematically generated here. I haven't looked into it enough yet, but there should be a straightforward way to alter that class to get the desired result during geometry generation.

@sunwin123
Copy link

I've read the code, it hasn't parameters to alter transformations in geometry creation periods.

@ianpurvis
Copy link

@codynova @sunwin123 Hi guys. I gave this a try... what do you think of the approach in #28 ? Let me know if there is a better way to write the Typescript.

@codynova
Copy link
Member Author

codynova commented Jun 9, 2020

Hey @ianpurvis, sorry for the delayed response, I've been super busy lately - thanks for taking a look! I agree with Marco that I'd rather this not be configurable, although I can see why you thought that was my goal due to my comment about performance.

My concern was generating the geometry in the incorrect axes, then transforming to align with ThreeJS. Instead we want to construct the geometry in the correct axes according to ThreeJS alignment, then allow other transforms at runtime. There is also the option to use ConvexPolyhedron.

I'm closing #28 in favor of #30 and have released the updated Cylinder class in cannon-es@0.10.0. I've also updated and released use-cannon@0.4.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants