action.d.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import { Observable } from "../Misc/observable";
  2. import type { Condition } from "./condition";
  3. import type { AbstractActionManager } from "./abstractActionManager";
  4. import type { Nullable } from "../types";
  5. import type { Material } from "../Materials/material";
  6. import type { Scene } from "../scene";
  7. import type { ActionManager } from "./actionManager";
  8. import type { ActionEvent } from "./actionEvent";
  9. import type { Node } from "../node";
  10. /**
  11. * Interface used to define Action
  12. */
  13. export interface IAction {
  14. /**
  15. * Trigger for the action
  16. */
  17. trigger: number;
  18. /** Options of the trigger */
  19. triggerOptions: any;
  20. /**
  21. * Gets the trigger parameters
  22. * @returns the trigger parameters
  23. */
  24. getTriggerParameter(): any;
  25. /**
  26. * Internal only - executes current action event
  27. * @internal
  28. */
  29. _executeCurrent(evt?: ActionEvent): void;
  30. /**
  31. * Serialize placeholder for child classes
  32. * @param parent of child
  33. * @returns the serialized object
  34. */
  35. serialize(parent: any): any;
  36. /**
  37. * Internal only
  38. * @internal
  39. */
  40. _prepare(): void;
  41. /**
  42. * Internal only - manager for action
  43. * @internal
  44. */
  45. _actionManager: Nullable<AbstractActionManager>;
  46. /**
  47. * Adds action to chain of actions, may be a DoNothingAction
  48. * @param action defines the next action to execute
  49. * @returns The action passed in
  50. * @see https://www.babylonjs-playground.com/#1T30HR#0
  51. */
  52. then(action: IAction): IAction;
  53. }
  54. /**
  55. * The action to be carried out following a trigger
  56. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#available-actions
  57. */
  58. export declare class Action implements IAction {
  59. /** the trigger, with or without parameters, for the action */
  60. triggerOptions: any;
  61. /**
  62. * Trigger for the action
  63. */
  64. trigger: number;
  65. /**
  66. * Internal only - manager for action
  67. * @internal
  68. */
  69. _actionManager: ActionManager;
  70. private _nextActiveAction;
  71. private _child;
  72. private _condition?;
  73. private _triggerParameter;
  74. /**
  75. * An event triggered prior to action being executed.
  76. */
  77. onBeforeExecuteObservable: Observable<Action>;
  78. /**
  79. * Creates a new Action
  80. * @param triggerOptions the trigger, with or without parameters, for the action
  81. * @param condition an optional determinant of action
  82. */
  83. constructor(
  84. /** the trigger, with or without parameters, for the action */
  85. triggerOptions: any, condition?: Condition);
  86. /**
  87. * Internal only
  88. * @internal
  89. */
  90. _prepare(): void;
  91. /**
  92. * Gets the trigger parameter
  93. * @returns the trigger parameter
  94. */
  95. getTriggerParameter(): any;
  96. /**
  97. * Sets the trigger parameter
  98. * @param value defines the new trigger parameter
  99. */
  100. setTriggerParameter(value: any): void;
  101. /**
  102. * Internal only - Returns if the current condition allows to run the action
  103. * @internal
  104. */
  105. _evaluateConditionForCurrentFrame(): boolean;
  106. /**
  107. * Internal only - executes current action event
  108. * @internal
  109. */
  110. _executeCurrent(evt?: ActionEvent): void;
  111. /**
  112. * Execute placeholder for child classes
  113. * @param evt optional action event
  114. */
  115. execute(evt?: ActionEvent): void;
  116. /**
  117. * Skips to next active action
  118. */
  119. skipToNextActiveAction(): void;
  120. /**
  121. * Adds action to chain of actions, may be a DoNothingAction
  122. * @param action defines the next action to execute
  123. * @returns The action passed in
  124. * @see https://www.babylonjs-playground.com/#1T30HR#0
  125. */
  126. then(action: Action): Action;
  127. /**
  128. * Internal only
  129. * @internal
  130. */
  131. _getProperty(propertyPath: string): string;
  132. /**
  133. * @internal
  134. */
  135. _getEffectiveTarget(target: any, propertyPath: string): any;
  136. /**
  137. * Serialize placeholder for child classes
  138. * @param parent of child
  139. * @returns the serialized object
  140. */
  141. serialize(parent: any): any;
  142. /**
  143. * Internal only called by serialize
  144. * @internal
  145. */
  146. protected _serialize(serializedAction: any, parent?: any): any;
  147. /**
  148. * Internal only
  149. * @internal
  150. */
  151. static _SerializeValueAsString: (value: any) => string;
  152. /**
  153. * Internal only
  154. * @internal
  155. */
  156. static _GetTargetProperty: (target: Scene | Node | Material) => {
  157. name: string;
  158. targetType: string;
  159. value: string;
  160. };
  161. }