babylon.physicsEngine.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var PhysicsEngine = (function () {
  4. function PhysicsEngine(plugin) {
  5. this._currentPlugin = plugin || new BABYLON.OimoJSPlugin();
  6. }
  7. PhysicsEngine.prototype._initialize = function (gravity) {
  8. this._currentPlugin.initialize();
  9. this._setGravity(gravity);
  10. };
  11. PhysicsEngine.prototype._runOneStep = function (delta) {
  12. if (delta > 0.1) {
  13. delta = 0.1;
  14. } else if (delta <= 0) {
  15. delta = 1.0 / 60.0;
  16. }
  17. this._currentPlugin.runOneStep(delta);
  18. };
  19. PhysicsEngine.prototype._setGravity = function (gravity) {
  20. this.gravity = gravity || new BABYLON.Vector3(0, -9.82, 0);
  21. this._currentPlugin.setGravity(this.gravity);
  22. };
  23. PhysicsEngine.prototype._registerMesh = function (mesh, impostor, options) {
  24. return this._currentPlugin.registerMesh(mesh, impostor, options);
  25. };
  26. PhysicsEngine.prototype._registerMeshesAsCompound = function (parts, options) {
  27. return this._currentPlugin.registerMeshesAsCompound(parts, options);
  28. };
  29. PhysicsEngine.prototype._unregisterMesh = function (mesh) {
  30. this._currentPlugin.unregisterMesh(mesh);
  31. };
  32. PhysicsEngine.prototype._applyImpulse = function (mesh, force, contactPoint) {
  33. this._currentPlugin.applyImpulse(mesh, force, contactPoint);
  34. };
  35. PhysicsEngine.prototype._createLink = function (mesh1, mesh2, pivot1, pivot2, options) {
  36. return this._currentPlugin.createLink(mesh1, mesh2, pivot1, pivot2, options);
  37. };
  38. PhysicsEngine.prototype._updateBodyPosition = function (mesh) {
  39. this._currentPlugin.updateBodyPosition(mesh);
  40. };
  41. PhysicsEngine.prototype.dispose = function () {
  42. this._currentPlugin.dispose();
  43. };
  44. PhysicsEngine.prototype.isSupported = function () {
  45. return this._currentPlugin.isSupported();
  46. };
  47. PhysicsEngine.NoImpostor = 0;
  48. PhysicsEngine.SphereImpostor = 1;
  49. PhysicsEngine.BoxImpostor = 2;
  50. PhysicsEngine.PlaneImpostor = 3;
  51. PhysicsEngine.MeshImpostor = 4;
  52. PhysicsEngine.CapsuleImpostor = 5;
  53. PhysicsEngine.ConeImpostor = 6;
  54. PhysicsEngine.CylinderImpostor = 7;
  55. PhysicsEngine.ConvexHullImpostor = 8;
  56. PhysicsEngine.Epsilon = 0.001;
  57. return PhysicsEngine;
  58. })();
  59. BABYLON.PhysicsEngine = PhysicsEngine;
  60. })(BABYLON || (BABYLON = {}));
  61. //# sourceMappingURL=babylon.physicsEngine.js.map