babylon.actionManager.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // Methods
  10. ActionManager.prototype.getScene = function () {
  11. return this._scene;
  12. };
  13. ActionManager.prototype.registerAction = function (action) {
  14. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  15. if (this.getScene().actionManager !== this) {
  16. console.warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  17. return null;
  18. }
  19. }
  20. this.actions.push(action);
  21. action._actionManager = this;
  22. action._prepare();
  23. return action;
  24. };
  25. ActionManager.prototype.processTrigger = function (trigger) {
  26. for (var index = 0; index < this.actions.length; index++) {
  27. var action = this.actions[index];
  28. if (action.trigger === trigger) {
  29. action._executeCurrent();
  30. }
  31. }
  32. };
  33. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  34. var properties = propertyPath.split(".");
  35. for (var index = 0; index < properties.length - 1; index++) {
  36. target = target[properties[index]];
  37. }
  38. return target;
  39. };
  40. ActionManager.prototype._getProperty = function (propertyPath) {
  41. var properties = propertyPath.split(".");
  42. return properties[properties.length - 1];
  43. };
  44. ActionManager.NoneTrigger = 0;
  45. ActionManager.OnPickTrigger = 1;
  46. ActionManager.OnPointerOverTrigger = 2;
  47. ActionManager.OnPointerOutTrigger = 3;
  48. ActionManager.OnEveryFrameTrigger = 4;
  49. return ActionManager;
  50. })();
  51. BABYLON.ActionManager = ActionManager;
  52. })(BABYLON || (BABYLON = {}));
  53. //# sourceMappingURL=babylon.actionManager.js.map