actionEvent.d.ts 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import type { AbstractMesh } from "../Meshes/abstractMesh";
  2. import type { Nullable } from "../types";
  3. import type { Sprite } from "../Sprites/sprite";
  4. import type { Scene } from "../scene";
  5. import type { Vector2 } from "../Maths/math.vector";
  6. /**
  7. * Interface used to define ActionEvent
  8. */
  9. export interface IActionEvent {
  10. /** The mesh or sprite that triggered the action */
  11. source: any;
  12. /** The X mouse cursor position at the time of the event */
  13. pointerX: number;
  14. /** The Y mouse cursor position at the time of the event */
  15. pointerY: number;
  16. /** The mesh that is currently pointed at (can be null) */
  17. meshUnderPointer: Nullable<AbstractMesh>;
  18. /** the original (browser) event that triggered the ActionEvent */
  19. sourceEvent?: any;
  20. /** additional data for the event */
  21. additionalData?: any;
  22. }
  23. /**
  24. * ActionEvent is the event being sent when an action is triggered.
  25. */
  26. export declare class ActionEvent implements IActionEvent {
  27. /** The mesh or sprite that triggered the action */
  28. source: any;
  29. /** The X mouse cursor position at the time of the event */
  30. pointerX: number;
  31. /** The Y mouse cursor position at the time of the event */
  32. pointerY: number;
  33. /** The mesh that is currently pointed at (can be null) */
  34. meshUnderPointer: Nullable<AbstractMesh>;
  35. /** the original (browser) event that triggered the ActionEvent */
  36. sourceEvent?: any;
  37. /** additional data for the event */
  38. additionalData?: any;
  39. /**
  40. * Creates a new ActionEvent
  41. * @param source The mesh or sprite that triggered the action
  42. * @param pointerX The X mouse cursor position at the time of the event
  43. * @param pointerY The Y mouse cursor position at the time of the event
  44. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  45. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  46. * @param additionalData additional data for the event
  47. */
  48. constructor(
  49. /** The mesh or sprite that triggered the action */
  50. source: any,
  51. /** The X mouse cursor position at the time of the event */
  52. pointerX: number,
  53. /** The Y mouse cursor position at the time of the event */
  54. pointerY: number,
  55. /** The mesh that is currently pointed at (can be null) */
  56. meshUnderPointer: Nullable<AbstractMesh>,
  57. /** the original (browser) event that triggered the ActionEvent */
  58. sourceEvent?: any,
  59. /** additional data for the event */
  60. additionalData?: any);
  61. /**
  62. * Helper function to auto-create an ActionEvent from a source mesh.
  63. * @param source The source mesh that triggered the event
  64. * @param evt The original (browser) event
  65. * @param additionalData additional data for the event
  66. * @returns the new ActionEvent
  67. */
  68. static CreateNew(source: AbstractMesh, evt?: any, additionalData?: any): ActionEvent;
  69. /**
  70. * Helper function to auto-create an ActionEvent from a source sprite
  71. * @param source The source sprite that triggered the event
  72. * @param scene Scene associated with the sprite
  73. * @param evt The original (browser) event
  74. * @param additionalData additional data for the event
  75. * @returns the new ActionEvent
  76. */
  77. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: any, additionalData?: any): ActionEvent;
  78. /**
  79. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  80. * @param scene the scene where the event occurred
  81. * @param evt The original (browser) event
  82. * @returns the new ActionEvent
  83. */
  84. static CreateNewFromScene(scene: Scene, evt: any): ActionEvent;
  85. /**
  86. * Helper function to auto-create an ActionEvent from a primitive
  87. * @param prim defines the target primitive
  88. * @param pointerPos defines the pointer position
  89. * @param evt The original (browser) event
  90. * @param additionalData additional data for the event
  91. * @returns the new ActionEvent
  92. */
  93. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94. }