BaseCameraPointersInput.d.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import type { Nullable } from "../../types";
  2. import type { Camera } from "../../Cameras/camera";
  3. import type { ICameraInput } from "../../Cameras/cameraInputsManager";
  4. import type { PointerTouch } from "../../Events/pointerEvents";
  5. import type { IPointerEvent } from "../../Events/deviceInputEvents";
  6. /**
  7. * Base class for Camera Pointer Inputs.
  8. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  9. * for example usage.
  10. */
  11. export declare abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  12. /**
  13. * Defines the camera the input is attached to.
  14. */
  15. abstract camera: Camera;
  16. /**
  17. * Whether keyboard modifier keys are pressed at time of last mouse event.
  18. */
  19. protected _altKey: boolean;
  20. protected _ctrlKey: boolean;
  21. protected _metaKey: boolean;
  22. protected _shiftKey: boolean;
  23. /**
  24. * Which mouse buttons were pressed at time of last mouse event.
  25. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  26. */
  27. protected _buttonsPressed: number;
  28. private _currentActiveButton;
  29. private _contextMenuBind;
  30. /**
  31. * Defines the buttons associated with the input to handle camera move.
  32. */
  33. buttons: number[];
  34. /**
  35. * Attach the input controls to a specific dom element to get the input from.
  36. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37. */
  38. attachControl(noPreventDefault?: boolean): void;
  39. /**
  40. * Detach the current controls from the specified dom element.
  41. */
  42. detachControl(): void;
  43. /**
  44. * Gets the class name of the current input.
  45. * @returns the class name
  46. */
  47. getClassName(): string;
  48. /**
  49. * Get the friendly name associated with the input class.
  50. * @returns the input friendly name
  51. */
  52. getSimpleName(): string;
  53. /**
  54. * Called on pointer POINTERDOUBLETAP event.
  55. * Override this method to provide functionality on POINTERDOUBLETAP event.
  56. * @param type type of event
  57. */
  58. onDoubleTap(type: string): void;
  59. /**
  60. * Called on pointer POINTERMOVE event if only a single touch is active.
  61. * Override this method to provide functionality.
  62. * @param point The current position of the pointer
  63. * @param offsetX The offsetX of the pointer when the event occurred
  64. * @param offsetY The offsetY of the pointer when the event occurred
  65. */
  66. onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  67. /**
  68. * Called on pointer POINTERMOVE event if multiple touches are active.
  69. * Override this method to provide functionality.
  70. * @param _pointA First point in the pair
  71. * @param _pointB Second point in the pair
  72. * @param previousPinchSquaredDistance Sqr Distance between the points the last time this event was fired (by this input)
  73. * @param pinchSquaredDistance Sqr Distance between the points this time
  74. * @param previousMultiTouchPanPosition Previous center point between the points
  75. * @param multiTouchPanPosition Current center point between the points
  76. */
  77. onMultiTouch(_pointA: Nullable<PointerTouch>, _pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  78. /**
  79. * Called on JS contextmenu event.
  80. * Override this method to provide functionality.
  81. * @param evt the event to be handled
  82. */
  83. onContextMenu(evt: PointerEvent): void;
  84. /**
  85. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  86. * press.
  87. * Override this method to provide functionality.
  88. * @param _evt Defines the event to track
  89. */
  90. onButtonDown(_evt: IPointerEvent): void;
  91. /**
  92. * Called each time a new POINTERUP event occurs. Ie, for each button
  93. * release.
  94. * Override this method to provide functionality.
  95. * @param _evt Defines the event to track
  96. */
  97. onButtonUp(_evt: IPointerEvent): void;
  98. /**
  99. * Called when window becomes inactive.
  100. * Override this method to provide functionality.
  101. */
  102. onLostFocus(): void;
  103. private _pointerInput;
  104. private _observer;
  105. private _onLostFocus;
  106. private _pointA;
  107. private _pointB;
  108. }