flyCameraInputsManager.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { FlyCamera } from "./flyCamera";
  2. import { CameraInputsManager } from "./cameraInputsManager";
  3. import { FlyCameraMouseInput } from "../Cameras/Inputs/flyCameraMouseInput";
  4. import { FlyCameraKeyboardInput } from "../Cameras/Inputs/flyCameraKeyboardInput";
  5. /**
  6. * Default Inputs manager for the FlyCamera.
  7. * It groups all the default supported inputs for ease of use.
  8. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9. */
  10. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  11. /**
  12. * Instantiates a new FlyCameraInputsManager.
  13. * @param camera Defines the camera the inputs belong to.
  14. */
  15. constructor(camera: FlyCamera) {
  16. super(camera);
  17. }
  18. /**
  19. * Add keyboard input support to the input manager.
  20. * @returns the new FlyCameraKeyboardMoveInput().
  21. */
  22. addKeyboard(): FlyCameraInputsManager {
  23. this.add(new FlyCameraKeyboardInput());
  24. return this;
  25. }
  26. /**
  27. * Add mouse input support to the input manager.
  28. * @param touchEnabled Enable touch screen support.
  29. * @returns the new FlyCameraMouseInput().
  30. */
  31. addMouse(touchEnabled = true): FlyCameraInputsManager {
  32. this.add(new FlyCameraMouseInput(touchEnabled));
  33. return this;
  34. }
  35. }