final short parentIndex = joints[jointIndex].getParentIndex();
// neckBindGlobalTransform is the neck bone -> model space transform. essentially, it is the world transform of
// the neck bone in bind pose.
final ReadOnlyTransform inverseNeckBindGlobalTransform = joints[jointIndex].getInverseBindPose();
final ReadOnlyTransform neckBindGlobalTransform = inverseNeckBindGlobalTransform.invert(calcTrans1);
// Get a vector representing forward direction in neck space, use inverse to take from world -> neck space.
forwardDirection.set(bindPoseDirection);
inverseNeckBindGlobalTransform.applyForwardVector(forwardDirection, forwardDirection);
// Get a vector representing a direction to the camera in neck space.
targetPos.subtract(globalTransforms[jointIndex].getTranslation(), cameraDirection);
cameraDirection.normalizeLocal();
inverseNeckBindGlobalTransform.applyForwardVector(cameraDirection, cameraDirection);
// Calculate a rotation to go from one direction to the other and set that rotation on a blank transform.
calcQuat1.fromVectorToVector(forwardDirection, cameraDirection);
calcQuat1.slerpLocal(Quaternion.IDENTITY, calcQuat1, targetStrength);
final Transform subTransform = calcTrans2.setIdentity();
subTransform.setRotation(calcQuat1);
// Calculate a global version of that transform, as if it were attached to the neck
final Transform subGlobal = neckBindGlobalTransform.multiply(subTransform, calcTrans3);
// now remove the global/world transform of the neck's parent bone, leaving us with just the local transform of
// neck + rotation.
final Transform local = joints[parentIndex].getInverseBindPose().multiply(subGlobal, calcTrans2);