boneIKController.d.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import type { Bone } from "./bone";
  2. import { Vector3 } from "../Maths/math.vector";
  3. import type { TransformNode } from "../Meshes/transformNode";
  4. import type { Nullable } from "../types";
  5. /**
  6. * Class used to apply inverse kinematics to bones
  7. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/bonesSkeletons#boneikcontroller
  8. */
  9. export declare class BoneIKController {
  10. private static _TmpVecs;
  11. private static _TmpQuat;
  12. private static _TmpMats;
  13. /**
  14. * Gets or sets the target TransformNode
  15. * Name kept as mesh for back compatibility
  16. */
  17. targetMesh: TransformNode;
  18. /** Gets or sets the mesh used as pole */
  19. poleTargetMesh: TransformNode;
  20. /**
  21. * Gets or sets the bone used as pole
  22. */
  23. poleTargetBone: Nullable<Bone>;
  24. /**
  25. * Gets or sets the target position
  26. */
  27. targetPosition: Vector3;
  28. /**
  29. * Gets or sets the pole target position
  30. */
  31. poleTargetPosition: Vector3;
  32. /**
  33. * Gets or sets the pole target local offset
  34. */
  35. poleTargetLocalOffset: Vector3;
  36. /**
  37. * Gets or sets the pole angle
  38. */
  39. poleAngle: number;
  40. /**
  41. * Gets or sets the TransformNode associated with the controller
  42. * Name kept as mesh for back compatibility
  43. */
  44. mesh: TransformNode;
  45. /**
  46. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  47. */
  48. slerpAmount: number;
  49. private _bone1Quat;
  50. private _bone1Mat;
  51. private _bone2Ang;
  52. private _bone1;
  53. private _bone2;
  54. private _bone1Length;
  55. private _bone2Length;
  56. private _maxAngle;
  57. private _maxReach;
  58. private _rightHandedSystem;
  59. private _bendAxis;
  60. private _slerping;
  61. private _adjustRoll;
  62. private _notEnoughInformation;
  63. /**
  64. * Gets or sets maximum allowed angle
  65. */
  66. get maxAngle(): number;
  67. set maxAngle(value: number);
  68. /**
  69. * Creates a new BoneIKController
  70. * @param mesh defines the TransformNode to control
  71. * @param bone defines the bone to control. The bone needs to have a parent bone. It also needs to have a length greater than 0 or a children we can use to infer its length.
  72. * @param options defines options to set up the controller
  73. * @param options.targetMesh
  74. * @param options.poleTargetMesh
  75. * @param options.poleTargetBone
  76. * @param options.poleTargetLocalOffset
  77. * @param options.poleAngle
  78. * @param options.bendAxis
  79. * @param options.maxAngle
  80. * @param options.slerpAmount
  81. */
  82. constructor(mesh: TransformNode, bone: Bone, options?: {
  83. targetMesh?: TransformNode;
  84. poleTargetMesh?: TransformNode;
  85. poleTargetBone?: Bone;
  86. poleTargetLocalOffset?: Vector3;
  87. poleAngle?: number;
  88. bendAxis?: Vector3;
  89. maxAngle?: number;
  90. slerpAmount?: number;
  91. });
  92. private _setMaxAngle;
  93. /**
  94. * Force the controller to update the bones
  95. */
  96. update(): void;
  97. private _updateLinkedTransformRotation;
  98. }