babylon.gravityInputController.js 886 B

1234567891011121314151617181920
  1. "use strict";
  2. var BABYLON = BABYLON || {};
  3. (function () {
  4. BABYLON.GravityInputController = function (scene, target) {
  5. BABYLON.InputController.call(this, scene, target);
  6. this._moveVectorGlobal = new BABYLON.Vector3(0, 0, 0);
  7. this._moveVectorLocal = new BABYLON.Vector3(0, 0, 0);
  8. this._fallSpeed = .6;
  9. };
  10. BABYLON.GravityInputController.prototype = Object.create(BABYLON.InputController.prototype);
  11. BABYLON.GravityInputController.prototype.update = function () {
  12. this._moveVectorGlobal.x = 0;
  13. this._moveVectorGlobal.y = -this._fallSpeed * BABYLON.Tools.GetDeltaTime() / 1000.0;
  14. this._moveVectorGlobal.z = 0;
  15. BABYLON.Vector3.TransformNormalToRef(this._moveVectorGlobal, this.target.getInvertOrientationMatrix(), this._moveVectorLocal);
  16. this.target.moveRelative(this._moveVectorLocal);
  17. };
  18. })();