babylon.vrCameraMetrics.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var VRCameraMetrics = (function () {
  4. function VRCameraMetrics() {
  5. this.compensateDistortion = true;
  6. }
  7. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  8. get: function () {
  9. return this.hResolution / (2 * this.vResolution);
  10. },
  11. enumerable: true,
  12. configurable: true
  13. });
  14. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15. get: function () {
  16. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  17. },
  18. enumerable: true,
  19. configurable: true
  20. });
  21. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  22. get: function () {
  23. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  24. var h = (4 * meters) / this.hScreenSize;
  25. return BABYLON.Matrix.Translation(h, 0, 0);
  26. },
  27. enumerable: true,
  28. configurable: true
  29. });
  30. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  31. get: function () {
  32. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  33. var h = (4 * meters) / this.hScreenSize;
  34. return BABYLON.Matrix.Translation(-h, 0, 0);
  35. },
  36. enumerable: true,
  37. configurable: true
  38. });
  39. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  40. get: function () {
  41. return BABYLON.Matrix.Translation(0.5 * this.interpupillaryDistance, 0, 0);
  42. },
  43. enumerable: true,
  44. configurable: true
  45. });
  46. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  47. get: function () {
  48. return BABYLON.Matrix.Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  49. },
  50. enumerable: true,
  51. configurable: true
  52. });
  53. VRCameraMetrics.GetDefault = function () {
  54. var result = new VRCameraMetrics();
  55. result.hResolution = 1280;
  56. result.vResolution = 800;
  57. result.hScreenSize = 0.149759993;
  58. result.vScreenSize = 0.0935999975;
  59. result.vScreenCenter = 0.0467999987,
  60. result.eyeToScreenDistance = 0.0410000011;
  61. result.lensSeparationDistance = 0.0635000020;
  62. result.interpupillaryDistance = 0.0640000030;
  63. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  64. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  65. result.postProcessScaleFactor = 1.714605507808412;
  66. result.lensCenterOffset = 0.151976421;
  67. return result;
  68. };
  69. return VRCameraMetrics;
  70. })();
  71. BABYLON.VRCameraMetrics = VRCameraMetrics;
  72. })(BABYLON || (BABYLON = {}));