babylon.physicsEngine.js 2.6 KB

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