babylon.inputController.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.inputControllerMultiTarget = function (targets) {
  19. this.targets = targets;
  20. var mainTarget = this.targets[0];
  21. if (!mainTarget.controllers) {
  22. mainTarget.controllers = [this];
  23. } else {
  24. mainTarget.controllers.push(this);
  25. }
  26. };
  27. BABYLON.inputControllerMultiTarget.prototype.getPosition = function () {
  28. return this.targets[0].getPosition();
  29. };
  30. BABYLON.inputControllerMultiTarget.prototype.getOrientation = function () {
  31. return this.targets[0].getOrientation();
  32. };
  33. BABYLON.inputControllerMultiTarget.prototype.moveRelative = function (movementVector) {
  34. for (var i = 0; i < this.targets.length; ++i) {
  35. this.targets[i].moveRelative(movementVector);
  36. }
  37. };
  38. BABYLON.inputControllerMultiTarget.prototype.rotateRelative = function (relativeOrientation) {
  39. for (var i = 0; i < this.targets.length; ++i) {
  40. this.targets[i].rotateRelative(relativeOrientation);
  41. }
  42. };
  43. BABYLON.inputControllerMultiTarget.prototype.update = function () {
  44. if (this.controllers) {
  45. for (var i = 0; i < this.controllers.length; ++i) {
  46. this.controllers[i].update();
  47. }
  48. }
  49. };
  50. BABYLON.inputController = function (scene, target) {
  51. this.scene = scene;
  52. this.target = target;
  53. if (!this.target.controllers) {
  54. this.target.controllers = [this];
  55. } else {
  56. this.target.controllers.push(this);
  57. }
  58. };
  59. BABYLON.inputController.prototype.attachToCanvas = function (canvas) {
  60. };
  61. BABYLON.inputController.prototype.detachFromCanvas = function (canvas) {
  62. };
  63. BABYLON.inputController.prototype.update = function () {
  64. };
  65. BABYLON.inputController.prototype.dispose = function () {
  66. };
  67. BABYLON.inputFilter = function (scene, target) {
  68. BABYLON.inputController.call(this, scene, target);
  69. };
  70. BABYLON.inputFilter.prototype = Object.create(BABYLON.inputController.prototype);
  71. BABYLON.inputFilter.prototype.update = function () {
  72. if (this.controllers) {
  73. for (var i = 0; i < this.controllers.length; ++i) {
  74. this.controllers[i].update();
  75. }
  76. }
  77. };
  78. BABYLON.inputFilter.prototype.getPosition = function () {
  79. return this.target.getPosition();
  80. };
  81. BABYLON.inputFilter.prototype.getOrientation = function () {
  82. return this.target.getOrientation();
  83. };
  84. BABYLON.inputFilter.prototype.moveRelative = function (movementVector) {
  85. this.target.moveRelative(movementVector);
  86. };
  87. BABYLON.inputFilter.prototype.rotateRelative = function (relativeOrientation) {
  88. this.target.rotateRelative(relativeOrientation);
  89. };
  90. })();