babylon.arcrotatecamera.input.mousewheel.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6. };
  7. var BABYLON;
  8. (function (BABYLON) {
  9. var ArcRotateCameraMouseWheelInput = (function () {
  10. function ArcRotateCameraMouseWheelInput() {
  11. this.wheelPrecision = 3.0;
  12. }
  13. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  14. var _this = this;
  15. this._wheel = function (p, s) {
  16. var event = p.event;
  17. var delta = 0;
  18. if (event.wheelDelta) {
  19. delta = event.wheelDelta / (_this.wheelPrecision * 40);
  20. }
  21. else if (event.detail) {
  22. delta = -event.detail / _this.wheelPrecision;
  23. }
  24. if (delta)
  25. _this.camera.inertialRadiusOffset += delta;
  26. if (event.preventDefault) {
  27. if (!noPreventDefault) {
  28. event.preventDefault();
  29. }
  30. }
  31. };
  32. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel);
  33. };
  34. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  35. if (this._observer && element) {
  36. this.camera.getScene().onPointerObservable.remove(this._observer);
  37. this._observer = null;
  38. this._wheel = null;
  39. }
  40. };
  41. ArcRotateCameraMouseWheelInput.prototype.getTypeName = function () {
  42. return "ArcRotateCameraMouseWheelInput";
  43. };
  44. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  45. return "mousewheel";
  46. };
  47. __decorate([
  48. BABYLON.serialize()
  49. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  50. return ArcRotateCameraMouseWheelInput;
  51. }());
  52. BABYLON.ArcRotateCameraMouseWheelInput = ArcRotateCameraMouseWheelInput;
  53. BABYLON.CameraInputTypes["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  54. })(BABYLON || (BABYLON = {}));