BaseCameraMouseWheelInput.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { Observable } from "../../Misc/observable";
  2. import type { Camera } from "../../Cameras/camera";
  3. import type { ICameraInput } from "../../Cameras/cameraInputsManager";
  4. /**
  5. * Base class for mouse wheel input..
  6. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  7. * for example usage.
  8. */
  9. export declare abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  10. /**
  11. * Defines the camera the input is attached to.
  12. */
  13. abstract camera: Camera;
  14. /**
  15. * How fast is the camera moves in relation to X axis mouseWheel events.
  16. * Use negative value to reverse direction.
  17. */
  18. wheelPrecisionX: number;
  19. /**
  20. * How fast is the camera moves in relation to Y axis mouseWheel events.
  21. * Use negative value to reverse direction.
  22. */
  23. wheelPrecisionY: number;
  24. /**
  25. * How fast is the camera moves in relation to Z axis mouseWheel events.
  26. * Use negative value to reverse direction.
  27. */
  28. wheelPrecisionZ: number;
  29. /**
  30. * Observable for when a mouse wheel move event occurs.
  31. */
  32. onChangedObservable: Observable<{
  33. wheelDeltaX: number;
  34. wheelDeltaY: number;
  35. wheelDeltaZ: number;
  36. }>;
  37. private _wheel;
  38. private _observer;
  39. /**
  40. * Attach the input controls to a specific dom element to get the input from.
  41. * @param noPreventDefault Defines whether event caught by the controls
  42. * should call preventdefault().
  43. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44. */
  45. attachControl(noPreventDefault?: boolean): void;
  46. /**
  47. * Detach the current controls from the specified dom element.
  48. */
  49. detachControl(): void;
  50. /**
  51. * Called for each rendered frame.
  52. */
  53. checkInputs(): void;
  54. /**
  55. * Gets the class name of the current input.
  56. * @returns the class name
  57. */
  58. getClassName(): string;
  59. /**
  60. * Get the friendly name associated with the input class.
  61. * @returns the input friendly name
  62. */
  63. getSimpleName(): string;
  64. /**
  65. * Incremental value of multiple mouse wheel movements of the X axis.
  66. * Should be zero-ed when read.
  67. */
  68. protected _wheelDeltaX: number;
  69. /**
  70. * Incremental value of multiple mouse wheel movements of the Y axis.
  71. * Should be zero-ed when read.
  72. */
  73. protected _wheelDeltaY: number;
  74. /**
  75. * Incremental value of multiple mouse wheel movements of the Z axis.
  76. * Should be zero-ed when read.
  77. */
  78. protected _wheelDeltaZ: number;
  79. /**
  80. * Firefox uses a different scheme to report scroll distances to other
  81. * browsers. Rather than use complicated methods to calculate the exact
  82. * multiple we need to apply, let's just cheat and use a constant.
  83. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  84. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  85. */
  86. private readonly _ffMultiplier;
  87. /**
  88. * Different event attributes for wheel data fall into a few set ranges.
  89. * Some relevant but dated date here:
  90. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  91. */
  92. private readonly _normalize;
  93. }