From d75eb6328e68e900a2a814cec2056d8c39b33f77 Mon Sep 17 00:00:00 2001 From: yushiang Date: Sun, 17 Dec 2023 19:26:22 +0800 Subject: [PATCH 1/2] fix: enable camera rotation and zooming in editors. --- packages/three/core/helpers/CameraControls.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/three/core/helpers/CameraControls.js b/packages/three/core/helpers/CameraControls.js index 0435700..9c9a4d8 100644 --- a/packages/three/core/helpers/CameraControls.js +++ b/packages/three/core/helpers/CameraControls.js @@ -91,7 +91,12 @@ function CameraControls(camera, domElement) { }; let constraintPanEvent = null; - const focus = (object, constraintPan = true) => { + const focus = ( + object, + constraintZoom = true, + constraintPan = true, + constraintRotate = true + ) => { if (!object) return; const { origin, distance, boundingBox } = getFocusSettings( object, @@ -106,7 +111,21 @@ function CameraControls(camera, domElement) { controls.minDistance = 0; controls.update(); - setMode(MODE.TOP_VIEW, object); + if (constraintZoom) { + const { distance: minDistance } = getFocusSettings(object, 1.0); + const { distance: maxDistance } = getFocusSettings(object, 0.5); + controls.maxDistance = maxDistance; + controls.minDistance = minDistance; + controls.update(); + } + + if (constraintRotate) { + controls.maxPolarAngle = Math.PI / 2; + controls.minPolarAngle = 0; + controls.maxAzimuthAngle = Infinity; + controls.minAzimuthAngle = -Infinity; + controls.update(); + } if (constraintPan) { const checkTarget = () => { From e58298fac4f4d384d59156907f4855af415958d1 Mon Sep 17 00:00:00 2001 From: yushiang Date: Sun, 17 Dec 2023 19:28:26 +0800 Subject: [PATCH 2/2] doc: changelog MR#71. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e84a9b..e8be4b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://github.com/olivierlacan/keep-a ### Fixed +- Fix don't camera rotation and zooming in editors. (https://github.com/yushiang-demo/pano-to-mesh/pull/71) + ### Removed ## [2.0.0] - 2023-12-16