Skip to content

Commit b61142f

Browse files
authored
CCDIKSolver: Fix limitation handling. (#33386)
1 parent f9557c4 commit b61142f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

examples/jsm/animation/CCDIKSolver.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ class CCDIKSolver {
204204

205205
if ( c > 1.0 ) c = 1.0;
206206

207-
const c2 = math.sqrt( 1 - c * c );
207+
// preserve sign of the rotation along the limitation axis,
208+
// otherwise negative rotations get mirrored to positive
209+
const dot = link.quaternion.x * limitation.x + link.quaternion.y * limitation.y + link.quaternion.z * limitation.z;
210+
const sign = dot < 0 ? - 1 : 1;
211+
const c2 = sign * math.sqrt( 1 - c * c );
208212
link.quaternion.set( limitation.x * c2,
209213
limitation.y * c2,
210214
limitation.z * c2,

0 commit comments

Comments
 (0)