IPhysicsEnginePlugin.d.ts 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import type { Nullable } from "../../types";
  2. import type { Vector3, Quaternion } from "../../Maths/math.vector";
  3. import type { AbstractMesh } from "../../Meshes/abstractMesh";
  4. import type { PhysicsImpostor } from "./physicsImpostor";
  5. import type { PhysicsJoint, IMotorEnabledJoint } from "./physicsJoint";
  6. import type { PhysicsRaycastResult } from "../physicsRaycastResult";
  7. /**
  8. * Interface used to describe a physics joint
  9. */
  10. export interface PhysicsImpostorJoint {
  11. /** Defines the main impostor to which the joint is linked */
  12. mainImpostor: PhysicsImpostor;
  13. /** Defines the impostor that is connected to the main impostor using this joint */
  14. connectedImpostor: PhysicsImpostor;
  15. /** Defines the joint itself */
  16. joint: PhysicsJoint;
  17. }
  18. /** @internal */
  19. export interface IPhysicsEnginePlugin {
  20. /**
  21. *
  22. */
  23. world: any;
  24. /**
  25. *
  26. */
  27. name: string;
  28. setGravity(gravity: Vector3): void;
  29. setTimeStep(timeStep: number): void;
  30. getTimeStep(): number;
  31. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32. getPluginVersion(): number;
  33. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  35. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36. removePhysicsBody(impostor: PhysicsImpostor): void;
  37. generateJoint(joint: PhysicsImpostorJoint): void;
  38. removeJoint(joint: PhysicsImpostorJoint): void;
  39. isSupported(): boolean;
  40. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  41. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  42. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  43. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  44. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47. getBodyMass(impostor: PhysicsImpostor): number;
  48. getBodyFriction(impostor: PhysicsImpostor): number;
  49. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50. getBodyRestitution(impostor: PhysicsImpostor): number;
  51. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52. getBodyPressure?(impostor: PhysicsImpostor): number;
  53. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  54. getBodyStiffness?(impostor: PhysicsImpostor): number;
  55. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  56. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  57. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  58. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  59. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  60. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  61. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  62. sleepBody(impostor: PhysicsImpostor): void;
  63. wakeUpBody(impostor: PhysicsImpostor): void;
  64. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65. raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void;
  66. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  67. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  68. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  69. getRadius(impostor: PhysicsImpostor): number;
  70. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  71. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  72. dispose(): void;
  73. }