babylon.inputController.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. "use strict";
  2. var BABYLON = BABYLON || {};
  3. (function () {
  4. BABYLON.inputControllerTarget = function () {
  5. this._position = new BABYLON.Vector3(0, 0, 0);
  6. this._orientation = { yaw: 0.0, pitch: 0.0, roll: 0.0 };
  7. };
  8. BABYLON.inputControllerTarget.prototype.getPosition = function () {
  9. return this._position;
  10. };
  11. BABYLON.inputControllerTarget.prototype.getOrientation = function () {
  12. return this._orientation;
  13. };
  14. BABYLON.inputControllerTarget.prototype.moveRelative = function (movementVector) {
  15. };
  16. BABYLON.inputControllerTarget.prototype.rotateRelative = function (relativeOrientation) {
  17. };
  18. BABYLON.inputControllerTarget.prototype.getOrientationMatrix = function () { return new BABYLON.Matrix(); };
  19. BABYLON.inputControllerTarget.prototype.getInvertOrientationMatrix = function () { return new BABYLON.Matrix(); };
  20. BABYLON.inputControllerMultiTarget = function (targets) {
  21. this.targets = targets;
  22. var mainTarget = this.targets[0];
  23. if (!mainTarget.controllers) {
  24. mainTarget.controllers = [this];
  25. } else {
  26. mainTarget.controllers.push(this);
  27. }
  28. };
  29. BABYLON.inputControllerMultiTarget.prototype.getPosition = function () {
  30. return this.targets[0].getPosition();
  31. };
  32. BABYLON.inputControllerMultiTarget.prototype.getOrientation = function () {
  33. return this.targets[0].getOrientation();
  34. };
  35. BABYLON.inputControllerMultiTarget.prototype.getOrientationMatrix = function () { return this.targets[0].getOrientationMatrix(); };
  36. BABYLON.inputControllerMultiTarget.prototype.getInvertOrientationMatrix = function () { return this.targets[0].getInvertOrientationMatrix(); };
  37. BABYLON.inputControllerMultiTarget.prototype.moveRelative = function (movementVector) {
  38. for (var i = 0; i < this.targets.length; ++i) {
  39. this.targets[i].moveRelative(movementVector);
  40. }
  41. };
  42. BABYLON.inputControllerMultiTarget.prototype.rotateRelative = function (relativeOrientation) {
  43. for (var i = 0; i < this.targets.length; ++i) {
  44. this.targets[i].rotateRelative(relativeOrientation);
  45. }
  46. };
  47. BABYLON.inputControllerMultiTarget.prototype.update = function () {
  48. if (this.controllers) {
  49. for (var i = 0; i < this.controllers.length; ++i) {
  50. this.controllers[i].update();
  51. }
  52. }
  53. };
  54. BABYLON.inputController = function (scene, target) {
  55. this.scene = scene;
  56. this.target = target;
  57. if (!this.target.controllers) {
  58. this.target.controllers = [this];
  59. } else {
  60. this.target.controllers.push(this);
  61. }
  62. };
  63. BABYLON.inputController.prototype.attachToCanvas = function (canvas) {
  64. };
  65. BABYLON.inputController.prototype.detachFromCanvas = function (canvas) {
  66. };
  67. BABYLON.inputController.prototype.update = function () {
  68. };
  69. BABYLON.inputController.prototype.dispose = function () {
  70. };
  71. BABYLON.inputFilter = function (scene, target) {
  72. BABYLON.inputController.call(this, scene, target);
  73. };
  74. BABYLON.inputFilter.prototype = Object.create(BABYLON.inputController.prototype);
  75. BABYLON.inputFilter.prototype.update = function () {
  76. if (this.controllers) {
  77. for (var i = 0; i < this.controllers.length; ++i) {
  78. this.controllers[i].update();
  79. }
  80. }
  81. };
  82. BABYLON.inputFilter.prototype.getPosition = function () {
  83. return this.target.getPosition();
  84. };
  85. BABYLON.inputFilter.prototype.getOrientation = function () {
  86. return this.target.getOrientation();
  87. };
  88. BABYLON.inputFilter.prototype.getOrientationMatrix = function () { return this.target.getOrientationMatrix(); };
  89. BABYLON.inputFilter.prototype.getInvertOrientationMatrix = function () { return this.target.getInvertOrientationMatrix(); };
  90. BABYLON.inputFilter.prototype.moveRelative = function (movementVector) {
  91. this.target.moveRelative(movementVector);
  92. };
  93. BABYLON.inputFilter.prototype.rotateRelative = function (relativeOrientation) {
  94. this.target.rotateRelative(relativeOrientation);
  95. };
  96. })();