From 826b5bd7f3942a9c9bbaf3221316d75665d877d4 Mon Sep 17 00:00:00 2001 From: Leven <475563418@qq.com> Date: Wed, 17 Aug 2022 17:49:37 +0800 Subject: [PATCH] fix: change THREE.Math to THREE.MathUtils change THREE.Math to THREE.MathUtils --- src/Renderer/Camera.js | 4 ++-- src/Utils/CameraUtils.js | 2 +- test/unit/CameraUtils.js | 2 +- test/unit/globeview.js | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Renderer/Camera.js b/src/Renderer/Camera.js index 3bb36b28ac..efc7302921 100644 --- a/src/Renderer/Camera.js +++ b/src/Renderer/Camera.js @@ -153,8 +153,8 @@ class Camera { this.camera3D.bottom = -halfH; this.camera3D.top = halfH; } else if (this.camera3D.isPerspectiveCamera) { - this.camera3D.fov = 2 * THREE.Math.radToDeg(Math.atan( - (height / this.height) * Math.tan(THREE.Math.degToRad(this.camera3D.fov) / 2), + this.camera3D.fov = 2 * THREE.MathUtils.radToDeg(Math.atan( + (height / this.height) * Math.tan(THREE.MathUtils.degToRad(this.camera3D.fov) / 2), )); } this.camera3D.aspect = ratio; diff --git a/src/Utils/CameraUtils.js b/src/Utils/CameraUtils.js index fa41799095..70c2f808e7 100644 --- a/src/Utils/CameraUtils.js +++ b/src/Utils/CameraUtils.js @@ -457,7 +457,7 @@ export default { cameraTransformOptions.range = 1000; } else if (camera.isPerspectiveCamera) { // setup range for camera placement - const verticalFOV = THREE.Math.degToRad(camera.fov); + const verticalFOV = THREE.MathUtils.degToRad(camera.fov); if (dimensions.x / dimensions.y > camera.aspect) { const focal = (view.domElement.clientHeight * 0.5) / Math.tan(verticalFOV * 0.5); const horizontalFOV = 2 * Math.atan(view.domElement.clientWidth * 0.5 / focal); diff --git a/test/unit/CameraUtils.js b/test/unit/CameraUtils.js index 99adaeee3c..c5569bbe13 100644 --- a/test/unit/CameraUtils.js +++ b/test/unit/CameraUtils.js @@ -155,7 +155,7 @@ describe('Camera utils unit test', function () { camera3D.updateMatrixWorld(true); assert.ok( CameraUtils.getCameraTransformOptionsFromExtent(view, camera3D, subExtent).range - - subExtent.planarDimensions().y / (2 * Math.tan(THREE.Math.degToRad(camera3D.fov) / 2)) < 10 ** -14, + subExtent.planarDimensions().y / (2 * Math.tan(THREE.MathUtils.degToRad(camera3D.fov) / 2)) < 10 ** -14, ); }); }); diff --git a/test/unit/globeview.js b/test/unit/globeview.js index f6df067ba8..ea8a891baa 100644 --- a/test/unit/globeview.js +++ b/test/unit/globeview.js @@ -103,9 +103,8 @@ describe('GlobeView', function () { new OBB().setFromExtent(extent).box3D.getSize(size); assert.ok( CameraUtils.getTransformCameraLookingAtTarget(extentViewer, camera3D).range - - size.x / (2 * Math.tan(THREE.Math.degToRad(camera3D.fov) / 2)) + size.x / (2 * Math.tan(THREE.MathUtils.degToRad(camera3D.fov) / 2)) < 10 ** -6, ); }); }); -