babylon.inputController.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. })();