joinedPhysicsEngineComponent.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import type { Nullable } from "../types";
  2. import { Observable } from "../Misc/observable";
  3. import type { Vector3 } from "../Maths/math.vector";
  4. import type { ISceneComponent } from "../sceneComponent";
  5. import { Scene } from "../scene";
  6. import type { IPhysicsEngine } from "./IPhysicsEngine";
  7. import type { IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from "./v1/IPhysicsEnginePlugin";
  8. import type { IPhysicsEnginePluginV2 } from "./v2/IPhysicsEnginePlugin";
  9. declare module "../scene" {
  10. /**
  11. *
  12. */
  13. interface Scene {
  14. /** @internal (Backing field) */
  15. _physicsEngine: Nullable<IPhysicsEngine>;
  16. /** @internal */
  17. _physicsTimeAccumulator: number;
  18. /**
  19. * Gets the current physics engine
  20. * @returns a IPhysicsEngine or null if none attached
  21. */
  22. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  23. /**
  24. * Enables physics to the current scene
  25. * @param gravity defines the scene's gravity for the physics engine. defaults to real earth gravity : (0, -9.81, 0)
  26. * @param plugin defines the physics engine to be used. defaults to CannonJS.
  27. * @returns a boolean indicating if the physics engine was initialized
  28. */
  29. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2): boolean;
  30. /**
  31. * Disables and disposes the physics engine associated with the scene
  32. */
  33. disablePhysicsEngine(): void;
  34. /**
  35. * Gets a boolean indicating if there is an active physics engine
  36. * @returns a boolean indicating if there is an active physics engine
  37. */
  38. isPhysicsEnabled(): boolean;
  39. /**
  40. * Deletes a physics compound impostor
  41. * @param compound defines the compound to delete
  42. */
  43. deleteCompoundImpostor(compound: any): void;
  44. /**
  45. * An event triggered when physic simulation is about to be run
  46. */
  47. onBeforePhysicsObservable: Observable<Scene>;
  48. /**
  49. * An event triggered when physic simulation has been done
  50. */
  51. onAfterPhysicsObservable: Observable<Scene>;
  52. }
  53. }
  54. /**
  55. * Defines the physics engine scene component responsible to manage a physics engine
  56. */
  57. export declare class PhysicsEngineSceneComponent implements ISceneComponent {
  58. /**
  59. * The component name helpful to identify the component in the list of scene components.
  60. */
  61. readonly name = "PhysicsEngine";
  62. /**
  63. * The scene the component belongs to.
  64. */
  65. scene: Scene;
  66. /**
  67. * Creates a new instance of the component for the given scene
  68. * @param scene Defines the scene to register the component in
  69. */
  70. constructor(scene: Scene);
  71. /**
  72. * Registers the component in a given scene
  73. */
  74. register(): void;
  75. /**
  76. * Rebuilds the elements related to this component in case of
  77. * context lost for instance.
  78. */
  79. rebuild(): void;
  80. /**
  81. * Disposes the component and the associated resources
  82. */
  83. dispose(): void;
  84. }