babylon.action.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var Action = (function () {
  4. function Action(triggerOptions, condition) {
  5. this.triggerOptions = triggerOptions;
  6. if (triggerOptions.parameter) {
  7. this.trigger = triggerOptions.trigger;
  8. this._triggerParameter = triggerOptions.parameter;
  9. } else {
  10. this.trigger = triggerOptions;
  11. }
  12. this._nextActiveAction = this;
  13. this._condition = condition;
  14. }
  15. // Methods
  16. Action.prototype._prepare = function () {
  17. };
  18. Action.prototype.getTriggerParameter = function () {
  19. return this._triggerParameter;
  20. };
  21. Action.prototype._executeCurrent = function (evt) {
  22. if (this._condition) {
  23. var currentRenderId = this._actionManager.getScene().getRenderId();
  24. // We cache the current evaluation for the current frame
  25. if (this._condition._evaluationId === currentRenderId) {
  26. if (!this._condition._currentResult) {
  27. return;
  28. }
  29. } else {
  30. this._condition._evaluationId = currentRenderId;
  31. if (!this._condition.isValid()) {
  32. this._condition._currentResult = false;
  33. return;
  34. }
  35. this._condition._currentResult = true;
  36. }
  37. }
  38. this._nextActiveAction.execute(evt);
  39. if (this._nextActiveAction._child) {
  40. if (!this._nextActiveAction._child._actionManager) {
  41. this._nextActiveAction._child._actionManager = this._actionManager;
  42. }
  43. this._nextActiveAction = this._nextActiveAction._child;
  44. } else {
  45. this._nextActiveAction = this;
  46. }
  47. };
  48. Action.prototype.execute = function (evt) {
  49. };
  50. Action.prototype.then = function (action) {
  51. this._child = action;
  52. action._actionManager = this._actionManager;
  53. action._prepare();
  54. return action;
  55. };
  56. Action.prototype._getProperty = function (propertyPath) {
  57. return this._actionManager._getProperty(propertyPath);
  58. };
  59. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  60. return this._actionManager._getEffectiveTarget(target, propertyPath);
  61. };
  62. return Action;
  63. })();
  64. BABYLON.Action = Action;
  65. })(BABYLON || (BABYLON = {}));
  66. //# sourceMappingURL=babylon.action.js.map