123456789101112131415161718192021222324252627282930313233343536373839 |
- import MathLight from './MathLight'
- var cameraLight = {
- clampVFOV: function (currentFov, maxHFov, width, height) {
- //限制currentFov, 使之造成的横向fov不大于指定值maxHFov
- var r = cameraLight.getHFOVFromVFOV(currentFov, width, height)
- return r > maxHFov ? cameraLight.getVFOVFromHFOV(maxHFov, width, height) : currentFov
- },
- getHFOVForCamera: function (camera, width, height) {
- return cameraLight.getHFOVFromVFOV(camera.fov, width, height)
- },
- getHFOVFromVFOV: function (fov, width, height) {
- return 2 * Math.atan(Math.tan((fov * MathLight.RADIANS_PER_DEGREE) / 2) * (width / height)) * MathLight.DEGREES_PER_RADIAN
- },
- getVFOVFromHFOV: function (fov, width, height) {
- return 2 * Math.atan(Math.tan((fov * MathLight.RADIANS_PER_DEGREE) / 2) * (height / width)) * MathLight.DEGREES_PER_RADIAN
- },
- /* clampVFOV: function(fov, t, i, n) {
- var r = cameraLight.getHFOVFromVFOV(fov, i, n);
- return r > t ? cameraLight.getVFOVFromHFOV(t, i, n) : fov
- },
- getHFOVForCamera: function(e, t, i) {
- return cameraLight.getHFOVFromVFOV(e.fov, t, i)
- },
- getHFOVFromVFOV: function(fov, t, i) {
- var n = t
- , o = i
- , a = 2 * Math.atan(Math.tan(fov * MathLight.RADIANS_PER_DEGREE / 2) * (n / o)) * MathLight.DEGREES_PER_RADIAN;
- return a
- },
- getVFOVFromHFOV: function(e, t, i) {
- var n = t
- , o = i
- , a = 2 * Math.atan(Math.tan(e * MathLight.RADIANS_PER_DEGREE / 2) * (o / n)) * MathLight.DEGREES_PER_RADIAN;
- return a
- } */
- }
- export default cameraLight
|