ragdoll.d.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import type { Skeleton } from "../../Bones/skeleton";
  2. import { Vector3 } from "../../Maths/math.vector";
  3. import { PhysicsAggregate } from "./physicsAggregate";
  4. import type { Mesh } from "../../Meshes/mesh";
  5. import { TransformNode } from "../../Meshes/transformNode";
  6. /**
  7. * Ragdoll bone properties
  8. * @experimental
  9. */
  10. export declare class RagdollBoneProperties {
  11. /**
  12. * Width of the box shape
  13. */
  14. width?: number;
  15. /**
  16. * depth of the box shape
  17. */
  18. depth?: number;
  19. /**
  20. * height of the box shape
  21. */
  22. height?: number;
  23. /**
  24. * size that will be used of width, depth and height of the shape box
  25. */
  26. size?: number;
  27. /**
  28. * Type of Physics Constraint used between bones
  29. */
  30. joint?: number | undefined;
  31. /**
  32. * Main rotation axis used by the constraint, in local space
  33. */
  34. rotationAxis?: Vector3;
  35. /**
  36. * Minimum rotation angle value
  37. */
  38. min?: number;
  39. /**
  40. * Maximum rotation angle value
  41. */
  42. max?: number;
  43. /**
  44. * Offset along local axis
  45. */
  46. boxOffset?: number;
  47. /**
  48. * Axis that need an offset
  49. */
  50. boneOffsetAxis?: Vector3;
  51. }
  52. /**
  53. * Ragdoll for Physics V2
  54. * @experimental
  55. */
  56. export declare class Ragdoll {
  57. private _skeleton;
  58. private _scene;
  59. private _rootTransformNode;
  60. private _config;
  61. private _boxConfigs;
  62. private _joints;
  63. private _bones;
  64. private _initialRotation;
  65. private _initialRotation2;
  66. private _boneNames;
  67. private _transforms;
  68. private _aggregates;
  69. private _ragdollMode;
  70. private _rootBoneName;
  71. private _rootBoneIndex;
  72. private _mass;
  73. private _restitution;
  74. /**
  75. * Pause synchronization between physics and bone position/orientation
  76. */
  77. pauseSync: boolean;
  78. private _putBoxesInBoneCenter;
  79. private _defaultJoint;
  80. private _defaultJointMin;
  81. private _defaultJointMax;
  82. /**
  83. * Construct a new Ragdoll object. Once ready, it can be made dynamic by calling `Ragdoll` method
  84. * @param skeleton The skeleton containing bones to be physicalized
  85. * @param rootTransformNode The mesh or its transform used by the skeleton
  86. * @param config an array of `RagdollBoneProperties` corresponding to bones and their properties used to instanciate physics bodies
  87. */
  88. constructor(skeleton: Skeleton, rootTransformNode: Mesh | TransformNode, config: RagdollBoneProperties[]);
  89. /**
  90. * Returns the aggregate corresponding to the ragdoll bone index
  91. * @param index ragdoll bone aggregate index
  92. * @returns the aggregate for the bone index for the root aggregate if index is invalid
  93. */
  94. getAggregate(index: number): PhysicsAggregate;
  95. private _createColliders;
  96. private _initJoints;
  97. private _syncBonesToPhysics;
  98. private _setBoneOrientationToBody;
  99. private _syncBonesAndBoxes;
  100. private _setBodyOrientationToBone;
  101. private _defineRootBone;
  102. private _findNearestParent;
  103. private _init;
  104. /**
  105. * Enable ragdoll mode. Create physics objects and make them dynamic.
  106. */
  107. ragdoll(): void;
  108. /**
  109. * Dispose resources and remove physics objects
  110. */
  111. dispose(): void;
  112. }