actionManager.d.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import type { Nullable } from "../types";
  2. import type { AbstractMesh } from "../Meshes/abstractMesh";
  3. import type { Scene } from "../scene";
  4. import type { IAction } from "./action";
  5. import type { IActionEvent } from "../Actions/actionEvent";
  6. import { AbstractActionManager } from "./abstractActionManager";
  7. /**
  8. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions
  11. */
  12. export declare class ActionManager extends AbstractActionManager {
  13. /**
  14. * Nothing
  15. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  16. */
  17. static readonly NothingTrigger = 0;
  18. /**
  19. * On pick
  20. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  21. */
  22. static readonly OnPickTrigger = 1;
  23. /**
  24. * On left pick
  25. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  26. */
  27. static readonly OnLeftPickTrigger = 2;
  28. /**
  29. * On right pick
  30. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  31. */
  32. static readonly OnRightPickTrigger = 3;
  33. /**
  34. * On center pick
  35. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  36. */
  37. static readonly OnCenterPickTrigger = 4;
  38. /**
  39. * On pick down
  40. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  41. */
  42. static readonly OnPickDownTrigger = 5;
  43. /**
  44. * On double pick
  45. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  46. */
  47. static readonly OnDoublePickTrigger = 6;
  48. /**
  49. * On pick up
  50. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  51. */
  52. static readonly OnPickUpTrigger = 7;
  53. /**
  54. * On pick out.
  55. * This trigger will only be raised if you also declared a OnPickDown
  56. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  57. */
  58. static readonly OnPickOutTrigger = 16;
  59. /**
  60. * On long press
  61. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  62. */
  63. static readonly OnLongPressTrigger = 8;
  64. /**
  65. * On pointer over
  66. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  67. */
  68. static readonly OnPointerOverTrigger = 9;
  69. /**
  70. * On pointer out
  71. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  72. */
  73. static readonly OnPointerOutTrigger = 10;
  74. /**
  75. * On every frame
  76. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  77. */
  78. static readonly OnEveryFrameTrigger = 11;
  79. /**
  80. * On intersection enter
  81. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  82. */
  83. static readonly OnIntersectionEnterTrigger = 12;
  84. /**
  85. * On intersection exit
  86. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  87. */
  88. static readonly OnIntersectionExitTrigger = 13;
  89. /**
  90. * On key down
  91. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  92. */
  93. static readonly OnKeyDownTrigger = 14;
  94. /**
  95. * On key up
  96. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions#triggers
  97. */
  98. static readonly OnKeyUpTrigger = 15;
  99. private _scene;
  100. /**
  101. * Creates a new action manager
  102. * @param scene defines the hosting scene
  103. */
  104. constructor(scene?: Nullable<Scene>);
  105. /**
  106. * Releases all associated resources
  107. */
  108. dispose(): void;
  109. /**
  110. * Gets hosting scene
  111. * @returns the hosting scene
  112. */
  113. getScene(): Scene;
  114. /**
  115. * Does this action manager handles actions of any of the given triggers
  116. * @param triggers defines the triggers to be tested
  117. * @returns a boolean indicating whether one (or more) of the triggers is handled
  118. */
  119. hasSpecificTriggers(triggers: number[]): boolean;
  120. /**
  121. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  122. * speed.
  123. * @param triggerA defines the trigger to be tested
  124. * @param triggerB defines the trigger to be tested
  125. * @returns a boolean indicating whether one (or more) of the triggers is handled
  126. */
  127. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  128. /**
  129. * Does this action manager handles actions of a given trigger
  130. * @param trigger defines the trigger to be tested
  131. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  132. * @returns whether the trigger is handled
  133. */
  134. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  135. /**
  136. * Does this action manager has pointer triggers
  137. */
  138. get hasPointerTriggers(): boolean;
  139. /**
  140. * Does this action manager has pick triggers
  141. */
  142. get hasPickTriggers(): boolean;
  143. /**
  144. * Registers an action to this action manager
  145. * @param action defines the action to be registered
  146. * @returns the action amended (prepared) after registration
  147. */
  148. registerAction(action: IAction): Nullable<IAction>;
  149. /**
  150. * Unregisters an action to this action manager
  151. * @param action defines the action to be unregistered
  152. * @returns a boolean indicating whether the action has been unregistered
  153. */
  154. unregisterAction(action: IAction): Boolean;
  155. /**
  156. * Process a specific trigger
  157. * @param trigger defines the trigger to process
  158. * @param evt defines the event details to be processed
  159. */
  160. processTrigger(trigger: number, evt?: IActionEvent): void;
  161. /**
  162. * @internal
  163. */
  164. _getEffectiveTarget(target: any, propertyPath: string): any;
  165. /**
  166. * @internal
  167. */
  168. _getProperty(propertyPath: string): string;
  169. /**
  170. * Serialize this manager to a JSON object
  171. * @param name defines the property name to store this manager
  172. * @returns a JSON representation of this manager
  173. */
  174. serialize(name: string): any;
  175. /**
  176. * Creates a new ActionManager from a JSON data
  177. * @param parsedActions defines the JSON data to read from
  178. * @param object defines the hosting mesh
  179. * @param scene defines the hosting scene
  180. */
  181. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  182. /**
  183. * Get a trigger name by index
  184. * @param trigger defines the trigger index
  185. * @returns a trigger name
  186. */
  187. static GetTriggerName(trigger: number): string;
  188. }