babylon.action.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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._nextActiveAction._condition) {
  24. var condition = this._nextActiveAction._condition;
  25. var currentRenderId = this._actionManager.getScene().getRenderId();
  26. // We cache the current evaluation for the current frame
  27. if (condition._evaluationId === currentRenderId) {
  28. if (!condition._currentResult) {
  29. return;
  30. }
  31. }
  32. else {
  33. condition._evaluationId = currentRenderId;
  34. if (!condition.isValid()) {
  35. condition._currentResult = false;
  36. return;
  37. }
  38. condition._currentResult = true;
  39. }
  40. }
  41. this._nextActiveAction.execute(evt);
  42. this.skipToNextActiveAction();
  43. };
  44. Action.prototype.execute = function (evt) {
  45. };
  46. Action.prototype.skipToNextActiveAction = function () {
  47. if (this._nextActiveAction._child) {
  48. if (!this._nextActiveAction._child._actionManager) {
  49. this._nextActiveAction._child._actionManager = this._actionManager;
  50. }
  51. this._nextActiveAction = this._nextActiveAction._child;
  52. }
  53. else {
  54. this._nextActiveAction = this;
  55. }
  56. };
  57. Action.prototype.then = function (action) {
  58. this._child = action;
  59. action._actionManager = this._actionManager;
  60. action._prepare();
  61. return action;
  62. };
  63. Action.prototype._getProperty = function (propertyPath) {
  64. return this._actionManager._getProperty(propertyPath);
  65. };
  66. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  67. return this._actionManager._getEffectiveTarget(target, propertyPath);
  68. };
  69. return Action;
  70. })();
  71. BABYLON.Action = Action;
  72. })(BABYLON || (BABYLON = {}));
  73. //# sourceMappingURL=babylon.action.js.map