babylon.action.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. module BABYLON {
  2. export class Action {
  3. public _actionManager: ActionManager;
  4. private _nextActiveAction: Action;
  5. private _child: Action;
  6. private _condition: Condition;
  7. constructor(public trigger: number, condition?: Condition) {
  8. this._nextActiveAction = this;
  9. this._condition = condition;
  10. }
  11. // Methods
  12. public _prepare(): void {
  13. }
  14. public _executeCurrent(evt: ActionEvent): void {
  15. if (this._condition) {
  16. var currentRenderId = this._actionManager.getScene().getRenderId();
  17. // We cache the current evaluation for the current frame
  18. if (this._condition._evaluationId === currentRenderId) {
  19. if (!this._condition._currentResult) {
  20. return;
  21. }
  22. } else {
  23. this._condition._evaluationId = currentRenderId;
  24. if (!this._condition.isValid()) {
  25. this._condition._currentResult = false;
  26. return;
  27. }
  28. this._condition._currentResult = true;
  29. }
  30. }
  31. this._nextActiveAction.execute(evt);
  32. if (this._nextActiveAction._child) {
  33. this._nextActiveAction = this._nextActiveAction._child;
  34. } else {
  35. this._nextActiveAction = this;
  36. }
  37. }
  38. public execute(evt: ActionEvent): void {
  39. }
  40. public then(action: Action): Action {
  41. this._child = action;
  42. action._actionManager = this._actionManager;
  43. action._prepare();
  44. return action;
  45. }
  46. public _getProperty(propertyPath: string): string {
  47. return this._actionManager._getProperty(propertyPath);
  48. }
  49. public _getEffectiveTarget(target: any, propertyPath: string): any {
  50. return this._actionManager._getEffectiveTarget(target, propertyPath);
  51. }
  52. }
  53. }