babylon.actionManager.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. this.actions.push(action);
  15. action._actionManager = this;
  16. action._prepare();
  17. return action;
  18. };
  19. ActionManager.prototype.processTrigger = function (trigger) {
  20. for (var index = 0; index < this.actions.length; index++) {
  21. var action = this.actions[index];
  22. if (action.trigger === trigger) {
  23. action._executeCurrent();
  24. }
  25. }
  26. };
  27. ActionManager.prototype._getTarget = function (targetType, targetName) {
  28. var scene = this._scene;
  29. switch (targetType) {
  30. case ActionManager.SceneTarget:
  31. return scene;
  32. case ActionManager.MeshTarget:
  33. return scene.getMeshByName(targetName);
  34. case ActionManager.LightTarget:
  35. return scene.getLightByName(targetName);
  36. case ActionManager.CameraTarget:
  37. return scene.getCameraByName(targetName);
  38. case ActionManager.MaterialTarget:
  39. return scene.getMaterialByName(targetName);
  40. }
  41. return null;
  42. };
  43. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  44. var properties = propertyPath.split(".");
  45. for (var index = 0; index < properties.length - 1; index++) {
  46. target = target[properties[index]];
  47. }
  48. return target;
  49. };
  50. ActionManager.prototype._getProperty = function (propertyPath) {
  51. var properties = propertyPath.split(".");
  52. return properties[properties.length - 1];
  53. };
  54. ActionManager.AlwaysTrigger = 0;
  55. ActionManager.OnPickTrigger = 1;
  56. ActionManager.SceneTarget = 0;
  57. ActionManager.MeshTarget = 1;
  58. ActionManager.LightTarget = 2;
  59. ActionManager.CameraTarget = 3;
  60. ActionManager.MaterialTarget = 4;
  61. return ActionManager;
  62. })();
  63. BABYLON.ActionManager = ActionManager;
  64. })(BABYLON || (BABYLON = {}));
  65. //# sourceMappingURL=babylon.actionManager.js.map