physicsAggregate.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import { PhysicsBody } from "./physicsBody";
  2. import type { PhysicsMaterial } from "./physicsMaterial";
  3. import { PhysicsShape } from "./physicsShape";
  4. import type { Scene } from "../../scene";
  5. import type { TransformNode } from "../../Meshes/transformNode";
  6. import { Quaternion, Vector3 } from "../../Maths/math.vector";
  7. import { PhysicsShapeType } from "./IPhysicsEnginePlugin";
  8. import type { Mesh } from "../../Meshes/mesh";
  9. /**
  10. * The interface for the physics aggregate parameters
  11. */
  12. export interface PhysicsAggregateParameters {
  13. /**
  14. * The mass of the physics aggregate
  15. */
  16. mass: number;
  17. /**
  18. * The friction of the physics aggregate
  19. */
  20. friction?: number;
  21. /**
  22. * The coefficient of restitution of the physics aggregate
  23. */
  24. restitution?: number;
  25. /**
  26. * Radius for sphere, cylinder and capsule
  27. */
  28. radius?: number;
  29. /**
  30. * Starting point for cylinder/capsule
  31. */
  32. pointA?: Vector3;
  33. /**
  34. * Ending point for cylinder/capsule
  35. */
  36. pointB?: Vector3;
  37. /**
  38. * Extents for box
  39. */
  40. extents?: Vector3;
  41. /**
  42. * Orientation for box
  43. */
  44. rotation?: Quaternion;
  45. /**
  46. * mesh local center
  47. */
  48. center?: Vector3;
  49. /**
  50. * mesh object. Used for mesh and convex hull aggregates.
  51. */
  52. mesh?: Mesh;
  53. /**
  54. * Physics engine will try to make this body sleeping and not active
  55. */
  56. startAsleep?: boolean;
  57. /**
  58. * If true, mark the created shape as a trigger shape
  59. */
  60. isTriggerShape?: boolean;
  61. }
  62. /**
  63. * Helper class to create and interact with a PhysicsAggregate.
  64. * This is a transition object that works like Physics Plugin V1 Impostors.
  65. * This helper instanciate all mandatory physics objects to get a body/shape and material.
  66. * It's less efficient that handling body and shapes independently but for prototyping or
  67. * a small numbers of physics objects, it's good enough.
  68. */
  69. export declare class PhysicsAggregate {
  70. /**
  71. * The physics-enabled object used as the physics aggregate
  72. */
  73. transformNode: TransformNode;
  74. /**
  75. * The type of the physics aggregate
  76. */
  77. type: PhysicsShapeType | PhysicsShape;
  78. private _options;
  79. private _scene?;
  80. /**
  81. * The body that is associated with this aggregate
  82. */
  83. body: PhysicsBody;
  84. /**
  85. * The shape that is associated with this aggregate
  86. */
  87. shape: PhysicsShape;
  88. /**
  89. * The material that is associated with this aggregate
  90. */
  91. material: PhysicsMaterial;
  92. private _disposeShapeWhenDisposed;
  93. private _nodeDisposeObserver;
  94. constructor(
  95. /**
  96. * The physics-enabled object used as the physics aggregate
  97. */
  98. transformNode: TransformNode,
  99. /**
  100. * The type of the physics aggregate
  101. */
  102. type: PhysicsShapeType | PhysicsShape, _options?: PhysicsAggregateParameters, _scene?: Scene | undefined);
  103. private _getObjectBoundingBox;
  104. private _hasVertices;
  105. private _addSizeOptions;
  106. /**
  107. * Releases the body, shape and material
  108. */
  109. dispose(): void;
  110. }