I’ll just leave the sub-class here.
export class BoneIKController extends BABYLON.BoneIKController {
/**
* A switch indicating that the rotation from the target mesh also be used to rotate
* any child bones of the IK bone.
*/
private _childRotationBone : Bone;
constructor(mesh: BABYLON.TransformNode,
bone: Bone,
options?: {
targetMesh?: BABYLON.TransformNode, // this does not have to be a mesh; named like for back compatability
poleTargetMesh?: BABYLON.TransformNode,
poleTargetBone?: Bone,
poleTargetLocalOffset?: BABYLON.Vector3,
poleAngle?: number,
bendAxis?: BABYLON.Vector3,
maxAngle?: number,
slerpAmount?: number,
childRotationBone?: Bone // additional option added
}) {
super(mesh, bone, options);
if (options && options.childRotationBone) {
this._childRotationBone = options.childRotationBone
}
}
public update() : void {
super.update();
if (this._childRotationBone) this._childRotationBone.setRotation(this.targetMesh.rotation);
}
}
It is very simple:
- Add an option
childRotationBone
- Add a line in constructor to assign a private property if the option was used
- Execute a line in update if the private property was found.