jsantell / THREE.IK

inverse kinematics for three.js
https://jsantell.github.io/THREE.IK
MIT License
465 stars 54 forks source link

Additional constraints #3

Open jsantell opened 6 years ago

jsantell commented 6 years ago

Currently, only IKBallConstraint is implemented, limiting the joint in by X degrees from its origin state. The FABRIK paper describes ways to implement more complex constraints with irregular cone areas and hinge constraints, but a bit stumped on how to implement that.

bradley-newman commented 6 years ago

Pole Vector constraints are pretty common for constraining the rotation plane of elbows and knees, etc. https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/CSCo-Pole-Vector-constraints-htm.html

jsantell commented 6 years ago

Pole vectors would be great. Would that be a constraint type, or be its own solver? In other words, could it work with either CCD or FABRIK handling the solving, with the pole vector influencing the result? It's been awhile since I've used pole vector constraints in Maya, but this should work beyond a 3-joint shoulder-elbow-hand configuration, yeah?

bradley-newman commented 6 years ago

I've only used them as constraints. Don't honestly know enough about the details of the rest of the things you mentioned.

zalo commented 6 years ago

The naive way to implement "pole constraints"/attractors in FABRIK is to simply pull the joints toward the attractor a little bit before doing an IK solve. The joints preserve their "pulled" state even after the IK solve is run. The same thing can be done for a facsimile of gravity (where each joint is just offset downward a little bit every frame, in between solves).

CCDIK might do it by rotating all of the joints to face toward the attractor (well, in the direction of the base joint to the attractor) before doing a solve. The "pulled" state will still get preserved somewhat in CCDIK, but perhaps not as cleanly as it is in FABRIK.

sneha-belkhale commented 5 years ago

hey -- so I am using this library to procedurally animate a quadruped, and since the BallConstraint isn't really suitable for limb joints, I started to add a HingeConstraint.

Seems like it's working so far, I can post more details later in a PR, but just wanted to let you know~