saharan / OimoPhysics

A cross-platform 3D physics engine
MIT License
863 stars 68 forks source link

Shapeの座標をずらしたらおかしい #27

Closed takeru closed 4 years ago

takeru commented 4 years ago

https://jsfiddle.net/ssktkr/qmsctw51/

If you move the coordinates of the shape from the center of RigidBody and add it, it will move like a pendulum. Is it being used incorrectly?

Shapeの座標をRigidBodyの中心からずらしてaddすると振り子のような動きになってしまいます。 使い方が間違っていますか?

saharan commented 4 years ago

As the position of a RigidBody represents the center of gravity of the rigid body, and the position of a Shape (ShapeConfig.position in the code) represents the (local) relative position to the rigid body's center of gravity, it is an expected behavior that the rigid body moves like a pendulum. If you want to place the shape at the center of gravity of the rigid body, please adjust the rigid body's position instead of the shape's position.

RigidBodyの中心は剛体の重心で、Shapeの座標はRigidBodyの重心からのずれを表すので、振り子のような動きをするのは想定された動作です。Shapeを重心に置きたい場合は、Shapeの座標の代わりにRigidBodyの座標を調節してください。

saharan commented 4 years ago

Although it's an expected behavior, it's favorable to automatically update the center of gravity. This will be handled in #28.

重心がずれるのは想定された動作ですが、自動で重心を計算できる方が好ましいので、将来的に重心とRigidBodyの原点を分けて扱い、重心の座標を自動計算できるようにしようと思います(#28)。

takeru commented 4 years ago

https://twitter.com/shr_em/status/1249245606972772352 https://jsfiddle.net/ssktkr/w560mbfx/ 今のバージョン(1.2.0)のままでなんとかするサンプルです。たぶんなんとかなってるとおもいます。