ca6a19d57fb85f6722a1cfa3834164a044312c3b1684a4483d63370bb4d27af8.json 7.7 KB

1
  1. {"ast":null,"code":"import { Matrix } from \"../../Maths/math.vector.js\";\n/**\n * This represents all the required metrics to create a VR camera.\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_introduction#device-orientation-camera\n */\nexport class VRCameraMetrics {\n constructor() {\n /**\n * Define if the current vr camera should compensate the distortion of the lens or not.\n */\n this.compensateDistortion = true;\n /**\n * Defines if multiview should be enabled when rendering (Default: false)\n */\n this.multiviewEnabled = false;\n }\n /**\n * Gets the rendering aspect ratio based on the provided resolutions.\n */\n get aspectRatio() {\n return this.hResolution / (2 * this.vResolution);\n }\n /**\n * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.\n */\n get aspectRatioFov() {\n return 2 * Math.atan(this.postProcessScaleFactor * this.vScreenSize / (2 * this.eyeToScreenDistance));\n }\n /**\n * @internal\n */\n get leftHMatrix() {\n const meters = this.hScreenSize / 4 - this.lensSeparationDistance / 2;\n const h = 4 * meters / this.hScreenSize;\n return Matrix.Translation(h, 0, 0);\n }\n /**\n * @internal\n */\n get rightHMatrix() {\n const meters = this.hScreenSize / 4 - this.lensSeparationDistance / 2;\n const h = 4 * meters / this.hScreenSize;\n return Matrix.Translation(-h, 0, 0);\n }\n /**\n * @internal\n */\n get leftPreViewMatrix() {\n return Matrix.Translation(0.5 * this.interpupillaryDistance, 0, 0);\n }\n /**\n * @internal\n */\n get rightPreViewMatrix() {\n return Matrix.Translation(-0.5 * this.interpupillaryDistance, 0, 0);\n }\n /**\n * Get the default VRMetrics based on the most generic setup.\n * @returns the default vr metrics\n */\n static GetDefault() {\n const result = new VRCameraMetrics();\n result.hResolution = 1280;\n result.vResolution = 800;\n result.hScreenSize = 0.149759993;\n result.vScreenSize = 0.0935999975;\n result.vScreenCenter = 0.0467999987;\n result.eyeToScreenDistance = 0.0410000011;\n result.lensSeparationDistance = 0.063500002;\n result.interpupillaryDistance = 0.064000003;\n result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];\n result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];\n result.postProcessScaleFactor = 1.714605507808412;\n result.lensCenterOffset = 0.151976421;\n return result;\n }\n}","map":{"version":3,"names":["Matrix","VRCameraMetrics","constructor","compensateDistortion","multiviewEnabled","aspectRatio","hResolution","vResolution","aspectRatioFov","Math","atan","postProcessScaleFactor","vScreenSize","eyeToScreenDistance","leftHMatrix","meters","hScreenSize","lensSeparationDistance","h","Translation","rightHMatrix","leftPreViewMatrix","interpupillaryDistance","rightPreViewMatrix","GetDefault","result","vScreenCenter","distortionK","chromaAbCorrection","lensCenterOffset"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Cameras/VR/vrCameraMetrics.js"],"sourcesContent":["import { Matrix } from \"../../Maths/math.vector.js\";\n/**\n * This represents all the required metrics to create a VR camera.\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_introduction#device-orientation-camera\n */\nexport class VRCameraMetrics {\n constructor() {\n /**\n * Define if the current vr camera should compensate the distortion of the lens or not.\n */\n this.compensateDistortion = true;\n /**\n * Defines if multiview should be enabled when rendering (Default: false)\n */\n this.multiviewEnabled = false;\n }\n /**\n * Gets the rendering aspect ratio based on the provided resolutions.\n */\n get aspectRatio() {\n return this.hResolution / (2 * this.vResolution);\n }\n /**\n * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.\n */\n get aspectRatioFov() {\n return 2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance));\n }\n /**\n * @internal\n */\n get leftHMatrix() {\n const meters = this.hScreenSize / 4 - this.lensSeparationDistance / 2;\n const h = (4 * meters) / this.hScreenSize;\n return Matrix.Translation(h, 0, 0);\n }\n /**\n * @internal\n */\n get rightHMatrix() {\n const meters = this.hScreenSize / 4 - this.lensSeparationDistance / 2;\n const h = (4 * meters) / this.hScreenSize;\n return Matrix.Translation(-h, 0, 0);\n }\n /**\n * @internal\n */\n get leftPreViewMatrix() {\n return Matrix.Translation(0.5 * this.interpupillaryDistance, 0, 0);\n }\n /**\n * @internal\n */\n get rightPreViewMatrix() {\n return Matrix.Translation(-0.5 * this.interpupillaryDistance, 0, 0);\n }\n /**\n * Get the default VRMetrics based on the most generic setup.\n * @returns the default vr metrics\n */\n static GetDefault() {\n const result = new VRCameraMetrics();\n result.hResolution = 1280;\n result.vResolution = 800;\n result.hScreenSize = 0.149759993;\n result.vScreenSize = 0.0935999975;\n result.vScreenCenter = 0.0467999987;\n result.eyeToScreenDistance = 0.0410000011;\n result.lensSeparationDistance = 0.063500002;\n result.interpupillaryDistance = 0.064000003;\n result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];\n result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];\n result.postProcessScaleFactor = 1.714605507808412;\n result.lensCenterOffset = 0.151976421;\n return result;\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,4BAA4B;AACnD;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,CAAC;EACzBC,WAAWA,CAAA,EAAG;IACV;AACR;AACA;IACQ,IAAI,CAACC,oBAAoB,GAAG,IAAI;IAChC;AACR;AACA;IACQ,IAAI,CAACC,gBAAgB,GAAG,KAAK;EACjC;EACA;AACJ;AACA;EACI,IAAIC,WAAWA,CAAA,EAAG;IACd,OAAO,IAAI,CAACC,WAAW,IAAI,CAAC,GAAG,IAAI,CAACC,WAAW,CAAC;EACpD;EACA;AACJ;AACA;EACI,IAAIC,cAAcA,CAAA,EAAG;IACjB,OAAO,CAAC,GAAGC,IAAI,CAACC,IAAI,CAAE,IAAI,CAACC,sBAAsB,GAAG,IAAI,CAACC,WAAW,IAAK,CAAC,GAAG,IAAI,CAACC,mBAAmB,CAAC,CAAC;EAC3G;EACA;AACJ;AACA;EACI,IAAIC,WAAWA,CAAA,EAAG;IACd,MAAMC,MAAM,GAAG,IAAI,CAACC,WAAW,GAAG,CAAC,G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