babylon.action.js 2.7 KB

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