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

Cannon example doesn't descriptive enough #6

Closed
tynrare opened this issue Apr 6, 2020 · 2 comments
Closed

Cannon example doesn't descriptive enough #6

tynrare opened this issue Apr 6, 2020 · 2 comments

Comments

@tynrare
Copy link

tynrare commented Apr 6, 2020

Hi.

I experienced few problems when tried to use cannon by example and think it (example) should be extended:

  1. Cannon and Hilo worlds works in different axes: Cannon uses Z as vertical, Hilo Y. It isn't issue itself since you can just set gravity in any direction, but for some bodies like planes it is problem. All ground bodies has to be rotated:
world.gravity.set(0, GRAVITY, 0); //Hilo's gravity direction
const groundBody = new cannon.Body({
		mass: 0, // mass == 0 makes the body static
		quaternion: new cannon.Quaternion(0, 0, 0).setFromEuler(-Math.PI / 2, 0, 0) //hilo's ground rotation
	});

Also i think it would be better to let cannon work in Z direction as it was, but then we need to swap axes like hilomesh.setPosition(this.body.position.x, this.body.position.z, this.body.position.y); and rotation too.
2. Line geometry = new Hilo3d.BoxGeometry( 2, 2, 2 ); incorrect because BoxGeometry works with object argument, const geometry = new Hilo3d.BoxGeometry({ width: 2, height: 2, depth: 2 });
3. It doesn't clear from example that Hilo's bodies (Boxes) has to be twice bigger than cannon's

const geometry = new Hilo3d.BoxGeometry({ width: 2, height: 2, depth: 2 }); 
const shape = new cannon.Box(new cannon.Vec3(1, 1, 1)); //does it because cannon sets distance *from center*?

I don't sure is it problem exist only for boxes or whole cannon-hilo bind.

Thanks for your time!

@06wj
Copy link
Member

06wj commented Apr 13, 2020

Hi.
I updated the cannon demo: https://raw.githack.com/hiloteam/Hilo3d/dev/examples/physics/cannon.html

About your questions:

  1. It may be confusing to use two kinds of coordinates, I think it would be better to use hilo coordinate system.
  2. It is indeed incorrect, I fixed it.
  3. The parameter of the cannon box is the halfExtents. See http://schteppe.github.io/cannon.js/docs/classes/Box.html

@tynrare
Copy link
Author

tynrare commented Apr 15, 2020

@06wj thanks for response and your work. Nice example.

  1. Yep, and i think we already use two coordinate systems. Again, default rotation just wrong in cannon if we use it with hilo. It doesn't critical, but at least it deserves some comment note in example
  2. Yes, but still, "it doesn't clear" - i suggest add your comment about it in code

Please, check out this article - The Importance of “Why” Docs. One line of comment can save hours of work for someone.

@tynrare tynrare closed this as completed May 5, 2020
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

No branches or pull requests

2 participants