babylon.action.js 2.6 KB

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