babylon.action.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. this._nextActiveAction = this._nextActiveAction._child;
  41. } else {
  42. this._nextActiveAction = this;
  43. }
  44. };
  45. Action.prototype.execute = function (evt) {
  46. };
  47. Action.prototype.then = function (action) {
  48. this._child = action;
  49. action._actionManager = this._actionManager;
  50. action._prepare();
  51. return action;
  52. };
  53. Action.prototype._getProperty = function (propertyPath) {
  54. return this._actionManager._getProperty(propertyPath);
  55. };
  56. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  57. return this._actionManager._getEffectiveTarget(target, propertyPath);
  58. };
  59. return Action;
  60. })();
  61. BABYLON.Action = Action;
  62. })(BABYLON || (BABYLON = {}));
  63. //# sourceMappingURL=babylon.action.js.map