babylon.actionManager.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var ActionManager = (function () {
  4. function ActionManager(scene) {
  5. // Members
  6. this.actions = new Array();
  7. this._scene = scene;
  8. }
  9. Object.defineProperty(ActionManager, "NothingTrigger", {
  10. get: function () {
  11. return ActionManager._NothingTrigger;
  12. },
  13. enumerable: true,
  14. configurable: true
  15. });
  16. Object.defineProperty(ActionManager, "OnPickTrigger", {
  17. get: function () {
  18. return ActionManager._OnPickTrigger;
  19. },
  20. enumerable: true,
  21. configurable: true
  22. });
  23. Object.defineProperty(ActionManager, "OnLeftPickTrigger", {
  24. get: function () {
  25. return ActionManager._OnLeftPickTrigger;
  26. },
  27. enumerable: true,
  28. configurable: true
  29. });
  30. Object.defineProperty(ActionManager, "OnRightPickTrigger", {
  31. get: function () {
  32. return ActionManager._OnRightPickTrigger;
  33. },
  34. enumerable: true,
  35. configurable: true
  36. });
  37. Object.defineProperty(ActionManager, "OnCenterPickTrigger", {
  38. get: function () {
  39. return ActionManager._OnCenterPickTrigger;
  40. },
  41. enumerable: true,
  42. configurable: true
  43. });
  44. Object.defineProperty(ActionManager, "OnPointerOverTrigger", {
  45. get: function () {
  46. return ActionManager._OnPointerOverTrigger;
  47. },
  48. enumerable: true,
  49. configurable: true
  50. });
  51. Object.defineProperty(ActionManager, "OnPointerOutTrigger", {
  52. get: function () {
  53. return ActionManager._OnPointerOutTrigger;
  54. },
  55. enumerable: true,
  56. configurable: true
  57. });
  58. Object.defineProperty(ActionManager, "OnEveryFrameTrigger", {
  59. get: function () {
  60. return ActionManager._OnEveryFrameTrigger;
  61. },
  62. enumerable: true,
  63. configurable: true
  64. });
  65. // Methods
  66. ActionManager.prototype.getScene = function () {
  67. return this._scene;
  68. };
  69. ActionManager.prototype.registerAction = function (action) {
  70. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  71. if (this.getScene().actionManager !== this) {
  72. BABYLON.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  73. return null;
  74. }
  75. }
  76. this.actions.push(action);
  77. action._actionManager = this;
  78. action._prepare();
  79. return action;
  80. };
  81. ActionManager.prototype.processTrigger = function (trigger) {
  82. for (var index = 0; index < this.actions.length; index++) {
  83. var action = this.actions[index];
  84. if (action.trigger === trigger) {
  85. action._executeCurrent();
  86. }
  87. }
  88. };
  89. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  90. var properties = propertyPath.split(".");
  91. for (var index = 0; index < properties.length - 1; index++) {
  92. target = target[properties[index]];
  93. }
  94. return target;
  95. };
  96. ActionManager.prototype._getProperty = function (propertyPath) {
  97. var properties = propertyPath.split(".");
  98. return properties[properties.length - 1];
  99. };
  100. ActionManager._NothingTrigger = 0;
  101. ActionManager._OnPickTrigger = 1;
  102. ActionManager._OnLeftPickTrigger = 2;
  103. ActionManager._OnRightPickTrigger = 3;
  104. ActionManager._OnCenterPickTrigger = 4;
  105. ActionManager._OnPointerOverTrigger = 5;
  106. ActionManager._OnPointerOutTrigger = 6;
  107. ActionManager._OnEveryFrameTrigger = 7;
  108. return ActionManager;
  109. })();
  110. BABYLON.ActionManager = ActionManager;
  111. })(BABYLON || (BABYLON = {}));
  112. //# sourceMappingURL=babylon.actionManager.js.map